[PATCH] D100406: [AMDGPU] Factor out SelectSAddrFI()

Stanislav Mekhanoshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 13 12:36:20 PDT 2021


rampitec created this revision.
rampitec added reviewers: arsenm, sebastian-ne.
Herald added subscribers: kerbowa, hiraditya, t-tye, tpr, dstuttard, yaxunl, nhaehnle, jvesely, kzhuravl.
rampitec requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.

This is a service function generally useful for selection
of a FI in an SADDR. NFC for now, needed for future patch.


https://reviews.llvm.org/D100406

Files:
  llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp


Index: llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
@@ -1858,6 +1858,24 @@
   return true;
 }
 
+static SDValue SelectSAddrFI(SelectionDAG *CurDAG, SDValue SAddr) {
+  if (auto FI = dyn_cast<FrameIndexSDNode>(SAddr)) {
+    SAddr = CurDAG->getTargetFrameIndex(FI->getIndex(), FI->getValueType(0));
+  } else if (SAddr.getOpcode() == ISD::ADD &&
+             isa<FrameIndexSDNode>(SAddr.getOperand(0))) {
+    // Materialize this into a scalar move for scalar address to avoid
+    // readfirstlane.
+    auto FI = cast<FrameIndexSDNode>(SAddr.getOperand(0));
+    SDValue TFI = CurDAG->getTargetFrameIndex(FI->getIndex(),
+                                              FI->getValueType(0));
+    SAddr = SDValue(CurDAG->getMachineNode(AMDGPU::S_ADD_U32, SDLoc(SAddr),
+                                           MVT::i32, TFI, SAddr.getOperand(1)),
+                    0);
+  }
+
+  return SAddr;
+}
+
 // Match (32-bit SGPR base) + sext(imm offset)
 bool AMDGPUDAGToDAGISel::SelectScratchSAddr(SDNode *N,
                                             SDValue Addr,
@@ -1874,19 +1892,7 @@
     SAddr = Addr.getOperand(0);
   }
 
-  if (auto FI = dyn_cast<FrameIndexSDNode>(SAddr)) {
-    SAddr = CurDAG->getTargetFrameIndex(FI->getIndex(), FI->getValueType(0));
-  } else if (SAddr.getOpcode() == ISD::ADD &&
-             isa<FrameIndexSDNode>(SAddr.getOperand(0))) {
-    // Materialize this into a scalar move for scalar address to avoid
-    // readfirstlane.
-    auto FI = cast<FrameIndexSDNode>(SAddr.getOperand(0));
-    SDValue TFI = CurDAG->getTargetFrameIndex(FI->getIndex(),
-                                              FI->getValueType(0));
-    SAddr = SDValue(CurDAG->getMachineNode(AMDGPU::S_ADD_U32, SDLoc(SAddr),
-                                           MVT::i32, TFI, SAddr.getOperand(1)),
-                    0);
-  }
+  SAddr = SelectSAddrFI(CurDAG, SAddr);
 
   const SIInstrInfo *TII = Subtarget->getInstrInfo();
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100406.337234.patch
Type: text/x-patch
Size: 2114 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210413/1167fcc7/attachment-0001.bin>


More information about the llvm-commits mailing list