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

    <tr>
        <th>Summary</th>
        <td>
            Wrong code at -O1 on x86_64-linux_gnu
        </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>
    ```console
% clang-tk -v
clang version 16.0.0 (https://github.com/llvm/llvm-project.git 8f19de848b968bfdd237bdb6ffb65e7412bb6a0c)
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/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
%
% clang-tk -w -O0 a.c && ./a.out
1
-1
% clang-tk -w -O1 a.c && ./a.out
1
0
%
% cat a.c
int printf(const char *format, ...);
static short d;
long e;
long *g = &e;
int h;
int i(int j) {
  int c = 1;
  for (;; c++)
    if (1 << c >= j)
      return c;
}

void l(int j) {
  int m, o = (j + 83)%12;
  h = -o + 9;
  unsigned n = h;
  m = n >= 32 ? 1 : 1 >> n;
  if (m)
    *g = j;
  short *a = &d, *b = &a;
  b || 0;
}
void p() {
  int q = i(d - 8);
  printf("%d\n", q);
  l(-q);
}
int main() {
  p();
  printf("%d\n", e);
}
%
```
Compiler explorer: https://godbolt.org/z/xqn3v7coM
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVUuP2zYQ_jXSZSCBoqzXQYddOy56KHpogR4DSqQsOjTppSjvtr--Q1p-ZbdpAgQgKGqe3wxnhp3hf7dRSc6rN3oySkRkE5GniBbQK6Z3ifsCyelMD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