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

    <tr>
        <th>Summary</th>
        <td>
            Wrong code at -O2 on x86_64-linux_gnu since Clang-15
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          shao-hua-li
      </td>
    </tr>
</table>

<pre>
    clang at -O2 produced the wrong code.

Bisected to b22ffc7b98f8700d7d480127ff1c3683a6dac6e5, which was committed by @aeubanks 

Compiler explorer: https://godbolt.org/z/MxrnaqTqc


```console
% cat a.c
int printf(const char *, ...);
int a;
static int b;
short(c)(short d, int e) { return d >> e; }
char *f(int d, char *e) {
  if ((d & 1) == 0)
    return e;
  switch (d) {
  case 7:
  case 49:
  case 1:
    return "";
  case 11:
    return "0";
  case 3:
 return "0";
  }
  return "1";
}
char g(int d) {
  char h = 0, i = *f(d, &h);
  return i;
}
char j(int d) {
  for (;;) {
 if (g(d + 7) + d)
      return 0;
    for (; b - 30; b+=0)
 ;
  }
}
void k() {
  int l = -8, m = c(l, 8);
 j(m);
}
int main() {
  k();
  printf("%X\n", a);
}

% clang -O0 a.c && ./a.out
0
% clang -O2 a.c && ./a.out
%
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VU-P46gT_TTlS8kWBv_BBx86yeT201x-0u5thAHHzDgmY_B0z376FSRxnJ7ulZADxatXxYOqCOfMadK6hXIH5SERix_s3LpB2HRYRDqapLPqdytHMZ1QeEy_UrzMVi1SK_SDxtfZTieUVukMyAHIy_W7M05LHzAWO0r7XtZdw3teE6JqVXCS07rvc8kqzkSlhKx0CXSPr4ORA74Kh9Kez8YHiu43QkGEXjox_XC4DbO354sZ9Yz67TLaWc_AXnDw_uKAvQA9Aj2erOrs6DM7n4Ae_wF6_N_bPImf__8pt0y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