@@ -2545,13 +2545,11 @@ expandVPWidenIntOrFpInduction(VPWidenIntOrFpInductionRecipe *WidenIVR,
2545
2545
VPValue *Start = WidenIVR->getStartValue ();
2546
2546
VPValue *Step = WidenIVR->getStepValue ();
2547
2547
VPValue *VF = WidenIVR->getVFValue ();
2548
- TruncInst *Trunc = WidenIVR->getTruncInst ();
2549
2548
DebugLoc DL = WidenIVR->getDebugLoc ();
2550
2549
2551
2550
// The value from the original loop to which we are mapping the new induction
2552
2551
// variable.
2553
- Instruction *IV = Trunc ? cast<Instruction>(Trunc) : WidenIVR->getPHINode ();
2554
- Type *Ty = IV->getType ();
2552
+ Type *Ty = TypeInfo.inferScalarType (WidenIVR);
2555
2553
2556
2554
const InductionDescriptor &ID = WidenIVR->getInductionDescriptor ();
2557
2555
Instruction::BinaryOps AddOp;
@@ -2568,17 +2566,17 @@ expandVPWidenIntOrFpInduction(VPWidenIntOrFpInductionRecipe *WidenIVR,
2568
2566
2569
2567
// If the phi is truncated, truncate the start and step values.
2570
2568
VPBuilder Builder (Plan->getVectorPreheader ());
2571
- if (isa<TruncInst>(IV)) {
2572
- assert (TypeInfo. inferScalarType (Start)-> isIntegerTy () &&
2573
- " Truncation requires an integer type" );
2569
+ Type *StepTy = TypeInfo. inferScalarType (Step);
2570
+ if (Ty-> getScalarSizeInBits () < StepTy-> getScalarSizeInBits ()) {
2571
+ assert (StepTy-> isIntegerTy () && " Truncation requires an integer type" );
2574
2572
Step = Builder.createScalarCast (Instruction::Trunc, Step, Ty, DL);
2575
2573
Start = Builder.createScalarCast (Instruction::Trunc, Start, Ty, DL);
2574
+ StepTy = Ty;
2576
2575
}
2577
2576
2578
2577
// Construct the initial value of the vector IV in the vector loop preheader.
2579
- Type *StepTy = TypeInfo.inferScalarType (Step);
2580
2578
Type *IVIntTy =
2581
- IntegerType::get (IV ->getContext (), StepTy->getScalarSizeInBits ());
2579
+ IntegerType::get (StepTy ->getContext (), StepTy->getScalarSizeInBits ());
2582
2580
VPValue *Init = Builder.createNaryOp (VPInstruction::StepVector, {}, IVIntTy);
2583
2581
if (StepTy->isFloatingPointTy ())
2584
2582
Init = Builder.createWidenCast (Instruction::UIToFP, Init, StepTy);
0 commit comments