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

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 15 01:53:20 PDT 2024


================
@@ -271,9 +369,38 @@ X86RegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
 
     getInstrPartialMappingIdxs(MI, MRI, /* isFP= */ isFPTrunc || isFPAnyExt,
                                OpRegBankIdx);
-  } break;
+    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;
----------------
arsenm wrote:

Can just directly assign IsFP to this, don't need the if 

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


More information about the llvm-commits mailing list