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

    <tr>
        <th>Summary</th>
        <td>
            [RISCV] Miscompile with -O3
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            backend:RISC-V,
            miscompilation
      </td>
    </tr>

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

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

<pre>
    Reduced test case:
```
#include "csmith.h"
uint8_t a = 55;
int32_t b;
int32_t c[4];
uint32_t e[4];
void f() {
  int32_t *o = &c[1];
  *o = 223;
  if (safe_mod_func_uint8_t_u_u(safe_sub_func_uint8_t_u_u(b, 1), a |= *o)) {
 e[0] = ++a;
  }
}
int main() {
  b = 0;
  f();
 printf("%d\n", a);
  return 0;
}
```
```
> bin/clang -O0 --target=riscv64-linux-gnu test.c -I/usr/include/csmith -w
> qemu-riscv64 -L /usr/riscv64-linux-gnu/ a.out
255
> bin/clang -O3 --target=riscv64-linux-gnu test.c -I/usr/include/csmith -w
> qemu-riscv64 -L /usr/riscv64-linux-gnu/ a.out
224
```
llvm version: d6c4ebbf78c67cd298f6ba2da6c06e2362f4d0f4

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVMtu2zoQ_ZrRhpBBDSVKWmjhxxUQ4F4EyAWyNfiSzVYPVySdpF9fSJZjN0n3BQyQPMdzeIYzGuGcPfTGVJBtAFF79frz7QUQIdtFIvjjMFYLGMlBv1VPRgdlNPHGeaKEM8DWQHdA18Dp8rsckdletUEbAojKddYfV8dJeaaD7X2x90QQYDuSZcA2F8L2nuHeE_kJUZBtUsh270S4MuYjcx6sJg1gAVgSyBeUkGsA4HqYLwbkk2xyH0xuNCK7g21DAAsnGrPvBr1vQq_2Sx77sA9XzgX5FScBtyQBLKdVEMi3FwPrYcbufU75UMh2i8UN4Ebc28t3yxtfN7b3pBO2_5yxnDXoXfTyLDfkNNreX1AEzDRk237ebon47Y9kND6M_Z3azcmH4n84sn-InNzVqhX9gcSPlMSxF-PBeGC70Tp15mnc2j68xoc-zN21UiR-AKyDGwHrpZcmibmVSPxy0_5huhAvKiT-l7xHfVIGrIlYDcFfgjHL_uSQ_SUOMf3ySdv23JGzGZ0demBrorlKjZRNXiieK41l0XApUAuuKDfIODapps0iFumK6ZKVIjJVkicplknCaHSs8rwpGOeNyZOmzBlPEY1IeMOoQMF1HtkKKaY0xYLmWZHRlVIlF1JJzgomWSEgpaYTtl1NDlfDeIisc8FUJWUFjVohTeuWaSOF-m56DWz99PD_Nn6-NB0gdtapoTvZVvgpvcs0GqtJMZbh4CClrXXe3e7w1rfzEJuUnqdP57-rhiEvczUeWRTGtjp6f3LT0MIasD5YfwxypYYOsJ7UliU-jcM3o_xU18m-A6znDH4FAAD__ytEd1s">