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

    <tr>
        <th>Summary</th>
        <td>
            [Flang][OpenMP] Internal Compiler Error with atomic update
        </td>
    </tr>

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

    <tr>
      <th>Assignees</th>
      <td>
            shraiysh,
            NimishMishra
      </td>
    </tr>

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

<pre>
    The OpenMP atomic update codegen in Flang inserts the load/creation of the value with which to update also into the atomic region. This triggers an ICE in the translation from OpenMP+LLVM MLIR dialect to LLVM IR. The translation expects only two operations in the atomic update region:
1. The update operation
2. The yield
I guess the strong requirement is due to the conversion of the update operation to an atomicrmw instruction is possible. So the update operation has to be identifiable.

Flang patch : https://reviews.llvm.org/D125668
MLIR patch : https://reviews.llvm.org/D119657

**Reproducer**

```
subroutine test()
        real :: x
        real :: y
        x = 20
 y = 10
        !$OMP ATOMIC
        y = x + y
end subroutine test
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVE1v4zYQ_TXUZbCGRH1ZBx2SeA0YiJtFGvROU2NxWopUSSqO_31BSdmuFu1hDcIG572Z9zxDUnhPvUFsWfnIOPfKCbp7xThn_Ilx_hsN5NWZIhCD5SERU1DWtX-RE0YqYTonBquESS62u7dvCuFlRHP-BiLYgSRMYycCgrQd9miADBy1MD2Q8eiCh6AQtBUd40fpUASyBux1Dr8LPSHcKCi4KZIKgv0sJ7S3QCbYmbhKOezJmh28KfIQHPU9Og_CwOnpaxSO1OCE8XqRuTo7rG4Zf3x-_uMM5-fTK3QkNMoQ5ebg6TXW3Obix4gyeLBG3yHcLNgR3Qz5T6ltAxZzLH9g6YGlD9lScgW_Jy8gX8A7oe6WyAn6Cf3SLR-cNT04_HsihwOaAOShmxDWdkhr3tH5Hzr5s0xkCrM6dMMtTiO4Sc4YeRit93TRuIPf7X8XUMLHIhcE6tAEupKI_MXt8r3MeRRBKmD5A6gQRh8bwI-MHx2-E978Tuv3YWddz_jxkPGyqvZL9jyJX0rOmqqsfzTAeFyvODrbTRLdst8wqnRd89ZPF2enQAYhoA-M7xlvFgjWj0Oho6Ho6eP_ofsW-gCWH4CvMnCft1m6JTGeMV68nL_Bw9vL-fS0RZecD2D88bM6mg5-trz9W0nX5l2TNyLBNqvqutqnTVEkqu2wlnVR1LXkey6qMitk3WHeXbG5Sp7xhFqe8jzN0ywreJMWO5HWTSUrmadZI_eXnBUpDoL09xkk5P2EbZWl-ybR4oLaz89KeUhcG0lfLlPvWZFq8uHf0SWBgp4foPm8sPLAysf1UpYHOJmAzggNT3YYSaODr85Zt7wKmxuWTE6322PSU1DTZSftwPgxCq4_X0Zn_0QZGD_Opj3jx9n3PwEAAP__D4OaBw">