[Bug tree-optimization/110841] New: [14 Regression] Dead Code Elimination Regression since r14-2675-gef28aadad6e
theodort at inf dot ethz.ch
gcc-bugzilla@gcc.gnu.org
Fri Jul 28 10:10:58 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110841
Bug ID: 110841
Summary: [14 Regression] Dead Code Elimination Regression since
r14-2675-gef28aadad6e
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/YondMzhT8
Given the following code:
void foo(void);
static int b, c, d;
static char(a)(char e, char f) { return e - f; }
int main() {
for (; b <= 4; b++)
;
c = 0;
for (; c >= -16; c = a(c, 4))
;
char g = b;
for (; d <= 0; d++) {
if (!(((g) >= 5) && ((g) <= 5))) {
__builtin_unreachable();
}
if (c) return 0;
g = 0;
for (;;) {
foo();
break;
}
}
}
gcc-trunk -O2 does not eliminate the call to foo:
main:
cmpl $4, b(%rip)
jg .L2
movl $5, b(%rip)
.L2:
movl $-20, c(%rip)
movl d(%rip), %ecx
testl %ecx, %ecx
jg .L10
cmpl $0, c(%rip)
jne .L10
pushq %rax
jmp .L11
.p2align 4,,10
.p2align 3
.L3:
movl c(%rip), %edx
testl %edx, %edx
jne .L5
.L11:
call foo
movl d(%rip), %eax
addl $1, %eax
movl %eax, d(%rip)
testl %eax, %eax
jle .L3
.L5:
xorl %eax, %eax
addq $8, %rsp
ret
.L10:
xorl %eax, %eax
ret
gcc-13.2.0 -O2 eliminates the call to foo:
main:
cmpl $4, b(%rip)
jg .L2
movl $5, b(%rip)
.L2:
movl $-20, c(%rip)
xorl %eax, %eax
ret
Bisects to r14-2675-gef28aadad6e
More information about the Gcc-bugs
mailing list