https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103280
Bug ID: 103280
Summary: [12 Regression] Dead Code Elimination Regression at
-O3 (trunk vs 11.2.0)
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: theodort at inf dot ethz.ch
Target Milestone: ---
cat case.c
void bar(void);
void foo(void);
static char a;
int main() {
short b = -25536;
for (; a; a = 1) {
bar();
if (b)
b = 1;
else
foo();
}
}
trunk cannot eliminate the call to foo but 11.2.0 can:
gcc-11.2.0 -O3 -S -o /dev/stdout case.c
main:
.LFB0:
.cfi_startproc
cmpb $0, a(%rip)
je .L2
pushq %rax
.cfi_def_cfa_offset 16
call bar
.p2align 4,,10
.p2align 3
.L3:
movb $1, a(%rip)
call bar
movb $1, a(%rip)
call bar
jmp .L3
.p2align 4,,10
.p2align 3
.L2:
.cfi_def_cfa_offset 8
xorl %eax, %eax
ret
.cfi_endproc
gcc-trunk -O3 -S -o /dev/stdout case.c
main:
.LFB0:
.cfi_startproc
cmpb $0, a(%rip)
je .L2
pushq %rbx
.cfi_def_cfa_offset 16
.cfi_offset 3, -16
movl $-25536, %ebx
jmp .L4
.p2align 4,,10
.p2align 3
.L5:
movl $1, %ebx
.L3:
movb $1, a(%rip)
.L4:
call bar
testw %bx, %bx
jne .L5
call foo
jmp .L3
.p2align 4,,10
.p2align 3
.L2:
.cfi_def_cfa_offset 8
.cfi_restore 3
xorl %eax, %eax
ret
.cfi_endproc
gcc-trunk -v
Using built-in specs.
Target: x86_64-pc-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.0.0 20211116 (experimental) (GCC)
Started with
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=e53fbb17839723ea1697fcbaf76b1c092675eaaf