Skip to content

Commit 1abb055

Browse files
authored
[IVDesc] Make getCastInsts return an ArrayRef (NFC) (#169021)
To make it clear that the return value is immutable.
1 parent e888cf8 commit 1abb055

File tree

4 files changed

+5
-8
lines changed

4 files changed

+5
-8
lines changed

llvm/include/llvm/Analysis/IVDescriptors.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,12 +451,10 @@ class InductionDescriptor {
451451
: Instruction::BinaryOpsEnd;
452452
}
453453

454-
/// Returns a reference to the type cast instructions in the induction
454+
/// Returns an ArrayRef to the type cast instructions in the induction
455455
/// update chain, that are redundant when guarded with a runtime
456456
/// SCEV overflow check.
457-
const SmallVectorImpl<Instruction *> &getCastInsts() const {
458-
return RedundantCasts;
459-
}
457+
ArrayRef<Instruction *> getCastInsts() const { return RedundantCasts; }
460458

461459
private:
462460
/// Private constructor - used by \c isInductionPHI.

llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ void LoopVectorizationLegality::addInductionPhi(
684684
// in the vectorized loop body, record them here. All casts could be recorded
685685
// here for ignoring, but suffices to record only the first (as it is the
686686
// only one that may bw used outside the cast sequence).
687-
const SmallVectorImpl<Instruction *> &Casts = ID.getCastInsts();
687+
ArrayRef<Instruction *> Casts = ID.getCastInsts();
688688
if (!Casts.empty())
689689
InductionCastsToIgnore.insert(*Casts.begin());
690690

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6575,8 +6575,7 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {
65756575
// detection.
65766576
for (const auto &Induction : Legal->getInductionVars()) {
65776577
const InductionDescriptor &IndDes = Induction.second;
6578-
const SmallVectorImpl<Instruction *> &Casts = IndDes.getCastInsts();
6579-
VecValuesToIgnore.insert_range(Casts);
6578+
VecValuesToIgnore.insert_range(IndDes.getCastInsts());
65806579
}
65816580
}
65826581

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ static void removeRedundantInductionCasts(VPlan &Plan) {
512512
// replace it with the original IV. Note that only the final cast is
513513
// expected to have users outside the cast-chain and the dead casts left
514514
// over will be cleaned up later.
515-
auto &Casts = IV->getInductionDescriptor().getCastInsts();
515+
ArrayRef<Instruction *> Casts = IV->getInductionDescriptor().getCastInsts();
516516
VPValue *FindMyCast = IV;
517517
for (Instruction *IRCast : reverse(Casts)) {
518518
VPSingleDefRecipe *FoundUserCast = nullptr;

0 commit comments

Comments
 (0)