[llvm] [RegisterCoalescer]: Try inflated RC for coalescing (PR #130870)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 3 20:22:40 PDT 2025


================
@@ -509,19 +535,41 @@ bool CoalescerPair::setRegisters(const MachineInstr *MI) {
 
       NewRC = TRI.getCommonSuperRegClass(SrcRC, SrcSub, DstRC, DstSub, SrcIdx,
                                          DstIdx);
-      if (!NewRC)
-        return false;
+      if (!NewRC) {
+        auto SuperDstRC = getLargestLegalRegClass(Dst, MF, MRI);
+        if (SuperDstRC != DstRC)
+          NewRC = TRI.getCommonSuperRegClass(SrcRC, SrcSub, SuperDstRC, DstSub,
+                                             SrcIdx, DstIdx);
+        if (!NewRC)
+          return false;
+      }
     } else if (DstSub) {
       // SrcReg will be merged with a sub-register of DstReg.
       SrcIdx = DstSub;
       NewRC = TRI.getMatchingSuperRegClass(DstRC, SrcRC, DstSub);
+      if (!NewRC) {
+        auto SuperDstRC = getLargestLegalRegClass(Dst, MF, MRI);
+        if (SuperDstRC != DstRC)
+          NewRC = TRI.getMatchingSuperRegClass(SuperDstRC, SrcRC, DstSub);
+      }
----------------
arsenm wrote:

I think we should handle each of these cases in a separate patch, starting with this subregister insert case 

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


More information about the llvm-commits mailing list