<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63764>63764</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Wrong code at -O3 on x86_64-linux_gnu (latent issue in DSEPass since clang-9)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
shao-hua-li
</td>
</tr>
</table>
<pre>
This looks like a long latent issue since clang-9. Clang at -O3 produces wrong code on the following code. `opt-bisect-limit` suggests that the issue might be in `DSEPass`.
Compiler explorer: https://godbolt.org/z/YqG6YMefq
```console
% cat a.c
int printf(const char *, ...);
long a;
char b;
int c, e;
int *d = &c;
static int f;
int main() {
{
int g = e = f = 1;
for (; f >= 0; f--) {
char h[4];
for (; g < 4; g++)
h[e - 1 + g] = 5;
a = 0;
for (; a <= 0; a++) {
char *i = &b;
for (; g < 7; g++)
;
*i = *d = h[3];
}
}
}
printf("%d\n", b);
}
%
% clang-tk -O0 a.c && ./a.out
5
% clang-tk -O3 a.c && ./a.out
0
%
% clang-tk -v
clang version 17.0.0 (https://github.com/llvm/llvm-project.git 99074aafc31593c9935da483edab1333d6ce5a5b)
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/10
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
%
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VU2P2zgP_jXMhbChSP6IDzlkkrp4Dy-6QAsseipkSbG1o0ipJXdm99cvpDhOZjo7wAJdI1Aoinz4IYrk3uveKrWF8gHKw4pPYXDj1g_cZcPEM6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