diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 334e05d0814f65..636306eb58994e 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -9130,18 +9130,10 @@ VPlanPtr LoopVectorizationPlanner::buildVPlanWithVPRecipes( } } - std::string PlanName; - raw_string_ostream RSO(PlanName); - ElementCount VF = Range.Start; - Plan->addVF(VF); - RSO << "Initial VPlan for VF={" << VF; - for (VF *= 2; ElementCount::isKnownLT(VF, Range.End); VF *= 2) { + for (ElementCount VF = Range.Start; ElementCount::isKnownLT(VF, Range.End); + VF *= 2) Plan->addVF(VF); - RSO << "," << VF; - } - RSO << "},UF>=1"; - RSO.flush(); - Plan->setName(PlanName); + Plan->setName("Initial VPlan"); // From this point onwards, VPlan-to-VPlan transformations may change the plan // in ways that accessing values using original IR values is incorrect. diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp index a3175a05b75f8f..a425504ddf54a5 100644 --- a/llvm/lib/Transforms/Vectorize/VPlan.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp @@ -757,7 +757,7 @@ LLVM_DUMP_METHOD void VPlan::print(raw_ostream &O) const { VPSlotTracker SlotTracker(this); - O << "VPlan '" << Name << "' {"; + O << "VPlan '" << getName() << "' {"; if (VectorTripCount.getNumUsers() > 0) { O << "\nLive-in "; @@ -789,6 +789,20 @@ void VPlan::print(raw_ostream &O) const { O << "}\n"; } +std::string VPlan::getName() const { + std::string Out; + raw_string_ostream RSO(Out); + RSO << Name; + if (!VFs.empty()) { + RSO << " for VF={" << VFs[0]; + for (ElementCount VF : drop_begin(VFs)) + RSO << "," << VF; + RSO << "},UF>=1"; + } + + return Out; +} + LLVM_DUMP_METHOD void VPlan::printDOT(raw_ostream &O) const { VPlanPrinter Printer(O, *this); diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h index 5c7f7291e38c2e..f76931e675bf58 100644 --- a/llvm/lib/Transforms/Vectorize/VPlan.h +++ b/llvm/lib/Transforms/Vectorize/VPlan.h @@ -2601,7 +2601,8 @@ class VPlan { bool hasScalarVFOnly() const { return VFs.size() == 1 && VFs[0].isScalar(); } - const std::string &getName() const { return Name; } + /// Return a string with the name of the plan and the applicable VFs and UFs. + std::string getName() const; void setName(const Twine &newName) { Name = newName.str(); }