[llvm-branch-commits] [clang] [llvm] [HLSL] Add float overload for `InterlockedExchange` (PR #222163)
Joshua Batista via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Sep 23 12:46:02 PDT 2026
================
@@ -356,6 +356,34 @@ static bool updateFnegToFsub(Instruction &I,
return true;
}
+// DXIL has no floating-point atomic operation. A float exchange only moves the
+// bit pattern, so exchange an integer of the same width instead. Opaque
+// pointers keep the pointer operand type-agnostic, so only the value and the
+// result need a cast. This matches what DXC emits for groupshared memory.
+static bool
+legalizeFloatAtomicExchange(Instruction &I,
+ SmallVectorImpl<Instruction *> &ToRemove,
+ DenseMap<Value *, Value *> &) {
+ auto *AI = dyn_cast<AtomicRMWInst>(&I);
+ if (!AI || AI->getOperation() != AtomicRMWInst::Xchg)
+ return false;
+
+ Type *ValTy = AI->getValOperand()->getType();
+ if (!ValTy->isFloatingPointTy())
----------------
bob80905 wrote:
SemaHLSL should catch non-conformant types. But you're right that we could catch illegal widths here, so I've added a width check right after this.
https://github.com/llvm/llvm-project/pull/222163
More information about the llvm-branch-commits
mailing list