<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63645>63645</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Wrong code at -O3 on x86_64-linux_gnu (regression since clang-16)
</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>
For the following code, clang at -O3 produces wrong code. `opt-bisect-limit` suggests that the issue might be in `X86 DAG->DAG Instruction Selection on function (main)`.
Compiler explorer: https://godbolt.org/z/d7MsYac83
```console
% cat a.c
int c;
static int *d = &c;
static int **e = &d;
static int f = 564255563;
static int ***g = &e;
static unsigned j = 4294967295;
char *l;
static int *m = &f;
static int n;
long p;
int q(int r) { return r - 10 - 26 + 'a'; }
void s(int *r) {}
void t() {
int i = n = 0;
for (; n <= 1; n++) {
int a[2];
i = 0;
char h[] = {0, 0, 5, 0, 0, 4, 5, 0, 0, 8, 0, 0, 64};
char k = *(h + 12);
p = k;
for (; p + 126 + *m + j - 4859223048 + i < 2; i++)
a[q(48 + 4) + j + **e - 112 + i] = 50009;
if (0 == 42829 <= a[1])
*l = 0;
}
int ****b[] = {&g, &g};
}
int main() {
int *o = &c;
*o = 0;
t();
s(&f);
}
%
% clang-tk -O0 -fsanitize=address,undefined a.c && ./a.out
%
% clang-tk -O3 a.c && ./a.out
Segmentation fault
%
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VcGSozgPfhrloiJlBDhwyIF0_kz9h605zGF3T1MGDHjGsbPYTPfO02_ZJHQy3T1VlLFl6ZP8WbKEc2owUu6hOEBx3IjZj3bau1HYZJxFotWmsd2_-5Od0I8Se6u1fVZmwNZ2EugJWy3MgMJj8jnDy2S7uZUOnyd71dkicGYvPmmUk61PtDorD5yhm4dBOu_Qj8JHcOXcLPGshtFjI1GZYPpXyfFYf0og-9-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