[Bug c/80301] New: Sub-optimal code with an array of structs offsetted inside a struct global on x86/x86_64 at -O2
mednafen at sent dot com
gcc-bugzilla@gcc.gnu.org
Tue Apr 4 06:13:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80301
Bug ID: 80301
Summary: Sub-optimal code with an array of structs offsetted
inside a struct global on x86/x86_64 at -O2
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: mednafen at sent dot com
Target Milestone: ---
Created attachment 41114
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41114&action=edit
test code
gcc -fno-asynchronous-unwind-tables -S -O2 -o test.s -c test.c
The displacement should be coded in the memory access instructions, but instead
a separate addition instruction is being generated.
Assembly is from 4.9.2, but the issue shows up on at least 5.3.0, 6.1.0, and a
relatively recent 7.0 build.
[...]
func:
movl %edi, %edx
addq $2, %rdx
movl m(,%rdx,8), %eax
cmpl %edi, %eax
je .L2
movl m+4(,%rdx,8), %eax
.L2:
rep ret
[...]
More information about the Gcc-bugs
mailing list