[Bug rtl-optimization/71336] Suboptimal x86 code generated for "(a & 1) ? (CST1 + CST2) : CST1"
ppalka at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Aug 16 20:04:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71336
--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
On a related note I noticed the final code for
int test(int a) {
return (a & CST) * 4 + 3;
}
is not optimal when CST is a power of two, e.g. when CST=8:
_Z4testi:
.LFB0:
.cfi_startproc
andl $8, %edi
leal 0(,%rdi,4), %eax
addl $3, %eax
ret
The leal and the addl could be combined into a single leal. When CST is not a
power of two then there is no addl.
More information about the Gcc-bugs
mailing list