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 @@ -465,8 +465,7 @@ VPTransformState &State); /// Widen a single call instruction within the innermost loop. - void widenCallInstruction(CallInst &I, VPUser &ArgOperands, - VPTransformState &State); + void widenCallInstruction(CallInst &I, VPDef &Def, VPTransformState &State); /// Widen a single select instruction within the innermost loop. void widenSelectInstruction(SelectInst &I, VPUser &Operands, @@ -4616,7 +4615,7 @@ } // end of switch. } -void InnerLoopVectorizer::widenCallInstruction(CallInst &I, VPUser &ArgOperands, +void InnerLoopVectorizer::widenCallInstruction(CallInst &I, VPDef &Def, VPTransformState &State) { assert(!isa(I) && "DbgInfoIntrinsic should have been dropped during VPlan construction"); @@ -4643,7 +4642,7 @@ for (unsigned Part = 0; Part < UF; ++Part) { SmallVector Args; - for (auto &I : enumerate(ArgOperands.operands())) { + for (auto &I : enumerate(Def.operands())) { // Some intrinsics have a scalar argument - don't replace it with a // vector. Value *Arg; @@ -4680,7 +4679,7 @@ if (isa(V)) V->copyFastMathFlags(CI); - VectorLoopValueMap.setVectorValue(&I, Part, V); + State.set(Def.getVPValue(), &I, V, Part); addMetadata(V, &I); } } @@ -7987,7 +7986,8 @@ } void VPWidenCallRecipe::execute(VPTransformState &State) { - State.ILV->widenCallInstruction(Ingredient, *this, State); + State.ILV->widenCallInstruction(*cast(getUnderlyingInstr()), *this, + State); } void VPWidenSelectRecipe::execute(VPTransformState &State) { 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 @@ -841,14 +841,14 @@ }; /// A recipe for widening Call instructions. -class VPWidenCallRecipe : public VPRecipeBase, public VPUser { - /// Hold the call to be widened. - CallInst &Ingredient; +class VPWidenCallRecipe : public VPRecipeBase, public VPDef { public: template VPWidenCallRecipe(CallInst &I, iterator_range CallArguments) - : VPRecipeBase(VPWidenCallSC), VPUser(CallArguments), Ingredient(I) {} + : VPRecipeBase(VPRecipeBase::VPWidenCallSC), VPDef(CallArguments) { + new VPValue(&I, this); + } ~VPWidenCallRecipe() override = default; 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 @@ -112,6 +112,8 @@ return V; if (auto *V = dyn_cast(this)) return V; + if (auto *V = dyn_cast(this)) + return V->getVPValue(); return nullptr; } @@ -120,6 +122,8 @@ return V; if (auto *V = dyn_cast(this)) return V; + if (auto *V = dyn_cast(this)) + return V->getVPValue(); return nullptr; } @@ -828,7 +832,7 @@ void VPWidenCallRecipe::print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const { - O << "\"WIDEN-CALL " << VPlanIngredient(&Ingredient); + O << "\"WIDEN-CALL " << VPlanIngredient(getUnderlyingInstr()); } void VPWidenSelectRecipe::print(raw_ostream &O, const Twine &Indent, diff --git a/llvm/lib/Transforms/Vectorize/VPlanValue.h b/llvm/lib/Transforms/Vectorize/VPlanValue.h --- a/llvm/lib/Transforms/Vectorize/VPlanValue.h +++ b/llvm/lib/Transforms/Vectorize/VPlanValue.h @@ -83,7 +83,7 @@ /// 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 }; + enum { VPValueSC, VPInstructionSC, VPMemoryInstructionSC, VPVWidenCallSC }; VPValue(Value *UV = nullptr, VPDef *Def = nullptr) : VPValue(VPValueSC, UV, Def) {}