[llvm] [SPIRV] Let atomic store store pointers (PR #201251)
Nick Sarnie via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 4 08:23:28 PDT 2026
================
@@ -2073,12 +2073,50 @@ bool SPIRVInstructionSelector::selectAtomicStore(MachineInstr &I) const {
Register MemSemReg = buildI32Constant(MemSem | StorageClass, I);
MachineIRBuilder MIRBuilder(I);
- auto AtomicStore = MIRBuilder.buildInstr(SPIRV::OpAtomicStore)
- .addUse(Ptr)
- .addUse(ScopeReg)
- .addUse(MemSemReg)
- .addUse(StoreVal);
- AtomicStore.constrainAllUses(TII, TRI, RBI);
+
+ if (PointeeType.isTypePtr()) {
+ auto PtrSize = GR.getPointerSize();
+ SPIRVTypeInst SpirvType =
+ GR.getOrCreateSPIRVIntegerType(PtrSize, MIRBuilder);
+
+ Register NewVRegVal =
+ MRI->createGenericVirtualRegister(LLT::scalar(PtrSize));
+ MRI->setRegClass(NewVRegVal, MRI->getRegClassOrNull(StoreVal));
+ GR.assignSPIRVTypeToVReg(SpirvType, NewVRegVal, MIRBuilder.getMF());
+ MIRBuilder.buildInstr(SPIRV::OpConvertPtrToU)
+ .addDef(NewVRegVal)
+ .addUse(GR.getSPIRVTypeID(SpirvType)) // Result type
+ .addUse(StoreVal) // Pointer operand
+ .constrainAllUses(TII, TRI, RBI);
+
+ Register NewVRegPtr =
----------------
sarnex wrote:
similar here, maybe something like `PtrCastedToMatchValReg` or something?
https://github.com/llvm/llvm-project/pull/201251
More information about the llvm-commits
mailing list