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

    <tr>
        <th>Summary</th>
        <td>
            [clang-15] wrong code at -O1 about -inline
        </td>
    </tr>

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

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

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

<pre>
    Hi,
I found clang-15 produce wrong code at -O1 on this test case:

```c
#include <stdint.h>
#include <stdio.h>
int8_t a = 0;
uint64_t c = 0;
int8_t d[3] = {0, 0, 0};
uint32_t o(uint32_t p, uint32_t q) { 
  return (q == 0)? (p) : (p % q); 
}
int main() {
  int8_t *g = &a;
  int8_t *i = &d[1];
 int32_t j = (g == i);
  printf("%d\n", j);
  int32_t l = 1;
 uint64_t *n = &c;
  *n = o(10, (uint8_t)(l | j));
  printf("%llu\n", c);
}
```

Use -fno-inline-functions can produce correct code.

```console
$ clang-15 -v
Ubuntu clang version 15.0.7
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-15/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.3.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$ clang-15 -target i386-linux -O1 small.c -o small
$ ./small
0
1
$ clang-15 -target i386-linux -O1 -fno-inline-functions small.c -o small
$ ./small
0
0
```
</pre>
<img width="1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