[Bug target/71336] New: Suboptimal x86 code generated for "(a & 1) ? (CST1 + CST2) : CST1"
ppalka at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon May 30 07:07:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71336
Bug ID: 71336
Summary: Suboptimal x86 code generated for "(a & 1) ? (CST1 +
CST2) : CST1"
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: ppalka at gcc dot gnu.org
Target Milestone: ---
$ cat test.c
int test(int a) {
return a & 1 ? 7 : 3;
}
$ gcc -O2 -o- -S test.c
test:
.LFB0:
.cfi_startproc
andl $1, %edi
cmpl $1, %edi
sbbl %eax, %eax
andl $-4, %eax
addl $7, %eax
ret
.cfi_endproc
The optimal code would look like
andl $1, %edi
leal 3(,%rdi,4), %eax
ret
More information about the Gcc-bugs
mailing list