http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53705
Bug #: 53705
Summary: wrong code with custom flags - stores to memory are
lost
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
AssignedTo: [email protected]
ReportedBy: [email protected]
Created attachment 27640
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27640
reduced testcase (from testsuite/gcc.c-torture/execute/loop-2e.c)
GCC 4.3-4.8 fails, while with GCC 4.2, the code is reduced just to return 0. I
am not sure if this should be marked as a regression.
Compiler output:
$ gcc -O2 -fno-omit-frame-pointer -fpeel-loops -fsched2-use-superblocks
-fno-tree-loop-optimize -fno-web --param=max-completely-peel-times=256
testcase.c
$ ./a.out
Aborted
Looking at the assembly:
...
sub rsp, 320 #,
mov rdx, QWORD PTR p[rip] # p.0, p
lea rcx, [rbp-320] # q,
...
mov QWORD PTR [rcx+240], rdi # *q_19, tmp73
lea rax, [rdx+144] # tmp73,
lea rsi, [rdx+148] # tmp73,
lea rdi, [rdx+152] # tmp73,
lea rdx, [rdx+156] # tmp73,
cmp QWORD PTR [rbp-8], rdx # q, tmp73
mov QWORD PTR [rcx+280], rax # *q_19, tmp73
mov QWORD PTR [rcx+248], r8 # *q_19, tmp73
mov QWORD PTR [rcx+256], r9 # *q_19, tmp73
mov QWORD PTR [rcx+264], r10 # *q_19, tmp73
mov QWORD PTR [rcx+272], r11 # *q_19, tmp73
mov QWORD PTR [rcx+288], rsi # *q_19, tmp73
mov QWORD PTR [rcx+296], rdi # *q_19, tmp73
mov QWORD PTR [rcx+304], rdx # *q_19, tmp73
jne .L46 #,
...
It seems the dependency between storing to *q++ (esp. q[39]) in foo() and
verifying it in main() is lost. Furthermore, it seems q[39] ([rcx+312]) is not
stored to at all.