[llvm] [AMDGPU] Folding imm offset in more cases for scratch access (PR #70634)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 9 03:33:03 PST 2023


================
@@ -1146,13 +1146,61 @@ bool AMDGPUDAGToDAGISel::isDSOffset2Legal(SDValue Base, unsigned Offset0,
   return CurDAG->SignBitIsZero(Base);
 }
 
-bool AMDGPUDAGToDAGISel::isFlatScratchBaseLegal(SDValue Base,
+// Check that the address value of flat scratch load/store being put into
+// SGPR/VGPR is legal with respect to hardware's requirement that address in
+// SGPR/VGPR should be unsigned. When \p CheckTwoInstrs is set, we will check
+// against the instruction that defines \p Addr as well as the instruction that
+// defines the base address. When \p CheckTwoOperands is set, we will check both
+// operands (In case of two instructions, they are the operands from the
+// instruction that defines the base address).
+bool AMDGPUDAGToDAGISel::isFlatScratchBaseLegal(SDValue Addr,
+                                                bool CheckTwoInstrs,
+                                                bool CheckTwoOperands,
----------------
arsenm wrote:

I find the bool parameter names and usage somewhat confusing. It seems you're merging different cases together in this same function. Could you instead split out some common helper functions and have different queries for the different named addressing modes?

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


More information about the llvm-commits mailing list