[llvm] [SPIRV] Use OpCopyMemory for logical SPIRV memcpy (PR #169348)

Nathan Gauër via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 24 08:53:05 PST 2025


================
@@ -1435,50 +1438,76 @@ bool SPIRVInstructionSelector::selectStackRestore(MachineInstr &I) const {
       .constrainAllUses(TII, TRI, RBI);
 }
 
-bool SPIRVInstructionSelector::selectMemOperation(Register ResVReg,
-                                                  MachineInstr &I) const {
+Register
+SPIRVInstructionSelector::getOrCreateMemSetGlobal(MachineInstr &I) const {
+  MachineIRBuilder MIRBuilder(I);
+  assert(I.getOperand(1).isReg() && I.getOperand(2).isReg());
+  unsigned Val = getIConstVal(I.getOperand(1).getReg(), MRI);
+  unsigned Num = getIConstVal(I.getOperand(2).getReg(), MRI);
+  Type *ValTy = Type::getInt8Ty(I.getMF()->getFunction().getContext());
+  Type *ArrTy = ArrayType::get(ValTy, Num);
+  SPIRVType *VarTy = GR.getOrCreateSPIRVPointerType(
----------------
Keenuts wrote:

nit: You can move things around to have them closer to their usage:

- Num > LLVMArrTy > GlobalVariable
- Val > ValTy > ArrTy > { VarTy > SpvArrTy } > Const > OpVariable

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


More information about the llvm-commits mailing list