[Bug tree-optimization/71336] Suboptimal x86 code generated for "(a & 1) ? (CST1 + CST2) : CST1"
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jul 20 00:17:59 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71336
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|rtl-optimization |tree-optimization
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #3)
> I guess it could be useful even without lea.
Pretty much.
Even on aarch64 we get for the original case:
ubfiz w0, w0, 2, 1
add w0, w0, 3
ret
vs
tst x0, 1
mov w2, 7
mov w1, 3
csel w0, w2, w1, ne
ret
For something slightly different:
unsigned test(unsigned a) {
return a & 4 ? 7 : 3;
}
unsigned test1(unsigned a)
{
a &= 4;
a >>= 2;
return a*4 + 3;
}
----
We get:
tst x0, 4
mov w2, 7
mov w1, 3
csel w0, w2, w1, ne
ret
vs
and w0, w0, 4
add w0, w0, 3
ret
More information about the Gcc-bugs
mailing list