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

    <tr>
        <th>Summary</th>
        <td>
            [clang] Miscompile at -Os
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    This code prints 9 at `-Os` and 0 at `-O0/1/2/3`:

```c
int printf(const char *, ...);
char a = 9, c, d;
int b, e;
unsigned short f;
char *g = &a;
void h(int i) {
  for (; b; b++)
    c &= 0 <= i;
}
static short j(unsigned long i) {
  int k;
  for (; e + d + 4 > 0;) {
    k = i + 49;
 h(k + i - 52 + i);
    *g = 0;
    return 0;
  }
  return 0;
}
int main() {
  j(6 < (unsigned short)(f - 7) + f);
  printf("%d\n", a);
}
```

Compiler Explorer: https://godbolt.org/z/Mo5TEKh8r

Bisected to https://github.com/llvm/llvm-project/commit/5287299f8809ae927a0acafb179c4b37ce9ff21d, which was committed by @RKSimon 
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVNGu2ygQ_ZrxyygRDHZsHvyQ5F6_VFWl3f4ABhzT65jIkNvtfv0KaHPTvq2ECBw4Z-ZM8KgQ3GW1tofmBM1Lpe5x9luv1WbcRa2csa4avfnRf51dQO2Nxdvm1hhQoooIB7b7EuDAUK0G2QNiQAMHGghoEHBgII7A8jiwMjSwo1tjUZuAOu3XEFHPakOgI9AZ9_s9kARxAnbMuEIQLyjTmU6TKWdJZkx7W_b3NXsyGGa_RZyeFICOlywCdFAFf_fO4AzUJRkHJBHahCNOPhE6ECccy0SnPGQ-RtRJJqkxBHFOC1c0oX0BdgxRRad_ZvENqHsktvj18nusFPytkH8LbBHohCbPNYJ4RZZuPTER37IjV-78rFd29JYhhztsqCwf9Uy8RzHYB7bZeN_WD6Q4-RMvaMr5qtyaUn1KKDk9pILgs-VchRSeugl32GYGnXB6SunxFoAIqDHQnNe8PKN6XCuxH--oPKuzv97cYjd8_ee2-M1uII44x3gL6eXRADRcvBn9Evd-uwAN_wINn33z9fXT3G1F4-SC1dEajP5PqovzfdxrfwUaluX918_utvlvVkegQfvr1aVFQ11LUk5dx6SyklrFlFbTyFup61G02sppIm6Sqe-z0zN-V-nDSvQUfPyBULO_Pv3trn7FyvTCSCFVZXveioaLhtWimns5tazjnOnOclO3LRcNSbIH0Y2jUdpUridGNSdKnJbEnkbbSGFFO3JqJK-hZvaq3LJPTlJVKhfC3facOOesWtRol_CrLWx99jveLwFqtrgQwwcvurjkBqIXtV6gecHPLujyj6SOsPsSqvu29P-7qDmhkFpJyem9p_8CAAD__xiNTJ8">