https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92342
--- Comment #17 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Tried timing:
__attribute__((noipa)) int f(int a,int b, int c)
{
return a==c?b:0;
}
__attribute__((noipa)) int g(int a, int b, int c)
{
return b & -(a==c);
}
int
main (int argc, const char **argv)
{
unsigned int c = 0;
if (argv[1][0] == 'f')
{
for (int i = 0; i < 1000000000; i++)
c += f(1,1,i&1);
}
else
{
for (int i = 0; i < 1000000000; i++)
c += g(1,1,i&1);
}
asm volatile ("" : : "r" (c));
return 0;
}
and the same without the "i&", i.e. alternating results and always same, and
both functions are the same speed in both cases, and cmov is shorter.
Without cmov, such as with -m32 -O2 -march=i586, g seems to be faster, so we
probably should teach ifcvt.c to try it.