@@ -1913,8 +1913,8 @@ void InnerLoopVectorizer::widenIntOrFpInduction(PHINode *IV, TruncInst *Trunc) {
1913
1913
Value *InnerLoopVectorizer::getStepVector (Value *Val, int StartIdx, Value *Step,
1914
1914
Instruction::BinaryOps BinOp) {
1915
1915
// Create and check the types.
1916
- assert (Val->getType ()-> isVectorTy () && " Must be a vector " );
1917
- int VLen = Val-> getType ()-> getVectorNumElements ();
1916
+ auto *ValVTy = cast<VectorType> (Val->getType ());
1917
+ int VLen = ValVTy-> getNumElements ();
1918
1918
1919
1919
Type *STy = Val->getType ()->getScalarType ();
1920
1920
assert ((STy->isIntegerTy () || STy->isFloatingPointTy ()) &&
@@ -3318,13 +3318,14 @@ unsigned LoopVectorizationCostModel::getVectorIntrinsicCost(CallInst *CI,
3318
3318
}
3319
3319
3320
3320
static Type *smallestIntegerVectorType (Type *T1, Type *T2) {
3321
- auto *I1 = cast<IntegerType>(T1-> getVectorElementType ());
3322
- auto *I2 = cast<IntegerType>(T2-> getVectorElementType ());
3321
+ auto *I1 = cast<IntegerType>(cast<VectorType>(T1)-> getElementType ());
3322
+ auto *I2 = cast<IntegerType>(cast<VectorType>(T2)-> getElementType ());
3323
3323
return I1->getBitWidth () < I2->getBitWidth () ? T1 : T2;
3324
3324
}
3325
+
3325
3326
static Type *largestIntegerVectorType (Type *T1, Type *T2) {
3326
- auto *I1 = cast<IntegerType>(T1-> getVectorElementType ());
3327
- auto *I2 = cast<IntegerType>(T2-> getVectorElementType ());
3327
+ auto *I1 = cast<IntegerType>(cast<VectorType>(T1)-> getElementType ());
3328
+ auto *I2 = cast<IntegerType>(cast<VectorType>(T2)-> getElementType ());
3328
3329
return I1->getBitWidth () > I2->getBitWidth () ? T1 : T2;
3329
3330
}
3330
3331
@@ -3347,8 +3348,8 @@ void InnerLoopVectorizer::truncateToMinimalBitwidths() {
3347
3348
Type *OriginalTy = I->getType ();
3348
3349
Type *ScalarTruncatedTy =
3349
3350
IntegerType::get (OriginalTy->getContext (), KV.second );
3350
- Type *TruncatedTy = VectorType::get (ScalarTruncatedTy,
3351
- OriginalTy-> getVectorNumElements ());
3351
+ Type *TruncatedTy = VectorType::get (
3352
+ ScalarTruncatedTy, cast<VectorType>( OriginalTy)-> getNumElements ());
3352
3353
if (TruncatedTy == OriginalTy)
3353
3354
continue ;
3354
3355
@@ -3398,10 +3399,12 @@ void InnerLoopVectorizer::truncateToMinimalBitwidths() {
3398
3399
break ;
3399
3400
}
3400
3401
} else if (auto *SI = dyn_cast<ShuffleVectorInst>(I)) {
3401
- auto Elements0 = SI->getOperand (0 )->getType ()->getVectorNumElements ();
3402
+ auto Elements0 =
3403
+ cast<VectorType>(SI->getOperand (0 )->getType ())->getNumElements ();
3402
3404
auto *O0 = B.CreateZExtOrTrunc (
3403
3405
SI->getOperand (0 ), VectorType::get (ScalarTruncatedTy, Elements0));
3404
- auto Elements1 = SI->getOperand (1 )->getType ()->getVectorNumElements ();
3406
+ auto Elements1 =
3407
+ cast<VectorType>(SI->getOperand (1 )->getType ())->getNumElements ();
3405
3408
auto *O1 = B.CreateZExtOrTrunc (
3406
3409
SI->getOperand (1 ), VectorType::get (ScalarTruncatedTy, Elements1));
3407
3410
@@ -3410,13 +3413,15 @@ void InnerLoopVectorizer::truncateToMinimalBitwidths() {
3410
3413
// Don't do anything with the operands, just extend the result.
3411
3414
continue ;
3412
3415
} else if (auto *IE = dyn_cast<InsertElementInst>(I)) {
3413
- auto Elements = IE->getOperand (0 )->getType ()->getVectorNumElements ();
3416
+ auto Elements =
3417
+ cast<VectorType>(IE->getOperand (0 )->getType ())->getNumElements ();
3414
3418
auto *O0 = B.CreateZExtOrTrunc (
3415
3419
IE->getOperand (0 ), VectorType::get (ScalarTruncatedTy, Elements));
3416
3420
auto *O1 = B.CreateZExtOrTrunc (IE->getOperand (1 ), ScalarTruncatedTy);
3417
3421
NewI = B.CreateInsertElement (O0, O1, IE->getOperand (2 ));
3418
3422
} else if (auto *EE = dyn_cast<ExtractElementInst>(I)) {
3419
- auto Elements = EE->getOperand (0 )->getType ()->getVectorNumElements ();
3423
+ auto Elements =
3424
+ cast<VectorType>(EE->getOperand (0 )->getType ())->getNumElements ();
3420
3425
auto *O0 = B.CreateZExtOrTrunc (
3421
3426
EE->getOperand (0 ), VectorType::get (ScalarTruncatedTy, Elements));
3422
3427
NewI = B.CreateExtractElement (O0, EE->getOperand (2 ));
0 commit comments