[llvm] [SPIRV] Expand RWBuffer load and store from HLSL (PR #122355)

Nathan Gauër via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 14 02:50:33 PST 2025


================
@@ -1018,6 +1024,25 @@ bool SPIRVInstructionSelector::selectLoad(Register ResVReg,
                                           MachineInstr &I) const {
   unsigned OpOffset = isa<GIntrinsic>(I) ? 1 : 0;
   Register Ptr = I.getOperand(1 + OpOffset).getReg();
+
+  auto *PtrDef = getVRegDef(*MRI, Ptr);
+  auto *IntPtrDef = dyn_cast<GIntrinsic>(PtrDef);
+  if (IntPtrDef &&
+      IntPtrDef->getIntrinsicID() == Intrinsic::spv_resource_getpointer) {
----------------
Keenuts wrote:

>From what I've seen, reg2mem is not that clever. Seems like every single register is dumbly stored into a variable, and loaded just before use.

We do have a mem2reg pass after the structurizer (PromoteMemoryToRegisterPass) so that should be OK.


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


More information about the llvm-commits mailing list