From c8d73d939fa4fda9c87b3979225d02d63062bd68 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Tue, 10 Nov 2020 22:50:46 +0000 Subject: [PATCH] Revert "[VPlan] Use VPValue def for VPWidenSelectRecipe." This reverts commit a8e50f1c6e7b404aab8fedb972f003a4d6a6434e. This reportedly breaks building the Linux kernel. https://bugs.llvm.org/show_bug.cgi?id=48142 --- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 14 +++++--------- llvm/lib/Transforms/Vectorize/VPlan.cpp | 15 ++------------- llvm/lib/Transforms/Vectorize/VPlan.h | 8 +++++--- llvm/lib/Transforms/Vectorize/VPlanValue.h | 8 +------- llvm/test/Transforms/LoopVectorize/icmp-uniforms.ll | 2 +- 5 files changed, 14 insertions(+), 33 deletions(-) diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 64f46d5..2e19566 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -469,7 +469,7 @@ public: VPTransformState &State); /// Widen a single select instruction within the innermost loop. - void widenSelectInstruction(SelectInst &I, VPValue *VPDef, VPUser &Operands, + void widenSelectInstruction(SelectInst &I, VPUser &Operands, bool InvariantCond, VPTransformState &State); /// Fix the vectorized code, taking care of header phi's, live-outs, and more. @@ -4686,7 +4686,7 @@ void InnerLoopVectorizer::widenCallInstruction(CallInst &I, VPValue *Def, } } -void InnerLoopVectorizer::widenSelectInstruction(SelectInst &I, VPValue *VPDef, +void InnerLoopVectorizer::widenSelectInstruction(SelectInst &I, VPUser &Operands, bool InvariantCond, VPTransformState &State) { @@ -4705,7 +4705,7 @@ void InnerLoopVectorizer::widenSelectInstruction(SelectInst &I, VPValue *VPDef, Value *Op0 = State.get(Operands.getOperand(1), Part); Value *Op1 = State.get(Operands.getOperand(2), Part); Value *Sel = Builder.CreateSelect(Cond, Op0, Op1); - State.set(VPDef, &I, Sel, Part); + VectorLoopValueMap.setVectorValue(&I, Part, Sel); addMetadata(Sel, &I); } } @@ -7640,10 +7640,7 @@ void LoopVectorizationPlanner::buildVPlansWithVPRecipes(ElementCount MinVF, NeedDef.insert(Legal->getPrimaryInduction()); for (auto &Reduction : Legal->getReductionVars()) { NeedDef.insert(Reduction.first); - // VPWidenSelect is a VPValue already, there is no need to add a separate - // VPValue. - if (!isa(Reduction.second.getLoopExitInstr())) - NeedDef.insert(Reduction.second.getLoopExitInstr()); + NeedDef.insert(Reduction.second.getLoopExitInstr()); } } @@ -8003,8 +8000,7 @@ void VPWidenCallRecipe::execute(VPTransformState &State) { } void VPWidenSelectRecipe::execute(VPTransformState &State) { - State.ILV->widenSelectInstruction(*cast(getUnderlyingInstr()), - this, *this, InvariantCond, State); + State.ILV->widenSelectInstruction(Ingredient, *this, InvariantCond, State); } void VPWidenRecipe::execute(VPTransformState &State) { diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp index 46ab2ea..0656854 100644 --- a/llvm/lib/Transforms/Vectorize/VPlan.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp @@ -108,8 +108,6 @@ VPValue *VPRecipeBase::toVPValue() { return V; if (auto *V = dyn_cast(this)) return V; - if (auto *V = dyn_cast(this)) - return V; return nullptr; } @@ -120,8 +118,6 @@ const VPValue *VPRecipeBase::toVPValue() const { return V; if (auto *V = dyn_cast(this)) return V; - if (auto *V = dyn_cast(this)) - return V; return nullptr; } @@ -847,15 +843,8 @@ void VPWidenCallRecipe::print(raw_ostream &O, const Twine &Indent, void VPWidenSelectRecipe::print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const { - O << "\"WIDEN-SELECT "; - printAsOperand(O, SlotTracker); - O << " = select "; - getOperand(0)->printAsOperand(O, SlotTracker); - O << ", "; - getOperand(1)->printAsOperand(O, SlotTracker); - O << ", "; - getOperand(2)->printAsOperand(O, SlotTracker); - O << (InvariantCond ? " (condition is loop invariant)" : ""); + O << "\"WIDEN-SELECT" << VPlanIngredient(&Ingredient) + << (InvariantCond ? " (condition is loop invariant)" : ""); } void VPWidenRecipe::print(raw_ostream &O, const Twine &Indent, diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h index 4c7982c..c70d82b 100644 --- a/llvm/lib/Transforms/Vectorize/VPlan.h +++ b/llvm/lib/Transforms/Vectorize/VPlan.h @@ -877,7 +877,10 @@ public: }; /// A recipe for widening select instructions. -class VPWidenSelectRecipe : public VPRecipeBase, public VPValue, public VPUser { +class VPWidenSelectRecipe : public VPRecipeBase, public VPUser { +private: + /// Hold the select to be widened. + SelectInst &Ingredient; /// Is the condition of the select loop invariant? bool InvariantCond; @@ -886,8 +889,7 @@ public: template VPWidenSelectRecipe(SelectInst &I, iterator_range Operands, bool InvariantCond) - : VPRecipeBase(VPRecipeBase::VPWidenSelectSC), - VPValue(VPValue::VPVWidenSelectSC, &I), VPUser(Operands), + : VPRecipeBase(VPWidenSelectSC), VPUser(Operands), Ingredient(I), InvariantCond(InvariantCond) {} ~VPWidenSelectRecipe() override = default; diff --git a/llvm/lib/Transforms/Vectorize/VPlanValue.h b/llvm/lib/Transforms/Vectorize/VPlanValue.h index ce3b4b1..503abec 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanValue.h +++ b/llvm/lib/Transforms/Vectorize/VPlanValue.h @@ -78,13 +78,7 @@ public: /// are actually instantiated. Values of this enumeration are kept in the /// SubclassID field of the VPValue objects. They are used for concrete /// type identification. - enum { - VPValueSC, - VPInstructionSC, - VPMemoryInstructionSC, - VPVWidenCallSC, - VPVWidenSelectSC - }; + enum { VPValueSC, VPInstructionSC, VPMemoryInstructionSC, VPVWidenCallSC }; VPValue(Value *UV = nullptr) : VPValue(VPValueSC, UV) {} VPValue(const VPValue &) = delete; diff --git a/llvm/test/Transforms/LoopVectorize/icmp-uniforms.ll b/llvm/test/Transforms/LoopVectorize/icmp-uniforms.ll index e8e80d1..a5b5743 100644 --- a/llvm/test/Transforms/LoopVectorize/icmp-uniforms.ll +++ b/llvm/test/Transforms/LoopVectorize/icmp-uniforms.ll @@ -39,7 +39,7 @@ for.end: ; CHECK-NEXT: "loop:\n" + ; CHECK-NEXT: "WIDEN-INDUCTION %iv = phi 0, %iv.next\l" + ; CHECK-NEXT: "WIDEN\l"" %cond0 = icmp %iv, 13\l" + -; CHECK-NEXT: "WIDEN-SELECT ir<%s> = select ir<%cond0>, ir<10>, ir<20>\l" +; CHECK-NEXT: "WIDEN-SELECT%s = select %cond0, 10, 20\l" ; CHECK-NEXT: ] define void @test() { entry: -- 2.7.4