@@ -3067,23 +3067,23 @@ bool VectorCombine::foldInsExtVectorToShuffle(Instruction &I) {
3067
3067
m_ConstantInt (InsIdx))))
3068
3068
return false ;
3069
3069
3070
- auto *VecTy = dyn_cast<FixedVectorType>(I.getType ());
3070
+ auto *DstVecTy = dyn_cast<FixedVectorType>(I.getType ());
3071
3071
auto *SrcVecTy = dyn_cast<FixedVectorType>(SrcVec->getType ());
3072
3072
// We can try combining vectors with different element sizes.
3073
- if (!VecTy || !SrcVecTy ||
3074
- SrcVecTy->getElementType () != VecTy ->getElementType ())
3073
+ if (!DstVecTy || !SrcVecTy ||
3074
+ SrcVecTy->getElementType () != DstVecTy ->getElementType ())
3075
3075
return false ;
3076
3076
3077
- unsigned NumElts = VecTy ->getNumElements ();
3077
+ unsigned NumDstElts = DstVecTy ->getNumElements ();
3078
3078
unsigned NumSrcElts = SrcVecTy->getNumElements ();
3079
- if (InsIdx >= NumElts || NumElts == 1 )
3079
+ if (InsIdx >= NumDstElts || NumDstElts == 1 )
3080
3080
return false ;
3081
3081
3082
3082
// Insertion into poison is a cheaper single operand shuffle.
3083
3083
TargetTransformInfo::ShuffleKind SK;
3084
- SmallVector<int > Mask (NumElts , PoisonMaskElem);
3084
+ SmallVector<int > Mask (NumDstElts , PoisonMaskElem);
3085
3085
3086
- bool NeedExpOrNarrow = NumSrcElts != NumElts ;
3086
+ bool NeedExpOrNarrow = NumSrcElts != NumDstElts ;
3087
3087
bool NeedDstSrcSwap = isa<PoisonValue>(DstVec) && !isa<UndefValue>(SrcVec);
3088
3088
if (NeedDstSrcSwap) {
3089
3089
SK = TargetTransformInfo::SK_PermuteSingleSrc;
@@ -3096,38 +3096,38 @@ bool VectorCombine::foldInsExtVectorToShuffle(Instruction &I) {
3096
3096
SK = TargetTransformInfo::SK_PermuteTwoSrc;
3097
3097
std::iota (Mask.begin (), Mask.end (), 0 );
3098
3098
if (!NeedExpOrNarrow)
3099
- Mask[InsIdx] = ExtIdx + NumElts ;
3099
+ Mask[InsIdx] = ExtIdx + NumDstElts ;
3100
3100
else
3101
- Mask[InsIdx] = NumElts ;
3101
+ Mask[InsIdx] = NumDstElts ;
3102
3102
}
3103
3103
3104
3104
// Cost
3105
3105
auto *Ins = cast<InsertElementInst>(&I);
3106
3106
auto *Ext = cast<ExtractElementInst>(I.getOperand (1 ));
3107
3107
InstructionCost InsCost =
3108
- TTI.getVectorInstrCost (*Ins, VecTy , CostKind, InsIdx);
3108
+ TTI.getVectorInstrCost (*Ins, DstVecTy , CostKind, InsIdx);
3109
3109
InstructionCost ExtCost =
3110
- TTI.getVectorInstrCost (*Ext, VecTy , CostKind, ExtIdx);
3110
+ TTI.getVectorInstrCost (*Ext, DstVecTy , CostKind, ExtIdx);
3111
3111
InstructionCost OldCost = ExtCost + InsCost;
3112
3112
3113
3113
InstructionCost NewCost = 0 ;
3114
3114
SmallVector<int > ExtToVecMask;
3115
3115
if (!NeedExpOrNarrow) {
3116
3116
// Ignore 'free' identity insertion shuffle.
3117
3117
// TODO: getShuffleCost should return TCC_Free for Identity shuffles.
3118
- if (!ShuffleVectorInst::isIdentityMask (Mask, NumElts ))
3119
- NewCost += TTI.getShuffleCost (SK, VecTy , Mask, CostKind, 0 , nullptr ,
3118
+ if (!ShuffleVectorInst::isIdentityMask (Mask, NumDstElts ))
3119
+ NewCost += TTI.getShuffleCost (SK, DstVecTy , Mask, CostKind, 0 , nullptr ,
3120
3120
{DstVec, SrcVec});
3121
3121
} else {
3122
3122
// When creating length-changing-vector, always create with a Mask whose
3123
3123
// first element has an ExtIdx, so that the first element of the vector
3124
3124
// being created is always the target to be extracted.
3125
- ExtToVecMask.assign (NumElts , PoisonMaskElem);
3125
+ ExtToVecMask.assign (NumDstElts , PoisonMaskElem);
3126
3126
ExtToVecMask[0 ] = ExtIdx;
3127
3127
// Add cost for expanding or narrowing
3128
3128
NewCost = TTI.getShuffleCost (TargetTransformInfo::SK_PermuteSingleSrc,
3129
- VecTy , ExtToVecMask, CostKind);
3130
- NewCost += TTI.getShuffleCost (SK, VecTy , Mask, CostKind);
3129
+ DstVecTy , ExtToVecMask, CostKind);
3130
+ NewCost += TTI.getShuffleCost (SK, DstVecTy , Mask, CostKind);
3131
3131
}
3132
3132
3133
3133
if (!Ext->hasOneUse ())
@@ -3149,7 +3149,7 @@ bool VectorCombine::foldInsExtVectorToShuffle(Instruction &I) {
3149
3149
3150
3150
// Canonicalize undef param to RHS to help further folds.
3151
3151
if (isa<UndefValue>(DstVec) && !isa<UndefValue>(SrcVec)) {
3152
- ShuffleVectorInst::commuteShuffleMask (Mask, NumElts );
3152
+ ShuffleVectorInst::commuteShuffleMask (Mask, NumDstElts );
3153
3153
std::swap (DstVec, SrcVec);
3154
3154
}
3155
3155
0 commit comments