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

    <tr>
        <th>Summary</th>
        <td>
            [LoongArch] Miscompile with O2
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            miscompilation,
            backend:loongarch
      </td>
    </tr>

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

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

<pre>
    Reproducer:
```
int printf(const char *, ...);
int a;
long b = 1;
short c, d;
void e(short f) {
ab:
  d = f == b ?1: b % f;
  if (d)
    c = 0;
 for (; c <= 0; c++) {
    if (c)
      goto ab;
    a++;
 }
}
void g() {
  short h = 15;
  for (; h; --h) {
 e(h);
    e(11);
  }
}
int main() {
  g();
 printf("%d\n", a);
}
```
```
> gcc -O0 test.c && ./a.out
30
> clang -O3 test.c && ./a.out
29
```
llvm version: 8951b51402d17af1f97e5804f60c946e624650d6

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VNuOmzAQ_ZrhZRRkjzGBBx5yaZ5ardQ_MMaAW4Ij7GS7_frKhNx2pUoI7PGcM2cuWHlvu9GYCuQWiJqg__z9eAcikPtEnUPvpmoxJrVrPqqf5jS55qzNBGIDbA9sAzlbnnlrx4CnyY6hBSq0G31A3asJgTZAO0zTFKgEsX14q_tucGOHNYLYI78bfe-mgDqCm7vx4myDBqi4nrZAJcJ6OVT1XRxiM9O18R0Xkf3AQWziiiS2d0pE2yJQ0UR9iwVRz3D28GpdzKUAsZ3PdrfjqHA7P09KIsOVVb-wInYuOIxCnzzVwnC3wXq_1Pi2mPPuYvzXMNcy9NfSySfWJ7l9fK1W_Ss0FrF_bklUEo2cv1q_ionNOyo7fpWzKHyg7xMRZ4tkA3I3zstdzPrh-AjyOlWft-Ibdlrj6o1hMD6kGoFyoBxToINK3TlcHcUTQA9q7HD1Jv4PufXpU8hhuBzxYiZv3RjHpyglryXPGDV8rVrelmsjC5a1OdNllpucslyyJr-ik6YSTSlKlZiKrwXLCp6VedJX3GQiK7g0vK65zFtVszYvqVVC5HUtssRWxCjjnHG-5gWXKZOCcSNboQTPS9NCxsxR2SGNClM3dYn1_mwqzjO5LpJB1Wbwyw9-tF6748kOKsQ05gYAUa30bzM2IDaDc2OnJt0vd8BURdZVfe48ZGywPvhHnGDDMF8d3yNqE1Fyjz9uMQy-29DjGyXnaaj6EE4-_pd0ADp0NvTnOtXuCHSIhMtndZrcL6MD0GHOwgMdlkQuFf0LAAD___oAOGY">