https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70087
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2016-03-04
Ever confirmed|0 |1
--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(Ugh... now I hit Tab + Space by mistake.)
$ gcc assoc.c -O2 -o- -S
.file "assoc.c"
.text
.p2align 4,,15
.globl foo
.type foo, @function
foo:
.LFB0:
.cfi_startproc
movl at(%rip), %edx
leal -2(%rdx), %eax
andl $-3, %eax
sete %al
cmpl $7, %edx
sete %dl
orl %edx, %eax
movzbl %al, %eax
ret
.cfi_endproc
.LFE0:
.size foo, .-foo
.p2align 4,,15
.globl bar
.type bar, @function
bar:
.LFB1:
.cfi_startproc
movl at(%rip), %edx
cmpl $2, %edx
je .L4
cmpl $4, %edx
sete %al
cmpl $7, %edx
sete %dl
orl %edx, %eax
movzbl %al, %eax
ret
.p2align 4,,10
.p2align 3
.L4:
movl $1, %eax
movzbl %al, %eax
ret
.cfi_endproc
.LFE1:
.size bar, .-bar
.comm at,4,4
.ident "GCC: (GNU) 6.0.0 20160304 (experimental)"
.section .note.GNU-stack,"",@progbits
On x86_64, the code generated for foo and for bar differ. The code generated
for foo is arguably better since it's branchless.