[Bug tree-optimization/95731] Faiilure to optimize a >= 0 && b >= 0 to (a | b) >= 0
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Aug 4 11:30:57 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95731
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I think doing it only in the last reassoc would have the advantage that it
wouldn't break other optimizations done by reassoc.
E.g.
if (a >= 0 && b >= 0 && a < 32 && b < 128)
which can be now optimized into a < 32U && b < 128U couldn't be optimized
unless we teach the reassoc code that (a | b) >= 0 is equivalent to a >= 0 && b
>= 0.
The user can write it that way though:
void bar (int, int);
void
foo (int a, int b)
{
if (a >= 0 && b >= 0 && a < 32 && b < 128)
bar (a, b);
}
void
baz (int a, int b)
{
if ((a | b) >= 0 && a < 32 && b < 128)
bar (a, b);
}
More information about the Gcc-bugs
mailing list