<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/65110>65110</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Wrong code at -O2/3/s on x86_64 (latend regression since Clang-14)
</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 trunk at -O2/3/s produce the wrong code.
Bisected to 8fce94f91610bc4614b1fe0bff8f143ea2b54742, which was committed by @rotateright
Compiler explorer: https://godbolt.org/z/PP4ff1vcx
```console
% cat a.c
int printf(const char *, ...);
int a, b, c;
int d(unsigned e) {
for (;;)
if (e >= 2)
;
else
return 1;
}
void f(long e) { d(e); }
int main() {
for (; b <= 1; b++) {
int g[2];
for (; c < 2; c++)
g[c] = 1;
f(g[0]);
}
printf("%d\n", a);
}
%
% clang-8fce94f -O0 a.c && ./a.out
0
% clang-8fce94f -O2 a.c
% ./a.out
(Timeout)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0VEGP6ygM_jXOxWoEJkmTQw7TdnN977DSHleEkIRdGiogM_P2169IO21nnkaKCNjm8_dhgwzBTIvWLZQHKE-ZXOPsfBtm6XbzKnfWZL0bfrXKymXC6NflX5QRdz8IqBNAXcCLd8OqNMZZ45t3y4TKDToHdgL2ch0PJmgV9YDRYT0q3RRjwyvOelVUvOj5qFk_jvXIC6El9WWxLwjoiG-zUTO-yYDKnc8mJoj-F0LBvIsyam-mOeJzpqM7X4zVHvX7xTqvPYgXnGO8BBAvQB1QN7mhdzbmzk9A3X9A3c-fxTjyV_X-jAQVu37KLcFZfbNSiUpGlLm6GswS8eLNEkegOoVGVLP0CPSSFOR5DtSAODyiZbL3aVCf7ANQvS5bOQbUQA3C_uZGHF2CrNMGcUiINzuiGZNDI4g_QJyQPjkR7ynSQtugn51ex9UvyO9BsD9dJ6_ODJgk2VTQDzYbR30VhPfYRP4szZL4fccaewRxTAT5tgI6bN-ncMQENUF5IChPn5g_IamEhLRN7zDPqhKAgvKEH-luziQn-VgCfyoKPqTgo5ZABFQOUB6XbXpMhWt-Pymg8qk10jXZ3Vocdz9YahQEqoAqzIE6mbs1XuPZ99vo0V_J_WUjUP2nOeu0_hB-b9ZsaMXQiEZmuuVVI0RTE5XZ3Mo96_eCD1UxVsPAG8W4YKrkVc3qYmQyMy0xEqwWjBOJosj7iu_rvpKFHpr9uB-gYPosjc2tfT2n25OZEFbdViXnLLOy1zZszwjRot9wc6aTK0-Zb9OeXb9OAQpmTYjhgRJNtLr96_5yfH1f3ILvdfV3VaQGsDLqZUCvJ69DMG7BYBal8bidIC-Ammz1tv1y5U2c1z5X7gzUpcS33-7i3T9aRaBuoxuAuk3O_wEAAP__YGlijA">