<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 vs 13.0.0)"
href="https://bugs.llvm.org/show_bug.cgi?id=52289">52289</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Dead Code Elimination Regression at -O3 (trunk vs 13.0.0)
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</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 b;
static char a(char h, int i) { return h > i ? h : h << i; }
static long d(long h) { return h; }
int main() {
char e = 0;
short g = 0;
b++;
e = a(b & 8, 7);
g = d(e) * 20681;
if (!(g ^ 1))
foo();
a(0, 0);
}
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:
addl $1, b(%rip)
xorl %eax, %eax
retq
.Lfunc_end0
clang-trunk -O3 -S -o /dev/stdout test.c
...
main: # @main
.cfi_startproc
# %bb.0:
pushq %rax
.cfi_def_cfa_offset 16
movl b(%rip), %eax
addl $1, %eax
movl %eax, b(%rip)
xorl %edx, %edx
andb $8, %al
movl $7, %ecx
cmovnel %edx, %ecx
# kill: def $cl killed $cl killed $ecx
shlb %cl, %al
movsbl %al, %eax
imull $1355350016, %eax, %eax # imm = 0x50C90000
cmpl $65536, %eax # imm = 0x10000
jne .LBB0_2
# %bb.1:
callq foo
.LBB0_2:
xorl %eax, %eax
popq %rcx
.cfi_def_cfa_offset 8
retq
.Lfunc_end0
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>
3729a5abf41d992535508e55c5d975f98c54dba0)
Target: x86_64-unknown-linux-gnu
Thread model: posix
This was introduced by
<a href="https://github.com/llvm/llvm-project/commit/1f3e35b6d165715ec7bf7ba80d5b982719c7752a">https://github.com/llvm/llvm-project/commit/1f3e35b6d165715ec7bf7ba80d5b982719c7752a</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>