================
@@ -2801,26 +2801,57 @@ void
CodeGenFunction::EmitStoreThroughExtVectorComponentLValue(RValue Src,
LValue Dst) {
llvm::Value *SrcVal = Src.getScalarVal();
Address DstAddr = Dst.getExtVectorAddress();
+ const llvm::Constant *Elts = Dst.getExtVectorElts();
if (DstAddr.getElementType()->getScalarSizeInBits() >
SrcVal->getType()->getScalarSizeInBits())
SrcVal = Builder.CreateZExt(
SrcVal, convertTypeForLoadStore(Dst.getType(), SrcVal->getType()));
- // HLSL allows storing to scalar values through ExtVector component LValues.
- // To support this we need to handle the case where the destination address
is
- // a scalar.
- if (!DstAddr.getElementType()->isVectorTy()) {
- assert(!Dst.getType()->isVectorType() &&
- "this should only occur for non-vector l-values");
- Builder.CreateStore(SrcVal, DstAddr, Dst.isVolatileQualified());
+ if (getLangOpts().HLSL) {
+ llvm::Type *DestAddrTy = DstAddr.getElementType();
+ // HLSL allows storing to scalar values through ExtVector component
LValues.
+ // To support this we need to handle the case where the destination address
+ // is a scalar.
+ if (!DestAddrTy->isVectorTy()) {
+ assert(!Dst.getType()->isVectorType() &&
+ "this should only occur for non-vector l-values");
+ Builder.CreateStore(SrcVal, DstAddr, Dst.isVolatileQualified());
+ return;
+ }
+
+ // In HLSL, storing to individual elements of a vector through ExtVector
+ // components needs to be handled as separate store instructions. We need
to
+ // avoid the load/modify/store sequence to prevent overwriting other
+ // elements that might be getting updated in parallel.
----------------
bogner wrote:
The wording on this comment is a bit confusing in the way it talks about
"avoiding RMW". Would it be better to just state that accesses to individual
vector elements are modelled as such, and so we access them directly?
https://github.com/llvm/llvm-project/pull/169090
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits