<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Dead Code Elimination Regression at -O3 (trunk&13.0.0 vs 12.0.1)"
href="https://bugs.llvm.org/show_bug.cgi?id=52347">52347</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Dead Code Elimination Regression at -O3 (trunk&13.0.0 vs 12.0.1)
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>12.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>theodort@inf.ethz.ch
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>cat test.c
void foo(void);
static int a = 3, b, c[1], d;
void foo(void);
static void f() {
if (a) {
d = (char)c[0];
} else
b = 0;
}
int main() {
a = b = d;
f();
if (b)
foo();
}
12.0.1 at -O3 can eliminate the call to foo but neither 13.0.0 nor trunk can:
clang-12 -O3 -S -o /dev/stdout test.c
...
main: # @main
.cfi_startproc
# %bb.0:
xorl %eax, %eax
retq
clang-trunk -O3 -S -o /dev/stdout test.c
...
main: # @main
.cfi_startproc
# %bb.0:
pushq %rax
.cfi_def_cfa_offset 16
movl $d, %eax
movl d(%rip), %ecx
movl $b, %edx
testl %ecx, %ecx
cmovneq %rax, %rdx
movl %ecx, b(%rip)
movl $0, (%rdx)
cmpl $0, b(%rip)
je .LBB0_2
# %bb.1:
callq foo
.LBB0_2:
xorl %eax, %eax
popq %rcx
.cfi_def_cfa_offset 8
retq
(13.0.0 produces identical code)
clang-trunk -v
clang version 14.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
73453e7adecbcc7208ceb70d5e55086ffbd1de3a)
Target: x86_64-unknown-linux-gnu
Thread model: posix
This was introduced by
<a href="https://github.com/llvm/llvm-project/commit/ed9df5bd2f50b2199204cc6e50910ba52dd5e93e">https://github.com/llvm/llvm-project/commit/ed9df5bd2f50b2199204cc6e50910ba52dd5e93e</a></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>