Skip to content

Commit ff89acf

Browse files
committed
!fixup address latest comments, thanks
1 parent 761d4ca commit ff89acf

File tree

6 files changed

+18
-12
lines changed

6 files changed

+18
-12
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2381,7 +2381,6 @@ void InnerLoopVectorizer::introduceCheckBlockInVPlan(BasicBlock *CheckIRBB) {
23812381
// We just connected a new block to the scalar preheader. Update all
23822382
// VPPhis by adding an incoming value for it, replicating the last value.
23832383
unsigned NumPredecessors = ScalarPH->getNumPredecessors();
2384-
(void)NumPredecessors;
23852384
for (VPRecipeBase &R : cast<VPBasicBlock>(ScalarPH)->phis()) {
23862385
assert(isa<VPPhi>(&R) && "Phi expected to be VPPhi");
23872386
assert(cast<VPPhi>(&R)->getNumIncoming() == NumPredecessors - 1 &&

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3530,17 +3530,16 @@ class VPScalarIVStepsRecipe : public VPRecipeWithIRFlags,
35303530

35313531
/// Casting from VPRecipeBase -> VPPhiAccessors is supported for all recipe
35323532
/// types implementing VPPhiAccessors. Used by isa<> & co.
3533-
template <typename SrcTy> struct CastIsPossible<VPPhiAccessors, SrcTy> {
3534-
static inline bool isPossible(SrcTy f) {
3533+
template <> struct CastIsPossible<VPPhiAccessors, const VPRecipeBase *> {
3534+
static inline bool isPossible(const VPRecipeBase *f) {
35353535
// TODO: include VPPredInstPHIRecipe too, once it implements VPPhiAccessors.
35363536
return isa<VPIRPhi, VPHeaderPHIRecipe, VPWidenPHIRecipe, VPPhi>(f);
35373537
}
35383538
};
35393539
/// Support casting from VPRecipeBase -> VPPhiAccessors, by down-casting to the
35403540
/// recipe types implementing VPPhiAccessors. Used by cast<>, dyn_cast<> & co.
35413541
template <typename SrcTy>
3542-
struct CastInfo<VPPhiAccessors, SrcTy>
3543-
: public CastIsPossible<VPPhiAccessors, SrcTy> {
3542+
struct CastInfoVPPhiAccessors : public CastIsPossible<VPPhiAccessors, SrcTy> {
35443543

35453544
using Self = CastInfo<VPPhiAccessors, SrcTy>;
35463545

@@ -3567,6 +3566,12 @@ struct CastInfo<VPPhiAccessors, SrcTy>
35673566
return doCast(f);
35683567
}
35693568
};
3569+
template <>
3570+
struct CastInfo<VPPhiAccessors, VPRecipeBase *>
3571+
: CastInfoVPPhiAccessors<VPRecipeBase *> {};
3572+
template <>
3573+
struct CastInfo<VPPhiAccessors, const VPRecipeBase *>
3574+
: CastInfoVPPhiAccessors<const VPRecipeBase *> {};
35703575

35713576
/// VPBasicBlock serves as the leaf of the Hierarchical Control-Flow Graph. It
35723577
/// holds a sequence of zero or more VPRecipe's each representing a sequence of

llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ void VPlanTransforms::prepareForVectorization(
548548

549549
assert(MiddleVPBB->getNumSuccessors() == 2 && "must have 2 successors");
550550

551-
// Add a check in the middle block to see if we have completed$ all of the
551+
// Add a check in the middle block to see if we have completed all of the
552552
// iterations in the first vector loop.
553553
//
554554
// Three cases:

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,6 @@ void VPPhiAccessors::removeIncomingValueFor(VPBlockBase *IncomingBlock) const {
11911191
assert(R->getNumOperands() == Preds.size() &&
11921192
"Number of phi operands must match number of predecessors");
11931193
unsigned Position = std::distance(Preds.begin(), find(Preds, IncomingBlock));
1194-
R->getOperand(Position)->removeUser(*R);
11951194
R->removeOperand(Position);
11961195
}
11971196

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,10 +1867,8 @@ static void removeBranchOnConst(VPlan &Plan) {
18671867
"There must be a single edge between VPBB and its successor");
18681868
// Values coming from VPBB into phi recipes of RemoveSucc are removed from
18691869
// these recipes.
1870-
for (VPRecipeBase &R : make_early_inc_range(*RemovedSucc)) {
1871-
auto *Phi = dyn_cast<VPPhiAccessors>(&R);
1872-
if (!Phi)
1873-
break;
1870+
for (VPRecipeBase &R : RemovedSucc->phis()) {
1871+
auto *Phi = cast<VPPhiAccessors>(&R);
18741872
assert((!isa<VPIRPhi>(&R) || RemovedSucc->getNumPredecessors() == 1) &&
18751873
"VPIRPhis must have a single predecessor");
18761874
Phi->removeIncomingValueFor(VPBB);

llvm/lib/Transforms/Vectorize/VPlanValue.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,12 @@ class VPUser {
205205

206206
SmallVector<VPValue *, 2> Operands;
207207

208-
void removeOperand(unsigned Idx) { Operands.erase(Operands.begin() + Idx); }
208+
/// Removes the operand at index \p Idx. This also removes the VPUser from the
209+
/// use-list of the operand.
210+
void removeOperand(unsigned Idx) {
211+
getOperand(Idx)->removeUser(*this);
212+
Operands.erase(Operands.begin() + Idx);
213+
}
209214

210215
protected:
211216
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)

0 commit comments

Comments
 (0)