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

    <tr>
        <th>Summary</th>
        <td>
            Wrong code at -Os on x86_64-linux_gnu since 5dde9c1
        </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 -Os produced the wrong code.

Bisected to 5dde9c1286c9360cdc3aa07a1d69ff41f941e4f7, which was committed by @RKSimon 

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

```console
% cat a.c
int printf(const char *, ...);
static int a = -3, b;
static char c;
int d;
int e(int f, int g) {
  if (f - g < 10000)
    return f;
 return f + 1 % -f;
}
int main() {
  int *h[] = {&a, &a};
  for (; c <= 37; ++c) {
    int *i = &b;
    *i |= e(a, 8) + d;
  }
 printf("%d\n", b);
}
%
% clang -O0 a.c && ./a.out
-3
% clang -Os a.c && ./a.out
-1
%
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VMGuqzYQ_ZphMwKZMRhYsLhJlE0Xr2oXVVdPxhhwRewIm-a-fn1lyE3SVHpSFGPPmXOO7fFI781otW6hPEB5SuQaJre0fpIunVaZzibpXP-jPc7SjigDpt88XhfXr0r3GCaNt8XZEZXrdQbsBOxj_z8Yr1WIGIdl3-tG5VQL1XDBVK-4lKySeS-aYSjyoSlyXQwV0BFvk1ET3qRH5S4XEyJF9wOhYL_98ru5OIuvKkd3uZpZL6g_r7Nb9AL8A6cQrh74B9AZ6Dy6vnNzyNwyAp3_ATr39lcp3Z9D98oEgu0_5ax3s76vUolKBpSZ2heMDXhdjA0DUB2hAdUkFwT6iO6zLANqgB92tA8yGIUxSSLwE6Y8orp3wEahHqsR3_9npoHqOA4xPX6MQA1CdYcgmgGB6gFTHBH4EXPGGItW7nHERYd1sTg8eB8rCHTAHONe02cYqtNT_yKNBarfRW2IG5_22tk2GKMkZLS5jdXpqYeDiwdVAz-gii5jAq_iFOgAdFBv_A8Fs3OT6F7Y8B6pNp54QpvsbpIOLyeI-NjM8_KACKjsoTza7TNey8vVPTKAypda2J5B-o3FioiGgARmQGeZuTXsuJT_H-9_hs_fhb5KMelb3je8kYluc9FUORO8FMnUCl50ZZdXVZFTLcVQFVqppuCdkJ0smyIxLTHiOcspZ1SWIhNDXeqqqeuuH1SlCiiYvkgzZ_P89yW-jcR4v-pW1HWVJ7Ps9Oy3nkBk9Q23YDym8pQsbcxJu3X0ULDZ-OCfLMGEWbd_PHrCV8twFj9r8V0U6Wzs-vl9tCt6Y5X-ag7Juszt28s1YVq7TLkL0Dkq3If0uri_tApA582XBzpvvv8NAAD__3e3UP0">