@@ -496,10 +496,9 @@ static void EmitHLSLSplatCast(CodeGenFunction &CGF, Address DestVal,
496
496
QualType SrcTy, SourceLocation Loc) {
497
497
// Flatten our destination
498
498
SmallVector<QualType> DestTypes; // Flattened type
499
- SmallVector<llvm::Value *, 4 > IdxList;
500
499
SmallVector<std::pair<Address, llvm::Value *>, 16 > StoreGEPList;
501
500
// ^^ Flattened accesses to DestVal we want to store into
502
- CGF.FlattenAccessAndType (DestVal, DestTy, IdxList, StoreGEPList, DestTypes);
501
+ CGF.FlattenAccessAndType (DestVal, DestTy, StoreGEPList, DestTypes);
503
502
504
503
if (const VectorType *VT = SrcTy->getAs <VectorType>()) {
505
504
assert (VT->getNumElements () == 1 && " Invalid HLSL splat cast." );
@@ -511,7 +510,15 @@ static void EmitHLSLSplatCast(CodeGenFunction &CGF, Address DestVal,
511
510
for (unsigned i = 0 ; i < StoreGEPList.size (); i++) {
512
511
llvm::Value *Cast =
513
512
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 );
515
522
}
516
523
}
517
524
@@ -1595,7 +1602,6 @@ static bool castPreservesZero(const CastExpr *CE) {
1595
1602
case CK_HLSLVectorTruncation:
1596
1603
// TODO does CK_HLSLAggregateCast preserve zero?
1597
1604
// TODO is this true for CK_HLSLSplatCast
1598
- >>>>>>> a74daceacc38 (Try to handle Cast in all the places it needs to be handled)
1599
1605
return true ;
1600
1606
1601
1607
case CK_BaseToDerivedMemberPointer:
0 commit comments