[llvm-bugs] [Bug 52253] New: Dead Code Elimination Regression at -O3 (trunk vs 13.0.0)
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Oct 21 07:13:18 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=52253
Bug ID: 52253
Summary: Dead Code Elimination Regression at -O3 (trunk vs
13.0.0)
Product: new-bugs
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: theodort at inf.ethz.ch
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org
cat test.c
void foo(void);
static int c, d;
static char e, f;
static char a(char h, int i) { return h ? h : h << i; }
int main() {
int j = 1;
for (; d < 1; d++) {
f = c;
if ((c = f + 979) ^ a(j, 1)) {
a(0, 0);
j = e;
} else
foo();
}
}
13.0.0 at -O3 can eliminate the call to foo but trunk cannot:
clang-13 -O3 -S -o /dev/stdout test.c
...
main: # @main
.cfi_startproc
# %bb.0:
movl d(%rip), %eax
testl %eax, %eax
jle .LBB0_1
# %bb.9:
xorl %eax, %eax
retq
.LBB0_1:
movl c(%rip), %ecx
movl $1, %esi
subl %eax, %esi
movl %eax, %edx
negl %edx
andl $3, %esi
je .LBB0_2
# %bb.3:
negl %esi
xorl %edi, %edi
.p2align 4, 0x90
.LBB0_4: # =>This Inner Loop Header: Depth=1
movsbl %cl, %ecx
addl $979, %ecx # imm = 0x3D3
addl $-1, %edi
cmpl %edi, %esi
jne .LBB0_4
# %bb.5:
subl %edi, %eax
movl %eax, %esi
cmpl $3, %edx
jb .LBB0_8
.p2align 4, 0x90
.LBB0_7: # =>This Inner Loop Header: Depth=1
addb $121, %cl
movsbl %cl, %ecx
addl $979, %ecx # imm = 0x3D3
leal 4(%rax), %esi
cmpl $-3, %eax
movl %esi, %eax
jl .LBB0_7
.LBB0_8:
movl %ecx, c(%rip)
movl %esi, d(%rip)
xorl %eax, %eax
retq
.LBB0_2:
# implicit-def: $esi
cmpl $3, %edx
jae .LBB0_7
jmp .LBB0_8
clang-trunk -O3 -S -o /dev/stdout test.c
...
main: # @main
.cfi_startproc
# %bb.0:
pushq %rbx
.cfi_def_cfa_offset 16
.cfi_offset %rbx, -16
movl d(%rip), %esi
testl %esi, %esi
jle .LBB0_1
.LBB0_5:
xorl %eax, %eax
popq %rbx
.cfi_def_cfa_offset 8
retq
.LBB0_1:
.cfi_def_cfa_offset 16
movl $1, %ebx
movl c(%rip), %edx
jmp .LBB0_2
.p2align 4, 0x90
.LBB0_4: # in Loop: Header=BB0_2 Depth=1
leal 1(%rsi), %eax
movl %eax, d(%rip)
movl %ecx, %ebx
testl %esi, %esi
movl %eax, %esi
jns .LBB0_5
.LBB0_2: # =>This Inner Loop Header: Depth=1
movsbl %dl, %edx
addl $979, %edx # imm = 0x3D3
testb %bl, %bl
sete %cl
movl %ebx, %eax
shlb %cl, %al
movl %edx, c(%rip)
movzbl %al, %eax
xorl %ecx, %ecx
cmpl %eax, %edx
jne .LBB0_4
# %bb.3: # in Loop: Header=BB0_2 Depth=1
callq foo
movl c(%rip), %edx
movl d(%rip), %esi
movl %ebx, %ecx
jmp .LBB0_4
clang-trunk -v
clang version 14.0.0 (https://github.com/llvm/llvm-project.git
7ff4f48adb26429086d6fd85a14336e57cd340dc)
Target: x86_64-unknown-linux-gnu
Thread model: posix
This was introduced by
https://github.com/llvm/llvm-project/commit/1f3e35b6d165715ec7bf7ba80d5b982719c7752a
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211021/57e865c1/attachment.html>
More information about the llvm-bugs
mailing list