<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63727>63727</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Wrong code at -O3 on x86_64-linux_gnu (a recent regression)
</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 recent regression. Clang trunk at -O3 emits wrong code. `opt-bisect-limit` suggests that the issue might be in `GVNPass`.
Compiler explorer: https://godbolt.org/z/b6Mdvq453
```console
% cat a.c
int printf(const char *, ...);
int a, b, c, d;
long e;
int f(int g) {
if (g < 68)
return 0;
return g < 768 ? 5 & 1 << (g - 68) : 1 << (g - 2);
}
int main() {
for (; d < 2; d++)
c = 1;
a = 1;
for (; a <= 9; a++)
;
for (;;) {
for (; f(a) + b - 30 + e; ++e)
;
if (c)
break;
}
printf("%d\n", (int)e);
}
%
% clang-tk -O0 a.c && ./a.out
30
% 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/eJy0Vd-P4yYQ_mvIy8gWhvjXgx92E_nUh_Yq9dQ-njBMbBoCKeC9bf_6CjubZKPVSZWuioXJMHzz-WOGESHo0SJ2pHwm5X4j5jg534VJuGyaRWb0ZnDq7-7Lp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