@@ -496,10 +496,9 @@ static void EmitHLSLSplatCast(CodeGenFunction &CGF, Address DestVal,
496496 QualType SrcTy, SourceLocation Loc) {
497497 // Flatten our destination
498498 SmallVector<QualType> DestTypes; // Flattened type
499- SmallVector<llvm::Value *, 4 > IdxList;
500499 SmallVector<std::pair<Address, llvm::Value *>, 16 > StoreGEPList;
501500 // ^^ Flattened accesses to DestVal we want to store into
502- CGF.FlattenAccessAndType (DestVal, DestTy, IdxList, StoreGEPList, DestTypes);
501+ CGF.FlattenAccessAndType (DestVal, DestTy, StoreGEPList, DestTypes);
503502
504503 if (const VectorType *VT = SrcTy->getAs <VectorType>()) {
505504 assert (VT->getNumElements () == 1 && " Invalid HLSL splat cast." );
@@ -511,7 +510,15 @@ static void EmitHLSLSplatCast(CodeGenFunction &CGF, Address DestVal,
511510 for (unsigned i = 0 ; i < StoreGEPList.size (); i++) {
512511 llvm::Value *Cast =
513512 CGF.EmitScalarConversion (SrcVal, SrcTy, DestTypes[i], Loc);
514- CGF.PerformStore (StoreGEPList[i], Cast);
513+
514+ // store back
515+ llvm::Value *Idx = StoreGEPList[i].second ;
516+ if (Idx) {
517+ llvm::Value *V =
518+ CGF.Builder .CreateLoad (StoreGEPList[i].first , " load.for.insert" );
519+ Cast = CGF.Builder .CreateInsertElement (V, Cast, Idx);
520+ }
521+ CGF.Builder .CreateStore (Cast, StoreGEPList[i].first );
515522 }
516523}
517524
@@ -1595,7 +1602,6 @@ static bool castPreservesZero(const CastExpr *CE) {
15951602 case CK_HLSLVectorTruncation:
15961603 // TODO does CK_HLSLAggregateCast preserve zero?
15971604 // TODO is this true for CK_HLSLSplatCast
1598- >>>>>>> a74daceacc38 (Try to handle Cast in all the places it needs to be handled)
15991605 return true ;
16001606
16011607 case CK_BaseToDerivedMemberPointer:
0 commit comments