https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110873
Bug ID: 110873
Summary: [14 Regression] Dead Code Elimination Regression at
-O2 since r14-376-g47a76439911
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: scherrer.sv at gmail dot com
Target Milestone: ---
static int b;
static short c;
static char d;
static int *e = &b;
void foo(void);
void bar110_(void);
static char(a)(char f, char g) { return f + g; }
int main() {
*e = 3;
unsigned char h;
c = 0;
i:
if (!b)
foo();
h = -25;
for (; h >= 7; h = a(h, 6))
for (; d; d--)
;
if (!(h >= 5))
bar110_();
if (c)
goto i;
}
-----------------------------------------------------------------------
gcc-68c3aa7510b (trunk) -O2 cannot eliminate the call to foo but
gcc-releases/gcc-13.1.0 -O2 can
-----------------------------------------------------------------------
gcc-68c3aa7510b2f45f44379ecd77e97c88780a84ed -O2 case.c -S -o case.s
--------- OUTPUT ---------
main:
.LFB1:
.cfi_startproc
movl $3, b(%rip)
xorl %esi, %esi
movw %si, c(%rip)
.L11:
cmpb $0, d(%rip)
je .L13
movb $0, d(%rip)
.L13:
cmpw $0, c(%rip)
je .L15
movl b(%rip), %eax
testl %eax, %eax
jne .L11
subq $8, %rsp
.cfi_def_cfa_offset 16
.L6:
call foo
.L2:
cmpb $0, d(%rip)
je .L4
movb $0, d(%rip)
.L4:
cmpw $0, c(%rip)
je .L5
movl b(%rip), %ecx
testl %ecx, %ecx
jne .L2
jmp .L6
.L15:
.cfi_def_cfa_offset 8
xorl %eax, %eax
ret
.L5:
.cfi_def_cfa_offset 16
xorl %eax, %eax
popq %rdx
.cfi_def_cfa_offset 8
ret
---------- END OUTPUT ---------
-----------------------------------------------------------------------
gcc-2b98cc24d6af0432a74f6dad1c722ce21c1f7458 -O2 case.c -S -o case.s
--------- OUTPUT ---------
main:
.LFB1:
.cfi_startproc
movl $3, b(%rip)
xorl %eax, %eax
cmpb $0, d(%rip)
movw %ax, c(%rip)
je .L3
movb $0, d(%rip)
.L3:
xorl %eax, %eax
ret
---------- END OUTPUT ---------
-----------------------------------------------------------------------
Bisects to r14-376-g47a76439911