[llvm] [X86][GISel] Add DU chain lookups for LOAD & STORE (PR #87453)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 12 07:09:23 PDT 2024


================
@@ -272,8 +370,34 @@ X86RegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
     getInstrPartialMappingIdxs(MI, MRI, /* isFP= */ isFPTrunc || isFPAnyExt,
                                OpRegBankIdx);
   } break;
+  case TargetOpcode::G_LOAD: {
+    bool IsFP = false;
+    // Check if that load feeds fp instructions.
+    // In that case, we want the default mapping to be on FPR
+    // instead of blind map every scalar to GPR.
+    if (any_of(MRI.use_nodbg_instructions(cast<GLoad>(MI).getDstReg()),
+               [&](const MachineInstr &UseMI) {
+                 // If we have at least one direct use in a FP instruction,
+                 // assume this was a floating point load in the IR. If it
+                 // was not, we would have had a bitcast before reaching
+                 // that instruction.
+                 return onlyUsesFP(UseMI, MRI, TRI);
+               }))
+      IsFP = true;
+    getInstrPartialMappingIdxs(MI, MRI, IsFP, OpRegBankIdx);
+  } break;
+  case TargetOpcode::G_STORE: {
+    // Check if that store is fed by fp instructions.
+    Register VReg = cast<GStore>(MI).getValueReg();
+    if (!VReg)
+      break;
+    MachineInstr *DefMI = MRI.getVRegDef(VReg);
+    bool IsFP = onlyDefinesFP(*DefMI, MRI, TRI);
+    getInstrPartialMappingIdxs(MI, MRI, IsFP, OpRegBankIdx);
+  } break;
----------------
arsenm wrote:

Ditto 

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


More information about the llvm-commits mailing list