This is the mail archive of the
mailing list for the GCC project.
Re: [tree-ssa] execute/20021120-1.c
> > In message <20031121212928.GB12416@redhat.com>, Richard Henderson writes:
> > >On Fri, Nov 21, 2003 at 10:17:03PM +0100, Jan Hubicka wrote:
> > >> 1505 if (TYPE_MAIN_VARIANT (orig_type) != TYPE_MAIN_VARIANT (elt_type)
> > >)
> > >> (gdb)
> > >> 1506 return NULL_TREE;
> > >> (gdb) p debug_tree (orig_type)
> > >> <real_type 0x40175c3c double DF
> > >> size <integer_cst 0x4016d6d8 type <integer_type 0x401757b4 bit_size_typ
> > >e> constant invariant 64>
> > >> unit size <integer_cst 0x4016d930 type <integer_type 0x40175740 unsigne
> > >d int> constant invariant 8>
> > >> align 64 symtab 0 alias set 2 precision 64
> > >> pointer_to_this <pointer_type 0x40175d98>>
> > >> $9 = void
> > >> (gdb) p debug_tree (elt_type)
> > >> <real_type 0x4021a4fc double volatile DF
> > >
> > >I really would have thought these would be VARIANTs of one another...
> > Likewise.
> This is what I get for debugging bootstrapped compiler...
> OK, the actually problem is that we are not able to fold
> (plus_expr (addr_expr (array_ref (decl ....
> It seems to me that we should never construct
> (addr_expr (array_ref (decl.... at first place and instead of convert it
> into (plus_expr (addr_expr) (const)), but I can't find proper place to
> hook simplifier to.
the attached patch solves it.
But it seems to me that it catch just top of the iceberg, as we can have
similar issues with COMPONENT_REF and friends and we can also have
nested these REFs together, right?
Is there some code already that is able to compute the proper offset in
such a chases? It seems to me that there must be something in expansion
but I can't find it :(
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 188.8.131.52
diff -c -3 -p -r184.108.40.206 fold-const.c
*** fold-const.c 14 Nov 2003 16:50:00 -0000 220.127.116.11
--- fold-const.c 21 Nov 2003 22:21:12 -0000
*************** fold (tree expr)
*** 5424,5429 ****
--- 5424,5442 ----
+ case ADDR_EXPR:
+ if (TREE_CODE (TREE_OPERAND (t, 0)) == ARRAY_REF)
+ tree base = TREE_OPERAND (TREE_OPERAND (t, 0), 0);
+ tree offset = TREE_OPERAND (TREE_OPERAND (t, 0), 1);
+ tree elt_size = TYPE_SIZE_UNIT (TREE_TYPE (TREE_OPERAND (t, 0)));
+ offset = fold (build (MULT_EXPR, type, offset, elt_size));
+ return build (PLUS_EXPR, type, build1 (ADDR_EXPR, type, base), offset);
+ return t;
return fold (DECL_INITIAL (t));