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

    <tr>
        <th>Summary</th>
        <td>
            [AMDGPU] MachineCSE related issue
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            backend:AMDGPU
      </td>
    </tr>

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

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

<pre>
    Split from #60937 since this issue disappears if MachineCSE is disabled but the other issue does not.

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

Two more reproducers. This time I make them run into a trap that they should not run into (see picture).
<img width="641" alt="Screenshot 2023-03-13 at 6 52 59 PM" src="https://user-images.githubusercontent.com/6248191/224871832-2e014589-b353-40bc-8ad0-db7507a04793.png">

Modifying unrelated parts makes it run fine. I assume some reg-alloc or similar issue.
I included two different minimal modifications that make it run, as well as the suprisingly different assembly.
I think with the executable, and a dynamic library build of LLVM w/ OpenMP offload, one can even reproduce the issue on a GFX90a, see README.

@arsenm, @nhaehnle Can you please take a look?

_Originally posted by @jdoerfert in https://github.com/llvm/llvm-project/issues/60937#issuecomment-1467225247_

See also https://github.com/llvm/llvm-project/issues/60937#issuecomment-1468125715
 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VE2P2zYQ_TX0ZWCDIvV58GGzXgcBYiTopkVvwUgcScxSpEBScd1fX1D2Zr3HoujFAumZefMe5w2GoAdLtGfFB1YcNrjE0fn9D-XI9-TjpnXqsn-ejY7QezcBE7LkjawgaNsRxFEH0CEsBEoHnGdCH0D3cMJu1JYen59Ah_W_1pCCdokQRwIXR_KviY4CWBd3jB8Yf7j-wu1QfPA0e7eL6HfD36w4MFGPMc6ByQcmjkwcBx3Hpd11bmLiaMzP18929u4HdZGJY68NBSaOGW9KmYuGieO7qqK5h_52djA5T7DGqKUjH3bwLT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