@@ -1236,10 +1236,8 @@ RecurrenceDescriptor::getReductionOpChain(PHINode *Phi, Loop *L) const {
1236
1236
1237
1237
InductionDescriptor::InductionDescriptor (Value *Start, InductionKind K,
1238
1238
const SCEV *Step, BinaryOperator *BOp,
1239
- Type *ElementType,
1240
1239
SmallVectorImpl<Instruction *> *Casts)
1241
- : StartValue(Start), IK(K), Step(Step), InductionBinOp(BOp),
1242
- ElementType(ElementType) {
1240
+ : StartValue(Start), IK(K), Step(Step), InductionBinOp(BOp) {
1243
1241
assert (IK != IK_NoInduction && " Not an induction" );
1244
1242
1245
1243
// Start value type should match the induction kind and the value
@@ -1265,11 +1263,6 @@ InductionDescriptor::InductionDescriptor(Value *Start, InductionKind K,
1265
1263
InductionBinOp->getOpcode () == Instruction::FSub))) &&
1266
1264
" Binary opcode should be specified for FP induction" );
1267
1265
1268
- if (IK == IK_PtrInduction)
1269
- assert (ElementType && " Pointer induction must have element type" );
1270
- else
1271
- assert (!ElementType && " Non-pointer induction cannot have element type" );
1272
-
1273
1266
if (Casts) {
1274
1267
for (auto &Inst : *Casts) {
1275
1268
RedundantCasts.push_back (Inst);
@@ -1535,49 +1528,13 @@ bool InductionDescriptor::isInductionPHI(
1535
1528
BinaryOperator *BOp =
1536
1529
dyn_cast<BinaryOperator>(Phi->getIncomingValueForBlock (Latch));
1537
1530
D = InductionDescriptor (StartValue, IK_IntInduction, Step, BOp,
1538
- /* ElementType */ nullptr , CastsToIgnore);
1531
+ CastsToIgnore);
1539
1532
return true ;
1540
1533
}
1541
1534
1542
1535
assert (PhiTy->isPointerTy () && " The PHI must be a pointer" );
1543
- PointerType *PtrTy = cast<PointerType>(PhiTy);
1544
1536
1545
- // Always use i8 element type for opaque pointer inductions.
1546
1537
// This allows induction variables w/non-constant steps.
1547
- if (PtrTy->isOpaque ()) {
1548
- D = InductionDescriptor (StartValue, IK_PtrInduction, Step,
1549
- /* BinOp */ nullptr ,
1550
- Type::getInt8Ty (PtrTy->getContext ()));
1551
- return true ;
1552
- }
1553
-
1554
- // Pointer induction should be a constant.
1555
- // TODO: This could be generalized, but should probably just
1556
- // be dropped instead once the migration to opaque ptrs is
1557
- // complete.
1558
- if (!ConstStep)
1559
- return false ;
1560
-
1561
- Type *ElementType = PtrTy->getNonOpaquePointerElementType ();
1562
- if (!ElementType->isSized ())
1563
- return false ;
1564
-
1565
- ConstantInt *CV = ConstStep->getValue ();
1566
- const DataLayout &DL = Phi->getModule ()->getDataLayout ();
1567
- TypeSize TySize = DL.getTypeAllocSize (ElementType);
1568
- // TODO: We could potentially support this for scalable vectors if we can
1569
- // prove at compile time that the constant step is always a multiple of
1570
- // the scalable type.
1571
- if (TySize.isZero () || TySize.isScalable ())
1572
- return false ;
1573
-
1574
- int64_t Size = static_cast <int64_t >(TySize.getFixedValue ());
1575
- int64_t CVSize = CV->getSExtValue ();
1576
- if (CVSize % Size)
1577
- return false ;
1578
- auto *StepValue =
1579
- SE->getConstant (CV->getType (), CVSize / Size, true /* signed */ );
1580
- D = InductionDescriptor (StartValue, IK_PtrInduction, StepValue,
1581
- /* BinOp */ nullptr , ElementType);
1538
+ D = InductionDescriptor (StartValue, IK_PtrInduction, Step);
1582
1539
return true ;
1583
1540
}
0 commit comments