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

    <tr>
        <th>Summary</th>
        <td>
            AMDGPU backend miscompiles (or exposes miscompilation)
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    I tracked down a OpenMP GPU reduction bug on AMD to the backend, or at least I think so.

Here is what I know:
If I run with upstream: `llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx90a --filetype=obj pre.O3.ll -o pre.O3.o` and then use that object in to run the reproducer of #59759, I get an error every few runs.
If I run with ROCM 5.4.1: `llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx90a --filetype=obj pre.O3.ll -o pre.O3.amdllconly.o` and then use that object in to run the reproducer of #59759, it runs fine a thousand times.
Note that the input, `pre.O3.ll` is the same for both. Everything else, host code, gpu loader, etc. are the same too.

I attached the input and the amdgcn files I got (in assembly format) to this issue.
The error happens in the `__omp_offloading_16_688e4c6__ZN11qmcplusplus7ompBLAS17gemv_batched_implIdEEiRiciiPKT_PKS5_iS7_iS5_PKPS3_ii_l153` kernel. 

At this point I'm not super sure how to proceed. If we have a good way of disabling options in llc we could maybe narrow it down further. Or maybe it's obvious (to someone else, looking @arsenm) by reading over the amdgcn diff.

Tag: @ye-luo, @ronlieb 

[repro.tar.gz](https://github.com/llvm/llvm-project/files/10419019/repro.tar.gz)


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VcFu4zYQ_Rr6MrAgUZJtHXzwrtetsc3G2KSXXgRKGklMSA5LUva6X19QcTYJ0EuB9kAJBDnD9948DoX3cjCIW1Z-YpwL59Foxjkr9wsxhZHc9qkjdD26sGiou26PEJxon7GDji4GBNxbNHcn-OX0OzjspjZIM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