[llvm] [AMDGPU] Fix negative immediate offset for unbuffered smem loads (PR #79553)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 16 11:46:46 PDT 2024


================
@@ -4218,6 +4218,27 @@ AMDGPUInstructionSelector::selectVINTERPModsHi(MachineOperand &Root) const {
   }};
 }
 
+// Subtract the absolute value of the immediate offset from SBase and set the
+// immediate offset to 0.
+bool AMDGPUInstructionSelector::subtractOffsetFromBase(MachineInstr *MI,
+                                                       MachineBasicBlock *MBB,
+                                                       Register &Base,
+                                                       int64_t *Offset) const {
+  Register SubtractReg = MRI->createVirtualRegister(&AMDGPU::SReg_64RegClass);
+  unsigned Opc;
+
+  if (Subtarget->hasScalarAddSub64())
+    Opc = AMDGPU::S_SUB_U64;
+  else
+    Opc = AMDGPU::S_SUB_U64_PSEUDO;
----------------
arsenm wrote:

Initialize Opc with ternary 

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


More information about the llvm-commits mailing list