<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/58401>58401</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Wrong code at -O3 on x86_64-linux_gnu (InstCombinePass)
</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>
```console
% clang-tk -v
clang version 16.0.0 (https://github.com/llvm/llvm-project.git 4e2dfd3589bd8eae6acd5a3aa895199cedd7efc9)
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/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
%
% clang-tk -w -O0 a.c && ./a.out
1
% clang-tk -w -O2 a.c && ./a.out
11
% clang-tk -w -Os a.c && ./a.out
11
% cat a.c
void printf();
short a, b;
int c, f;
long d;
static long e[] = {4073709551615, 4073709551615};
int g[];
long *h = &d;
void i(long *p) {
}
int main() {
*h = 10;
j:
a = 3;
for (; a; a--) {
f = 0;
for (; f <= 3; f++)
if (e[1]) {
b = 3;
for (; b; b--) {
int *k = &c;
if (d) {
i(e);
*k |= 0 <= g;
} else {
*k = 10;
goto j;
}
}
}
}
printf("%d\n", c);
}
%
```
Compiler explorer: https://godbolt.org/z/rzxhe19a4
`opt-bisect-limit` suggested that the bug may be in `InstCombinePass`.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVVmPmzoU_jXwYoFsEyA88NBJNFf3qVdqpT5W3gKecXCEzUzaX99jlpCkadUrFbGe5TsLx5-5ld_qqMDTKWznrFER3kf4Q0RzJAzrmsS_ouRtEo4C9KZ6p22HS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