<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/71330>71330</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Wrong code at -O3 on x86_64-linux_gnu since 0289dad (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>
clang at -O3 produces the wrong code.
Bisected to 0289dad538fa2fdc1a82a26f5d19f94fbd20d949, which was committed by @goldsteinn
Compiler explorer: https://godbolt.org/z/dhWWer8Gx
```console
% cat a.c
int printf(const char *, ...);
char a, e = 5, g, k, l;
short b, n;
int m, o, p, s;
long c;
unsigned short(q)(short d) { return d + b; }
int r(int *f) {
if ((f[0] & 8) == 0)
return 0;
if ((f[0] & 12) == 0)
return 1;
if ((f[0] & 14) == 0)
return 2;
if (f[0] & 15)
return 3;
return 1;
}
int fn3(int h) {
int i[] = {h};
int j = r(i);
return j;
}
void t() {
int *u = &m;
for (; s;)
for (; p;)
;
m = -3;
for (; m <= -1; m = q(m)) {
for (; fn3(*u + 8) + e + 9 + c < 15; ++c) {
k++;
n = 0;
for (; e + n; ++n)
o = 5 ^ *u;
}
if (n)
l = a;
for (; g; g = a)
;
}
}
int main() {
t();
printf("%d\n", k);
}
%
% clang -O0 a.c && ./a.out
1
% clang -O3 a.c && ./a.out
0
%
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVc2SmzoTfZr2pssUtADDgoUZf_6WWWaZEkiAEpAcJDKT-_S3JDwebCd3pqZk6J9zWs2Rmlurei1lBVkN2WnHFzeYubIDN_th4ftR7RojflftyHWP3OH-C8PLbMTSSotukPg6G91ja4SMID5BfFzXWlnZOinQGYypKAUXGSs6Tp1oE14Qp7zLRFJ2Zdo1gmJRpiXQC74Oqh3wlVtszTQp5yGa3whp3JtRWCeV1rglejHTR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