This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: fold: &a[i1] + c * i2 -> &a[i1 + i2] messing up types
Hello,
> > I don't think it is a good idea. TYPE argument of
> > try_move_mult_to_index really should be type of the arguments it works
> > with, or you are creating a nasty hack and source for other possible
> > bugs.
>
> Well, the type argument is only used for constructing the ADDR_EXPR
> which has to match TREE_TYPE (addr) due to checking constraints. So
> we could equally omit that argument. Or give it the meaning I read
> into the functions comment:
>
> /* Tries to replace &a[idx] CODE s * delta with &a[idx CODE delta], if s
> is
> step of the array. TYPE is the type of the expression. ADDR is the
> address.
> MULT is the multiplicative expression. If the function succeeds, the
> new
> address expression is returned. Otherwise NULL_TREE is returned. */
>
> namely, that we want a tree of type "type" which is the type of the
> whole expression, not of the ADDR_EXPR. But just working around this
> possible redundant argument in the callers seems wrong to me, too.
>
> If you prefer removing the type argument that would be fine, too.
this might be a good idea, yes.
Zdenek