<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=52260">52260</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 a;
static int *b = &a;
static int **c = &b;
static char e;
static unsigned d() {
if (c)
return a;
else
return 1;
}
int main() {
int f = d();
unsigned char g = f;
e = g >> 4;
if (e) {
for (;;) {
if (f)
break;
c = 0;
foo();
}
for (;;)
;
}
}
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:
testb $-16, a(%rip)
je .LBB0_2
.p2align 4, 0x90
.LBB0_1: # =>This Inner Loop Header: Depth=1
jmp .LBB0_1
.LBB0_2:
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
cmpq $0, c(%rip)
movl $1, %eax
je .LBB0_2
# %bb.1:
movl a(%rip), %eax
.LBB0_2:
cmpb $16, %al
jae .LBB0_3
# %bb.6:
xorl %eax, %eax
popq %rcx
.cfi_def_cfa_offset 8
retq
.LBB0_3:
.cfi_def_cfa_offset 16
testl %eax, %eax
je .LBB0_4
.p2align 4, 0x90
.LBB0_5: # =>This Inner Loop Header: Depth=1
jmp .LBB0_5
.p2align 4, 0x90
.LBB0_4: # =>This Inner Loop Header: Depth=1
movq $0, c(%rip)
callq foo
jmp .LBB0_4
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>
eda2ebd7807376829eb880c39623f364b438971f)
Target: x86_64-unknown-linux-gnu
Thread model: posix
<a href="https://github.com/llvm/llvm-project/commit/f32c0fe8e50534f4210d878b9a1420793860c567">https://github.com/llvm/llvm-project/commit/f32c0fe8e50534f4210d878b9a1420793860c567</a>
introduced this regression</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>