https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79673
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2017-02-22 Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- <mem_ref 0x7ffff69f2078 type <integer_type 0x7ffff69c1738 long int address-space-2 DI size <integer_cst 0x7ffff68a2cd8 constant 64> unit size <integer_cst 0x7ffff68a2cf0 constant 8> align 64 symtab 0 alias set -1 canonical type 0x7ffff69c1738 precision 64 min <integer_cst 0x7ffff68a2f60 -9223372036854775808> max <integer_cst 0x7ffff68a2f78 9223372036854775807> pointer_to_this <pointer_type 0x7ffff69c1150>> arg 0 <integer_cst 0x7ffff69d42b8 type <pointer_type 0x7ffff69c1150> constant 0> arg 1 <addr_space_convert_expr 0x7ffff69d0f80 type <pointer_type 0x7ffff68c20a8 type <void_type 0x7ffff68baf18 void> public unsigned DI size <integer_cst 0x7ffff68a2cd8 64> unit size <integer_cst 0x7ffff68a2cf0 8> align 64 symtab 0 alias set -1 canonical type 0x7ffff68c20a8 pointer_to_this <pointer_type 0x7ffff68cb2a0>> constant arg 0 <integer_cst 0x7ffff69d42b8 0>>> so I guess we somewhere use fold_convert and expect the literal to be constant folded (but it isn't, instead ADDR_SPACE_CONVERT is created). Indeed. Created by Run till exit from #0 0x0000000000adb6e0 in fold_convert_loc (loc=0, type=<pointer_type 0x7ffff68c20a8>, arg=<integer_cst 0x7ffff69d42b8>) at /space/rguenther/src/svn/gcc-7-branch/gcc/fold-const.c:2234 compute_avail () at /space/rguenther/src/svn/gcc-7-branch/gcc/tree-ssa-pre.c:4004 4004 ref1->op0); Value returned is $8 = (tree_node *) 0x7ffff69d0f80 (gdb) l 3999 else 4000 { 4001 ref->set = 0; 4002 if (ref1->opcode == MEM_REF) 4003 ref1->op0 = fold_convert (ptr_type_node, 4004 ref1->op0); 4005 else 4006 ref1->op2 = fold_convert (ptr_type_node, 4007 ref1->op2); and fold_convert just does case POINTER_TYPE: case REFERENCE_TYPE: /* Handle conversions between pointers to different address spaces. */ if (POINTER_TYPE_P (orig) && (TYPE_ADDR_SPACE (TREE_TYPE (type)) != TYPE_ADDR_SPACE (TREE_TYPE (orig)))) return fold_build1_loc (loc, ADDR_SPACE_CONVERT_EXPR, type, arg); /* fall through */ the issue is the use of ptr_type_node above which should use void * of the correct address space. Or rather simply scrap the addr-space from the offset (it serves no purpose there). Index: gcc/tree-ssa-pre.c =================================================================== --- gcc/tree-ssa-pre.c (revision 245646) +++ gcc/tree-ssa-pre.c (working copy) @@ -3996,11 +4000,11 @@ compute_avail (void) { ref->set = 0; if (ref1->opcode == MEM_REF) - ref1->op0 = fold_convert (ptr_type_node, - ref1->op0); + ref1->op0 = wide_int_to_tree (ptr_type_node, + ref1->op0); else - ref1->op2 = fold_convert (ptr_type_node, - ref1->op2); + ref1->op2 = wide_int_to_tree (ptr_type_node, + ref1->op2); } operands.release (); is a quick fix.