diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h b/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h --- a/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h +++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h @@ -218,18 +218,6 @@ SmallVector VPlans; - /// This class is used to enable the VPlan to invoke a method of ILV. This is - /// needed until the method is refactored out of ILV and becomes reusable. - struct VPCallbackILV : public VPCallback { - InnerLoopVectorizer &ILV; - - VPCallbackILV(InnerLoopVectorizer &ILV) : ILV(ILV) {} - - Value *getOrCreateVectorValues(Value *V, unsigned Part) override; - Value *getOrCreateScalarValue(Value *V, - const VPIteration &Instance) override; - }; - /// A builder used to construct the current plan. VPBuilder Builder; diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -7750,18 +7750,10 @@ // Perform the actual loop transformation. // 1. Create a new empty loop. Unlink the old loop and connect the new one. - VPCallbackILV CallbackILV(ILV); - assert(BestVF.hasValue() && "Vectorization Factor is missing"); - VPTransformState State{*BestVF, - BestUF, - LI, - DT, - ILV.Builder, - ILV.VectorLoopValueMap, - &ILV, - CallbackILV}; + VPTransformState State{ + *BestVF, BestUF, LI, DT, ILV.Builder, ILV.VectorLoopValueMap, &ILV}; State.CFG.PrevBB = ILV.createVectorizedLoopSkeleton(); State.TripCount = ILV.getOrCreateTripCount(nullptr); State.CanonicalIV = ILV.Induction; @@ -8966,16 +8958,6 @@ } } -Value* LoopVectorizationPlanner::VPCallbackILV:: -getOrCreateVectorValues(Value *V, unsigned Part) { - return ILV.getOrCreateVectorValue(V, Part); -} - -Value *LoopVectorizationPlanner::VPCallbackILV::getOrCreateScalarValue( - Value *V, const VPIteration &Instance) { - return ILV.getOrCreateScalarValue(V, Instance); -} - void VPInterleaveRecipe::print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const { O << "\"INTERLEAVE-GROUP with factor " << IG->getFactor() << " at "; @@ -9270,8 +9252,16 @@ if (hasVectorValue(Def, Part)) return Data.PerPartOutput[Def][Part]; - if (!hasScalarValue(Def, {Part, 0})) - return Callback.getOrCreateVectorValues(VPValue2Value[Def], Part); + if (!hasScalarValue(Def, {Part, 0})) { + Value *IRV = Def->getLiveInIRValue(); + Value *B = ILV->getBroadcastInstrs(IRV); + auto IRDef = VPValue2Value.find(Def); + if (IRDef != VPValue2Value.end()) + set(Def, IRDef->second, B, Part); + else + set(Def, B, Part); + return B; + } Value *ScalarValue = get(Def, {Part, 0}); // If we aren't vectorizing, we can just copy the scalar map values over diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h --- a/llvm/lib/Transforms/Vectorize/VPlan.h +++ b/llvm/lib/Transforms/Vectorize/VPlan.h @@ -234,24 +234,14 @@ } }; -/// This class is used to enable the VPlan to invoke a method of ILV. This is -/// needed until the method is refactored out of ILV and becomes reusable. -struct VPCallback { - virtual ~VPCallback() {} - virtual Value *getOrCreateVectorValues(Value *V, unsigned Part) = 0; - virtual Value *getOrCreateScalarValue(Value *V, - const VPIteration &Instance) = 0; -}; - /// VPTransformState holds information passed down when "executing" a VPlan, /// needed for generating the output IR. struct VPTransformState { VPTransformState(ElementCount VF, unsigned UF, LoopInfo *LI, DominatorTree *DT, IRBuilder<> &Builder, - VectorizerValueMap &ValueMap, InnerLoopVectorizer *ILV, - VPCallback &Callback) + VectorizerValueMap &ValueMap, InnerLoopVectorizer *ILV) : VF(VF), UF(UF), Instance(), LI(LI), DT(DT), Builder(Builder), - ValueMap(ValueMap), ILV(ILV), Callback(Callback) {} + ValueMap(ValueMap), ILV(ILV) {} /// The chosen Vectorization and Unroll Factors of the loop being vectorized. ElementCount VF; @@ -372,8 +362,6 @@ /// Hold a pointer to InnerLoopVectorizer to reuse its IR generation methods. InnerLoopVectorizer *ILV; - - VPCallback &Callback; }; /// VPBlockBase is the building block of the Hierarchical Control-Flow Graph. @@ -499,8 +487,6 @@ size_t getNumSuccessors() const { return Successors.size(); } size_t getNumPredecessors() const { return Predecessors.size(); } - void dump() const; - /// An Enclosing Block of a block B is any block containing B, including B /// itself. \return the closest enclosing block starting from "this", which /// has successors. \return the root enclosing block if all enclosing blocks diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp --- a/llvm/lib/Transforms/Vectorize/VPlan.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp @@ -335,9 +335,7 @@ // branch instruction using the condition value from vector lane 0 and dummy // successors. The successors are fixed later when the successor blocks are // visited. - Value *NewCond = State->Callback.getOrCreateVectorValues(IRCBV, 0); - NewCond = State->Builder.CreateExtractElement(NewCond, - State->Builder.getInt32(0)); + Value *NewCond = State->get(CBV, {0, 0}); // Replace the temporary unreachable terminator with the new conditional // branch.