[tree-ssa] Temporary Expression Replacement in SSA->normal.

Roger Sayle roger@eyesopen.com
Mon Dec 15 16:23:00 GMT 2003


On Mon, 15 Dec 2003, [iso-8859-1] Pop Sébastian wrote:
> In my opinion it is the folder that has to symbolically reduce these
> expressions.  However the folder does not implement the reassociation.
> As an example, consider the dependence test for:
>
>   X[2*N + 1] = ...
>   ... = X[2*N]
>
> where N is a parameter.  Following the way you compute the difference
> of the access functions, the fold works in one of the cases but fails
> on the other:
>
> fold (2*N - 2*N - 1) = -1
> fold (2*N + 1 - 2*N) = 2*N + 1 - 2*N


Have you tried with "-fwrapv"?  The default semantics for overflow is
undefined which means that "X + Y - Z" cannot safely be translated into
"X - Z + Y" in the general case, especially with "-ftrapv".

If -fwrapv doesn't help, let me know and I'll prepare a patch.  Support
for wrap-around arithmetic has only recently been added to the constant
folder, so this optimization may not have been valid until now.

Nice example!

Roger
--



More information about the Gcc-patches mailing list