[llvm-bugs] [Bug 52525] New: Dead Code Elimination Regression at -O3 (trunk vs 13.0.0)
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Nov 16 11:03:44 PST 2021
https://bugs.llvm.org/show_bug.cgi?id=52525
Bug ID: 52525
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 case.c
void foo(void);
static char a(char l) { return l; }
static char c(char l) { return l == 0; }
static int b, d;
static int *g;
int main() {
if (g) {
unsigned char f = b;
char n = f >> 2;
if (c(n)) {
d = a(b) || d;
} else if (!b)
foo();
}
g = &b;
}
trunk cannot eliminate the call to foo but 13.0.0 can:
clang-13.0.0 -O3 -S -o /dev/stdout case.c
main: # @main
.cfi_startproc
# %bb.0:
cmpq $0, g(%rip)
je .LBB0_3
# %bb.1:
movl b(%rip), %eax
testb $-4, %al
je .LBB0_2
.LBB0_3:
movq $b, g(%rip)
xorl %eax, %eax
retq
.LBB0_2:
testb %al, %al
setne %al
cmpl $0, d(%rip)
setne %cl
orb %al, %cl
movzbl %cl, %eax
movl %eax, d(%rip)
movq $b, g(%rip)
xorl %eax, %eax
retq
.Lfunc_end0:
clang-trunk -O3 -S -o /dev/stdout case.c
main: # @main
.cfi_startproc
# %bb.0:
pushq %rax
.cfi_def_cfa_offset 16
cmpq $0, g(%rip)
je .LBB0_5
# %bb.1:
movl b(%rip), %eax
cmpb $3, %al
jbe .LBB0_2
# %bb.3:
testl %eax, %eax
je .LBB0_4
.LBB0_5:
movq $b, g(%rip)
xorl %eax, %eax
popq %rcx
.cfi_def_cfa_offset 8
retq
.LBB0_2:
.cfi_def_cfa_offset 16
testb %al, %al
setne %al
cmpl $0, d(%rip)
setne %cl
orb %al, %cl
movzbl %cl, %eax
movl %eax, d(%rip)
movq $b, g(%rip)
xorl %eax, %eax
popq %rcx
.cfi_def_cfa_offset 8
retq
.LBB0_4:
.cfi_def_cfa_offset 16
callq foo
movq $b, g(%rip)
xorl %eax, %eax
popq %rcx
.cfi_def_cfa_offset 8
retq
.Lfunc_end0:
clang-trunk -v
clang version 14.0.0 (https://github.com/llvm/llvm-project.git
1ee32055ea1dd4db70d1939cbd4f5105c2dce160)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Started with
https://github.com/llvm/llvm-project/commit/f32c0fe8e50534f4210d878b9a1420793860c567
--
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/20211116/243f7f57/attachment.html>
More information about the llvm-bugs
mailing list