Simplification of relational operations (was [patch for PR18942])
Zdenek Dvorak
rakdver@kam.mff.cuni.cz
Fri Dec 2 08:42:00 GMT 2011
Hi,
> I'm looking at a missed optimizations in combine and it is similar to the one you've fixed in PR18942 (http://thread.gmane.org/gmane.comp.gcc.patches/81504).
>
> I'm trying to make GCC optimize
> (leu:SI
> (plus:SI (reg:SI) (const_int -1))
> (const_int 1))
>
> into
>
> (leu:SI
> (reg:SI)
> (const_int 2))
>
> Your patch for PR18942 handles only EQ/NE comparisons, and I wonder if there
> is a reason not to handle LEU/GEU, LTU/GTU comparisons as well. I'm a bit
> fuzzy whether signed comparisons can be optimized here as well, but I can't
> see the problem with unsigned comparisons.
>
> Any reason why this optimization would be unsafe?
the reason I handled only EQ/NE patterns is that you do not need to worry about
overflows there. For ordering predicates, x - 1 <= 1 is not equivalent to x <= 2
if x = 0 (the former becomes MAX_UNSIGNED_INT <= 1, which is false),
Zdenek
More information about the Gcc
mailing list