[llvm] [SPIRV] Let atomic store store pointers (PR #201251)
Dmitry Sidorov via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 4 12:46:21 PDT 2026
================
@@ -2073,12 +2073,54 @@ 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()) {
+ // If data to store is a pointer type we cast it to an integer type of the
+ // same size as the pointer size using OpConvertPtrToU and then generate
+ // OpAtomicStore with casted values as required by spec.
+ auto PtrSize = GR.getPointerSize();
----------------
MrSidims wrote:
This only works for plain pointers. How do you feel about:
```
EVT VT = TLI->getMemValueType(DL, T);
unsigned BitWidth = VT.getStoreSizeInBits();
```
?
https://github.com/llvm/llvm-project/pull/201251
More information about the llvm-commits
mailing list