[llvm] [AMDGPU] Rematerialize scalar loads (PR #68778)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 23 22:22:47 PDT 2023


================
@@ -108,7 +108,18 @@ static bool nodesHaveSameOperandValue(SDNode *N0, SDNode* N1, unsigned OpName) {
 
 bool SIInstrInfo::isReallyTriviallyReMaterializable(
     const MachineInstr &MI) const {
+
+  bool CanRemat = false;
   if (isVOP1(MI) || isVOP2(MI) || isVOP3(MI) || isSDWA(MI) || isSALU(MI)) {
+    CanRemat = true;
+  } else if (isSMRD(MI)) {
+    CanRemat = !MI.memoperands_empty() &&
+               llvm::all_of(MI.memoperands(), [](const MachineMemOperand *MMO) {
+                 return MMO->isLoad() && MMO->isInvariant();
+               });
+  }
+
+  if (CanRemat) {
----------------
arsenm wrote:

can you just split this into a helper function with early return?

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


More information about the llvm-commits mailing list