<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/69097>69097</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Wrong code at -O2 on x86_64-linux_gnu since ca18e21
</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 -O2 produced the wrong code.
Bisected to ca18e21951a89f3115694fc64cd64a4b06cd5873, which was committed by @nikic
Compiler explorer: https://godbolt.org/z/5Kvbqqjqd
```console
% cat a.c
int printf(const char *, ...);
int a = -6, b, c, e, f;
static unsigned char d;
short g;
static unsigned char *h = &d;
int *i = &b;
int j(int k) { return k << 2 & a; }
int main() {
unsigned char **l[2];
l[f] = &h;
g = 4;
for (; g != -15; g--) {
*i = 0;
c = 2;
for (; j(10) - 40 + c >= -1; --c)
;
}
for (; c + *h + e != -1; ++e)
;
printf("%d\n", e);
}
%
% clang -O0 a.c && ./a.out
1
% clang -O2 a.c && ./a.out
(Timeout)
%
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VEGvozgM_jXmYoESh1A4cCjt9rKHuay0x1EIAfIeJX0Qpm_2169CX0s7I41UhWJ__vxhO1bzbLvRmBJkBfIYqcX3birnXrm4X1Q82Kh2zc_yMKixQ-Ux_kZ4mVyzaNOg7w1eJzd2qF1jEmBHYPvbWdnZaB8wDrXiuSFeSK7yohWcy6xIW52luslSldYs043MdwLogNfe6h6vakbtzmfrA0X9EyFlo323Gp9zHNz5Ygczofm8DG4yE4g99t5fZhB7oBPQqXNN7QafuKkDOv0HdJJ__6g_Pt4-mmcmyNjtp904u8F8WUmiVh5Vom8GO3q8THb0LVAeoB51ryYE2gftSZIAFSCqDa0QxBHjLLjrcOhwmHC0D-Dslbcal3HtRXPjbDZ37yaP3Z_hQPt-zQWUNS8SgPb27qlfPG9AeXi-AxUIuwon45dpxHcEcQBxQAoxqEBUCLvjFnhWdgTKv8JudvxdENB-AFkRyOMjLwZLC_J4l9RvLuxWY_pkaV1gyoOCDoH4Wk0u1_c4_kUAbt_KnjgQ9WqjF9sTc6gDZ4EsxpQhULVG_HVLFhBxrENnH8GIT1yP0ryQ6pXn1haq0Gzq13JSBVSZF9InyseQARGQbEAexvXvOjvbiD1SA8mnmV0va_yNhckNNQ5dTIBOKnGLv-H473D6Axwo_8eeTXi_S95S3i9P1JSiKUShIlPyrNiJjMtdHvWlMSojLlKhjGpTxXjO0tbsmOR5k6mMR7YkRoIzLlnBC5EnWSrynSlELWXLUpKQMnNWdkiG4cc53ObIzvNiyqxgxS4aVG2Ged1hRKO54uoMBZPHaCpDTFwv3QwpG-zs543FWz-Y8t_HDruvODfiZ559z9J4sOPy-b0bF5ztqM19mUXLNJS_7Brr-6VOtDsDnUKGr0d8mdyb0R7otOqagU6r7v8DAAD__xyOeOs">