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

    <tr>
        <th>Summary</th>
        <td>
            [clang] Miscompile at O3 with SIGKILL
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    When I compiled this code with -O3, it triggered SIGKILL. With -O0/1/2, it returned 0.

Bisected to https://github.com/llvm/llvm-project/commit/254da5ab8bce846bcbac9862f31c1891d8feea44, which was committed by @RKSimon 

Compiler Explorer: https://godbolt.org/z/oE87zTxGf

Code:
```c
int printf(const char *, ...);
int a, b, c, e, f;
long k, l;
void m(int n) {
  b = 1;
  for (; b <= n; b++)
    for (; c; c++)
      ;
}
long o(long n) {
  long g = 0, i = 1, j = n;
  char h = 0;
  while (j > 0) {
    char d = j & i;
    if (d)
      g += i << h;
    j >>= 1;
    h++;
  }
  g *= h % 2 == 0 ? 2 : 3;
  return g;
}
long p(unsigned short n) {
  for (; e;)
    if (f)
 return 0;
  return n;
}
int main() {
  k = o(207 + 122);
  l = p((char)k);
  m(l);
  printf("%X\n", a);
}
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVE1v2zgQ_TWjy6AGOZQs6qCDY8dF0C4KbBfoXimKkpjIoiHRSdtfvyCl-CPGHgoIFDl8b-bNkBw1TbYdjCkhe4Bsl6iT79xYajXWtlUDZ0wmlat_lT86M-ATanc42t7U6Ds7oXa1wTfrO_z0TQBt0Xr0o21bM5oavz99_vL09esKf8wIBrTnQHtakKPxp3EwNbIVsB2wzTw-2MloH0I47Lw_TiA2QHugfWt9d6pW2h2A9n3_-v77dBzds9EeaK_d4WDDhLK0VpmqZKWNTNeVrpQu5JoawTWXBa9lY4xK06DlrbO6wzcVEgr0ELz6hZCyv798twc34LW-7VyCER9_Hns3mhHE5qNQV1eu9ys3tkD730B79yjz3__8_NzceqpN4MymNZs_Pa_t4PE42sE3QFK7YfKoOzUi0CZoXq1WQAWIhwtaBXsVBh0GE4bmjOjd0OJLsPVn26uzNR6AZKAPQAVCvmwhVghih_wMRmxcCC9BPMTNbdgf4groIX7FO_QGrOfhHoN49g757kqnA5Jx8lFUNLZRGYvXaBFJW3zGdz3v4FivbgFfzG-d7U3QFhiPwc9NiIVXR94zAq3RXrERbRPI9YdMWgzZiV2UtAWxxe6GFYPF77aoiN1SmYvtXIzZ7SZwOgTKkIKqmBCC2MflBsUVdX5U2P5PYY9A8jTEN1_j1Lnx_tyvDs4EL9dpzqk3F9sSjt0rGO4VhFt2UHYI3m9jvsRih1MnlodCIie6vt-IfYQcI1eGEwIqXm4h4Sb3t6bzC4LgL_sXsu0Qp9vwXIp7jednOC-TuhR1IQqVmJLngucZp3WedCUZqYpCF-uc5ULwSmqjsyrNc0lcpoYntiRGKed8zRnjLF-ZPK1kpRQrVNo0RJAyc1C2X4UWFlpFYqfpZErO16kUSa8q00-xLxPpXg1t0J3tkrGMPa86tROkrLeTny4uvPV9bOYzI9vhX3ZamjYqj9_E3K-X3pycxr784yYbdU6hm89SX0v6LwAA__89n6sZ">