<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/149644>149644</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [AArch64] Bad machine code: Virtual register killed in block, but needed live out
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          sjoerdmeijer
      </td>
    </tr>
</table>

<pre>
    A build with expensive checks enabled, and with this input:

```
#include <algorithm>
bool a;
extern int h[];
extern char b[];
void i(int c[][7][7]) {
  for (short d = 0; d < 17; d += 3)
 for (int e = 0; e < 17; e += 2) {
      for (short f = 1; f < 014; f += 3) {
        h[e] |= 9;
        a = std::max(a, bool(c[d][f][2]));
      }
 for (; short(c[1][1][1]);)
        for (int g = 0; g < 7; g += 4)
 b[d] = 0;
    }
}
```

runs into this errors like these:

```
*** Bad machine code: Virtual register killed in block, but needed live out. ***
- function:    _Z4testiyixxstjbhiPA18_sPtPA18_A18_j
- basic block: %bb.6 for.body34.us.us (0xaaaab39738a0)
Virtual register %35 is used after the block.

*** Bad machine code: Virtual register killed in block, but needed live out. ***
- function:    _Z4testiyixxstjbhiPA18_sPtPA18_A18_j
- basic block: %bb.6 for.body34.us.us (0xaaaab39738a0)
Virtual register %37 is used after the block.

*** Bad machine code: Virtual register killed in block, but needed live out. ***
- function: _Z4testiyixxstjbhiPA18_sPtPA18_A18_j
- basic block: %bb.6 for.body34.us.us (0xaaaab39738a0)
Virtual register %39 is used after the block.
```

See also https://godbolt.org/z/665x9eqr4.


This could be related to https://github.com/llvm/llvm-project/issues/149585, but I am raising this separately because the error is different, i.e. this is speaking about live-outs.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzklUuv4yYUxz8N3hyNhfF74YVzbyN1N1KrLroZgTm2SYhJedzJ7aevsJ25iUbtppVaqREJjuF_Hj_gwJ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