<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63996>63996</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Wrong code at -O1 on x86_64-linux_gnu (recent regression)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
shao-hua-li
</td>
</tr>
</table>
<pre>
This looks like a recent regression. Clang at -O1 produced the wrong code. `opt-bisect-limit` suggests that the issue might be in `Early Tail Duplication on function (main)`
Compiler explorer: https://godbolt.org/z/48dhr18To
```console
% cat a.c
int printf(const char *, ...);
unsigned a, b, n;
int g, h, j, i, s, t, o;
long k, f, p, u;
short l;
char e, m, v;
static long *q = &p;
int *r;
short(w)(int x) { return a > x ? a : a << x; }
void y(char x) { h = x; }
long *z() {
*q = 82442021152321478;
for (; n;)
for (; o + i; e++) {
int c;
if (w(r && v & (e <= t))) {
long d;
for (; e;)
return &f;
b = 0;
if (u)
break;
p = 0;
}
}
return &k;
}
int main() {
j = 5;
for (; j; j--) {
z();
for (; b;)
m = l &= m;
if (g)
r = &s;
else
*q &= 4294967295;
}
y(p >> 56);
printf("%X\n", h);
}
%
% clang-tk -O0 a.c && ./a.out
0
% clang-tk -O1 a.c && ./a.out
1
% clang-tk -v
clang version 17.0.0 (https://github.com/llvm/llvm-project.git 46333f71f8e0d6444a9b2c9e063aedb83ebb9735)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /zdata/shaoli/compilers/ccbuilder-compilers
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Candidate multilib: .;@m64
Selected multilib: .;@m64
%
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email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