https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110502
Bug ID: 110502 Summary: [14 Regression] Dead Code Elimination Regression at -Os since r14-1656-g55fcaa9a8bd Product: gcc Version: 14.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: --- https://godbolt.org/z/T9rv1nsGr Given the following code: void foo(void); static char e = -3L, k; static int f; static int *g; static signed char *h = &e; static signed char **i = &h; static unsigned j; static char(a)(char b, char c) { return b + c; } static int(d)(int b, int c) { return b && b < -c ? b : b + c; } static char l(char *n, unsigned short o) { char p; int q, s = 4104765887; int *r = &f; if (!(((o) >= 65533) && ((o) <= 65533))) { __builtin_unreachable(); } for (; s <= 4; s = a(s, 5)) { int **t = &g; *t = &s; j++; p = *n; q = d(*g, p); *r = q; } if (g || f) ; else foo(); return 0; } int main() { l(&e, e); char m = &k == (*i = &m); } gcc-trunk -Os does not eliminate the call to foo: main: pushq %rbx movl $-190201409, %edx xorl %esi, %esi subq $16, %rsp movl j(%rip), %ecx movl $-190201409, 12(%rsp) leal 15(%rcx), %r8d .L2: leal 1(%rcx), %edi cmpl %r8d, %edi je .L8 testl %edx, %edx movb $1, %sil sete %al cmpl $2, %edx setg %cl orl %ecx, %eax movl %edi, %ecx movzbl %al, %eax negl %eax andl $-3, %eax addl %edx, %eax addl $5, %edx movsbl %dl, %edx jmp .L2 .L8: testb %sil, %sil leaq 12(%rsp), %rbx je .L4 movq %rbx, g(%rip) movl %ecx, j(%rip) movl %eax, f(%rip) jmp .L5 .L4: cmpq $0, g(%rip) jne .L5 cmpl $0, f(%rip) jne .L5 call foo .L5: movq %rbx, h(%rip) addq $16, %rsp xorl %eax, %eax popq %rbx ret gcc-13.1.0 -Os eliminates the call to foo: main: movl j(%rip), %edx movl $-190201409, %eax leal 14(%rdx), %esi .L4: testl %eax, %eax je .L6 movl %eax, %ecx cmpl $2, %eax jle .L2 .L6: leal -3(%rax), %ecx .L2: addl $5, %eax incl %edx movsbl %al, %eax cmpl %esi, %edx jne .L4 leaq -4(%rsp), %rax movl %ecx, f(%rip) movq %rax, g(%rip) movq %rax, h(%rip) xorl %eax, %eax movl %edx, j(%rip) ret Bisects to r14-1656-g55fcaa9a8bd