[llvm] [SPIRV] Add handling for `uinc_wrap` and `udec_wrap` atomics (PR #179114)
Manuel Carrasco via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 4 03:23:08 PST 2026
================
@@ -627,3 +634,26 @@ bool SPIRVTargetLowering::insertLogicalCopyOnResult(
.constrainAllUses(*STI.getInstrInfo(), *STI.getRegisterInfo(),
*STI.getRegBankInfo());
}
+
+TargetLowering::AtomicExpansionKind
+SPIRVTargetLowering::shouldExpandAtomicRMWInIR(const AtomicRMWInst *RMW) const {
+ switch (RMW->getOperation()) {
+ case AtomicRMWInst::FAdd:
+ case AtomicRMWInst::FSub:
+ case AtomicRMWInst::FMin:
+ case AtomicRMWInst::FMax:
+ return AtomicExpansionKind::None;
+ case AtomicRMWInst::UIncWrap:
+ case AtomicRMWInst::UDecWrap:
+ return AtomicExpansionKind::CmpXChg;
+ default:
+ return TargetLowering::shouldExpandAtomicRMWInIR(RMW);
+ }
+}
+
+TargetLowering::AtomicExpansionKind
+SPIRVTargetLowering::shouldCastAtomicRMWIInIR(AtomicRMWInst *RMWI) const {
+ // Do not cast atomic exchange at all since SPIR-V natively supports
----------------
mgcarrasco wrote:
If I got it right, the PR is not changing how pointers are handled because that is not required for uinc_wrap or udec_wrap support. So there are no regressions. Thus, I'd not address that particular problem in this PR. A todo looks fine to me explaining that it may be a good idea to cast pointers because SPIRV doesn't support that (if it makes sense).
https://github.com/llvm/llvm-project/pull/179114
More information about the llvm-commits
mailing list