[Bug tree-optimization/94718] Failure to optimize opposite signs check
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Apr 23 13:15:05 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94718
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I guess:
int
foo (int x, int y)
{
return (x < 0) != (y < 0);
}
int
bar (int x, int y)
{
return (x < 0) == (y < 0);
}
int
baz (int x, int y)
{
return (x >= 0) != (y >= 0);
}
int
qux (int x, int y)
{
return (x >= 0) == (y <= 0);
}
which we don't optimize ATM is equivalent to:
#define I (-__INT_MAX__ - 1)
int
foo (int x, int y)
{
return (x & I) != (y & I);
}
int
bar (int x, int y)
{
return (x & I) == (y & I);
}
int
baz (int x, int y)
{
return (~x & I) != (~y & I);
}
int
qux (int x, int y)
{
return (~x & I) == (~y & I);
}
int
quux (int x, int y)
{
return ((x & I) ^ I) != ((y & I) ^ I);
}
int
corge (int x, int y)
{
return ((x & I) ^ I) == ((~y & I) ^ I);
}
which we do (already in *.original dump), but then
#define I (-__INT_MAX__ - 1)
int
foo (int x, int y)
{
int s = (x & I);
int t = (y & I);
return s != t;
}
int
bar (int x, int y)
{
int s = (x & I);
int t = (y & I);
return s == t;
}
int
baz (int x, int y)
{
int s = (~x & I);
int t = (~y & I);
return s != t;
}
int
qux (int x, int y)
{
int s = (~x & I);
int t = (~y & I);
return s == t;
}
int
quux (int x, int y)
{
int s = ((x & I) ^ I);
int t = ((y & I) ^ I);
return s != t;
}
int
corge (int x, int y)
{
int s = ((x & I) ^ I);
int t = ((~y & I) ^ I);
return s == t;
}
is not again, which means we optimize this somewhere in fold-const.c or where
and don't in match.pd.
More information about the Gcc-bugs
mailing list