[Bug tree-optimization/110875] New: [14 Regression] Dead Code Elimination Regression since r14-2501-g285c9d042e9
theodort at inf dot ethz.ch
gcc-bugzilla@gcc.gnu.org
Wed Aug 2 13:56:34 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110875
Bug ID: 110875
Summary: [14 Regression] Dead Code Elimination Regression since
r14-2501-g285c9d042e9
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/rjxT5PfzY
Given the following code:
void foo(void);
static int a, b;
static int *c = &a, *d;
static unsigned e;
static short f;
static unsigned g(unsigned char h, char i) { return h + i; }
int main() {
d = &a;
int *j = d;
e = -27;
for (; e > 18; e = g(e, 6)) {
a = 0;
for (; a != -3; a--) {
if (0 != a ^ *j)
for (; b; b++) f = -f;
else if (*c) {
foo();
break;
}
if (!(((e) >= 235) && ((e) <= 4294967269))) {
__builtin_unreachable();
}
b = 0;
}
}
}
gcc-trunk -O2 does not eliminate the call to foo:
main:
subq $8, %rsp
movl $-27, e(%rip)
.p2align 4,,10
.p2align 3
.L5:
xorl %eax, %eax
.L3:
subl $1, %eax
cmpl $-3, %eax
je .L2
cmpl $1, %eax
jne .L3
movl $1, a(%rip)
movl $0, b(%rip)
call foo
.L6:
movzbl e(%rip), %eax
addl $6, %eax
movl %eax, e(%rip)
cmpl $18, %eax
jg .L5
xorl %eax, %eax
addq $8, %rsp
ret
.p2align 4,,10
.p2align 3
.L2:
movl $-3, a(%rip)
movl $0, b(%rip)
jmp .L6
gcc-13.2.0 -O2 eliminates the call to foo:
main:
movl $-27, e(%rip)
movl $-27, %esi
.p2align 4,,10
.p2align 3
.L9:
movzwl f(%rip), %r11d
xorl %ecx, %ecx
xorl %r10d, %r10d
xorl %edx, %edx
movl $0, a(%rip)
movl b(%rip), %eax
leal -235(%rsi), %r8d
jmp .L7
.p2align 4,,10
.p2align 3
.L2:
cmpl $-262, %r8d
ja .L28
subl $1, %edx
xorl %eax, %eax
movl $1, %ecx
cmpl $-3, %edx
je .L32
movl %edx, %r9d
.L7:
xorl %esi, %esi
testl %edx, %edx
movl %ecx, %edi
setne %sil
cmpl %edx, %esi
je .L2
testl %eax, %eax
je .L2
testb $1, %al
je .L3
negl %r11d
addl $1, %eax
je .L30
.p2align 4,,10
.p2align 3
.L3:
addl $2, %eax
jne .L3
.L30:
movl $1, %edi
movl $1, %r10d
jmp .L2
.p2align 4,,10
.p2align 3
.L32:
movl $-3, a(%rip)
movl $0, b(%rip)
testb %r10b, %r10b
je .L8
movw %r11w, f(%rip)
.L8:
movzbl e(%rip), %esi
addl $6, %esi
movl %esi, e(%rip)
cmpl $18, %esi
jg .L9
xorl %eax, %eax
ret
.section .text.unlikely
.type main.cold, @function
main.cold:
.L28:
testb %cl, %cl
je .L5
movl %r9d, a(%rip)
.L5:
testb %dil, %dil
je .L6
movl %eax, b(%rip)
.L6:
movw %r11w, f(%rip)
.section .text.startup
Bisects to r14-2501-g285c9d042e9
More information about the Gcc-bugs
mailing list