https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107823
Bug ID: 107823
Summary: Dead Code Elimination Regression at -Os (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 53946
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53946&action=edit
Code
cat case.c #230633
int a;
void bar64_(void);
void foo();
int main() {
char b = a = 6;
for (; a; a = 0) {
bar64_();
b = 0;
}
if (b <= 0)
;
else
foo();
}
`gcc-e4faee8d02ec5d65bf418612f7181823eb08c078 (trunk) -Os` can not eliminate
`foo` but `gcc-releases/gcc-12.2.0 -Os` can.
`gcc-e4faee8d02ec5d65bf418612f7181823eb08c078 (trunk) -Os -S -o /dev/stdout
case.c`
--------- OUTPUT ---------
main:
.LFB0:
.cfi_startproc
pushq %rcx
.cfi_def_cfa_offset 16
movl $6, %eax
movb $6, %dl
.L2:
movl %eax, a(%rip)
testl %eax, %eax
je .L10
call bar64_
xorl %eax, %eax
xorl %edx, %edx
jmp .L2
.L10:
testb %dl, %dl
je .L4
call foo
.L4:
xorl %eax, %eax
popq %rdx
.cfi_def_cfa_offset 8
ret
---------- END OUTPUT ---------
`gcc-releases/gcc-12.2.0 -Os -S -o /dev/stdout case.c`
--------- OUTPUT ---------
main:
.LFB0:
.cfi_startproc
pushq %rax
.cfi_def_cfa_offset 16
movl $6, a(%rip)
call bar64_
xorl %edx, %edx
xorl %eax, %eax
movl %edx, a(%rip)
popq %rcx
.cfi_def_cfa_offset 8
ret
---------- END OUTPUT ---------
Bisects to:
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=353fd1ec3df92fbe66ce1513c5a86bdd5c5e22d1