[llvm] [VPlan] Version VPValue names in VPSlotTracker. (PR #81411)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 13 00:56:53 PDT 2024
================
@@ -1373,32 +1362,84 @@ VPInterleavedAccessInfo::VPInterleavedAccessInfo(VPlan &Plan,
visitRegion(Plan.getVectorLoopRegion(), Old2New, IAI);
}
-void VPSlotTracker::assignSlot(const VPValue *V) {
- if (V->getUnderlyingValue())
+void VPSlotTracker::assignSlotOrName(const VPValue *V) {
+ auto *UV = V->getUnderlyingValue();
+ if (!UV) {
+ assert(!VPValue2Name.contains(V) && "VPValue already has a slot!");
+ VPValue2Name[V] = (Twine("vp<%") + Twine(NextSlot) + ">").str();
+ NextSlot++;
return;
- assert(!Slots.contains(V) && "VPValue already has a slot!");
- Slots[V] = NextSlot++;
+ }
+ std::string Name;
+ raw_string_ostream S(Name);
+ UV->printAsOperand(S, false);
+ versionName(V, Name);
}
-void VPSlotTracker::assignSlots(const VPlan &Plan) {
+void VPSlotTracker::assignSlotsOrNames(const VPlan &Plan) {
if (Plan.VFxUF.getNumUsers() > 0)
- assignSlot(&Plan.VFxUF);
- assignSlot(&Plan.VectorTripCount);
+ assignSlotOrName(&Plan.VFxUF);
+ assignSlotOrName(&Plan.VectorTripCount);
if (Plan.BackedgeTakenCount)
- assignSlot(Plan.BackedgeTakenCount);
- assignSlots(Plan.getPreheader());
+ assignSlotOrName(Plan.BackedgeTakenCount);
+ for (VPValue *LI : Plan.VPLiveInsToFree)
+ assignSlotOrName(LI);
+ assignSlotsOrNames(Plan.getPreheader());
ReversePostOrderTraversal<VPBlockDeepTraversalWrapper<const VPBlockBase *>>
RPOT(VPBlockDeepTraversalWrapper<const VPBlockBase *>(Plan.getEntry()));
for (const VPBasicBlock *VPBB :
VPBlockUtils::blocksOnly<const VPBasicBlock>(RPOT))
- assignSlots(VPBB);
+ assignSlotsOrNames(VPBB);
}
-void VPSlotTracker::assignSlots(const VPBasicBlock *VPBB) {
+void VPSlotTracker::assignSlotsOrNames(const VPBasicBlock *VPBB) {
for (const VPRecipeBase &Recipe : *VPBB)
for (VPValue *Def : Recipe.definedValues())
- assignSlot(Def);
+ assignSlotOrName(Def);
+}
+
+void VPSlotTracker::versionName(const VPValue *V, StringRef Name) {
+ assert(!Name.empty() && "Name cannot be empty.");
+ std::string BaseName = (Twine("ir<") + Name + Twine(">")).str();
+
+ // First assign the base name for V.
+ const auto &[A, AssignedInserted] = VPValue2Name.insert({V, BaseName});
+ assert(AssignedInserted && "name assigned already?");
+ if (V->isLiveIn())
----------------
fhahn wrote:
Some live-ins (integer/fp constants) will print to the same string due to the type being stripped. Clarified by only bailing out for those types + a comment
https://github.com/llvm/llvm-project/pull/81411
More information about the llvm-commits
mailing list