[Bug tree-optimization/108353] New: Dead Code Elimination Regression at -O2 (trunk vs. 12.2.0)
yann at ywg dot ch
gcc-bugzilla@gcc.gnu.org
Tue Jan 10 12:32:10 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108353
Bug ID: 108353
Summary: Dead Code Elimination Regression at -O2 (trunk vs.
12.2.0)
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: yann at ywg dot ch
Target Milestone: ---
Created attachment 54228
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54228&action=edit
presented code as file
cat case.c #99
enum { a } b();
int d;
int e;
int f;
void foo();
void bar49_(void);
void(c)();
static short g(int h, int i) {
int j = 2874288693, k = 1;
if (h)
for (; j; j = j + 9) {
f = 0;
for (; f <= 1; c())
k = 90;
}
i = k;
for (; e; ++e) {
if (i)
continue;
foo();
i = b();
}
return 4;
}
int l() {
bar49_();
return 1;
}
int main() { d = d || g(d, l()); }
`gcc-cb93c5f8008b95743b741d6f1842f9be50c6985c (trunk) -O2` can not eliminate
`foo` but `gcc-releases/gcc-12.2.0 -O2` can.
`gcc-cb93c5f8008b95743b741d6f1842f9be50c6985c (trunk) -O2 -S -o /dev/stdout
case.c`
--------- OUTPUT ---------
main:
.LFB2:
.cfi_startproc
movl d(%rip), %eax
testl %eax, %eax
je .L20
movl $1, d(%rip)
xorl %eax, %eax
ret
.L20:
pushq %rbx
.cfi_def_cfa_offset 16
.cfi_offset 3, -16
call bar49_
cmpl $0, d(%rip)
jne .L12
movl $1, %eax
.L9:
cmpl $0, e(%rip)
je .L5
.L7:
addl $1, e(%rip)
je .L5
.L11:
testl %eax, %eax
jne .L7
call foo
xorl %eax, %eax
call b
addl $1, e(%rip)
jne .L11
.L5:
movl $1, d(%rip)
xorl %eax, %eax
popq %rbx
.cfi_remember_state
.cfi_def_cfa_offset 8
ret
.L12:
.cfi_restore_state
movl $1112290355, %ebx
.p2align 4,,10
.p2align 3
.L6:
movl $0, f(%rip)
.p2align 4,,10
.p2align 3
.L8:
xorl %eax, %eax
call c
cmpl $1, f(%rip)
jle .L8
subl $1, %ebx
jne .L6
movl $90, %eax
jmp .L9
---------- END OUTPUT ---------
`gcc-releases/gcc-12.2.0 -O2 -S -o /dev/stdout case.c`
--------- OUTPUT ---------
main:
.LFB2:
.cfi_startproc
movl d(%rip), %eax
testl %eax, %eax
je .L19
movl $1, d(%rip)
xorl %eax, %eax
ret
.L19:
pushq %rbx
.cfi_def_cfa_offset 16
.cfi_offset 3, -16
call bar49_
cmpl $0, d(%rip)
je .L11
movl $1112290355, %ebx
.p2align 4,,10
.p2align 3
.L7:
movl $0, f(%rip)
.p2align 4,,10
.p2align 3
.L10:
xorl %eax, %eax
call c
cmpl $1, f(%rip)
jle .L10
subl $1, %ebx
jne .L7
.L11:
cmpl $0, e(%rip)
je .L6
movl $0, e(%rip)
.L6:
movl $1, d(%rip)
xorl %eax, %eax
popq %rbx
.cfi_def_cfa_offset 8
ret
---------- END OUTPUT ---------
Bisects to:
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=af96500eea72c674a5686b35c66202ef2bd9688f
More information about the Gcc-bugs
mailing list