[llvm] [LV] Fix for `VPValue` dump method (PR #94272)

Kolya Panchenko via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 3 12:27:49 PDT 2024


https://github.com/nikolaypanchenko created https://github.com/llvm/llvm-project/pull/94272

The logic of getting `VPlan` from a `VPValue` should be in-sync with `VPSlotTracker::getOrCreateName`'s logic

>From 5ea251170563a65907ef8dd88dea8142b4e9c992 Mon Sep 17 00:00:00 2001
From: Kolya Panchenko <kolya.panchenko at sifive.com>
Date: Mon, 3 Jun 2024 12:25:12 -0700
Subject: [PATCH] [LV] Fix for `VPValue` dump method

The logic of getting `VPlan` from a `VPValue` should be in-sync with
`VPSlotTracker::getOrCreateName`'s logic
---
 llvm/lib/Transforms/Vectorize/VPlan.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index f17be451e6846..b22b543d071ed 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -58,9 +58,9 @@ extern cl::opt<bool> EnableVPlanNativePath;
 
 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
 raw_ostream &llvm::operator<<(raw_ostream &OS, const VPValue &V) {
-  const VPInstruction *Instr = dyn_cast<VPInstruction>(&V);
-  VPSlotTracker SlotTracker(
-      (Instr && Instr->getParent()) ? Instr->getParent()->getPlan() : nullptr);
+  const VPRecipeBase *R = V.getDefiningRecipe();
+  VPSlotTracker SlotTracker((R && R->getParent()) ? R->getParent()->getPlan()
+                                                  : nullptr);
   V.print(OS, SlotTracker);
   return OS;
 }
@@ -1381,7 +1381,7 @@ void VPSlotTracker::assignNames(const VPlan &Plan) {
   if (Plan.VFxUF.getNumUsers() > 0)
     assignName(&Plan.VFxUF);
   assignName(&Plan.VectorTripCount);
-  if (Plan.BackedgeTakenCount)
+  if (Plan.BackedgeTakenCount && Plan.BackedgeTakenCount->getNumUsers() > 0)
     assignName(Plan.BackedgeTakenCount);
   for (VPValue *LI : Plan.VPLiveInsToFree)
     assignName(LI);



More information about the llvm-commits mailing list