<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/113240>113240</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Compiler in infinite loop after 6fd229a
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dyung
</td>
</tr>
</table>
<pre>
One of our internal tests started to time out and when I looked into it, the test actually appears to be hitting an infinite loop in the compiler. I was able to bisect the cause back to commit 6fd229a655f521a9f58d40c671e5cab4ea3ea87b. Note that in #109215 it mentions ec78f0da0e9b1b8e2b2323e434ea742e272dd913 as a possible fix, but I tried that and the compiler still seems to be stuck in an infinite loop.
Consider the following code:
```c++
long b;
struct {
unsigned long a : 43;
} c;
void d() {
long e = b & b - 1, f = c.a = e;
c.a = 0;
volatile long g(~f & g);
}
```
If compiled with optimizations and the BMI attributes with a compiler that does not include 6fd229a655f521a9f58d40c671e5cab4ea3ea87b, the compilation succeeds quickly:
```
$ time ~/src/upstream/b9cae45b63bc9c44521cc28b4a381afec6181f54-linux/bin/clang -c -O2 -mbmi repro.cpp -o repro.o
real 0m0.046s
user 0m0.012s
sys 0m0.035s
```
However, the same compilation with a compiler built from ec78f0da0e9b1b8e2b2323e434ea742e272dd913 still seems to be stuck in an infinite loop somewhere:
```
$ time /home/dyung/src/upstream/ec78f0da0e9b1b8e2b2323e434ea742e272dd913-linux/bin/clang -c -O2 -mbmi repro.cpp -o repro.o
^C
real 5m6.955s
user 5m6.594s
sys 0m0.337s
```
Godbolt link: https://godbolt.org/z/7deanqrnn
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVc-So7gPfhrnokoKBA5w4DDT_ctv-7A7z-A_IvG2sRnbdKbnMM--ZUh6stkcZmurKCjJ0mf5-yQsYjRHR9Qz_pnx542Y08mHXr_P7riRXr_3XxyBH8DPAYxLFJywkCimCDGJkEhD8pDMS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