[llvm] [AMDGPU] Fix v_mov_b16 pair merging when the second mov reads the first (PR #227502)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 30 12:55:09 PDT 2026


================
@@ -156,14 +156,17 @@ bool SIPostRA16BitMovFolding::mergeSingleMovB16Pair(MachineInstr &Lo,
   MCRegister FirstDst16 = IsHiFirst ? HiDst : LoDst;
   MCRegister SecondSrc16 = IsHiFirst ? LoSrc16 : HiSrc16;
   MCRegister SecondDst16 = IsHiFirst ? LoDst : HiDst;
+
+  if (SecondSrc16 && TRI->regsOverlap(SecondSrc16, FirstDst16))
+    return false;
+
   for (MachineInstr &Scan :
        drop_begin(make_range(FirstMI.getIterator(), SecondMI.getIterator()))) {
     if (Scan.isDebugInstr())
       continue;
-    if (Scan.modifiesRegister(Dst32, TRI))
+    if (Scan.modifiesRegister(Dst32, TRI) ||
+        Scan.modifiesRegister(AMDGPU::EXEC, TRI))
----------------
jayfoad wrote:

Please don't do this, and please don't lump it into the same PR as the other change.

https://github.com/llvm/llvm-project/pull/227502


More information about the llvm-commits mailing list