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

    <tr>
        <th>Summary</th>
        <td>
            Wrong code at -O3 on x86_64-linux_gnu (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>
    Clang at -O3 produces wrong code on the following test case. `opt-bisect-limit` suggests that the issue might be in `InstCombinePass`.

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

```console
% cat a.c
int printf(const char *, ...);
static int a, b;
char c;
int d(int e) {
  if (e < 8)
    return 0;
  return e < 8 + 32 ? 1 << (e - 68) : 48 & 1 << e;
}
int main() {
  b = 0;
  for (; b < 10; b++) {
    c = 0;
    for (; (char)(d(a) + a) + c < 7; c++)
 ;
  }
  a = 0;
  for (; a <= 32; a++)
    ;
 printf("%d\n", c);
}
%
% clang-tk -O0 a.c && ./a.out
7
% 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/eJy0VU2P5CYT_jXVl5ItDP489KE_5FfvYbWREinHFQbaZpeGFuCdSX59hNvjnpldjRRpI1k2Lp56eCiqKB6CHq1Se6iOUJ13fI6T8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