-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[VPlan] Version VPValue names in VPSlotTracker. #81411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5c96c8d
d10aab4
d72a7b3
9a6c23c
162222a
5616888
1800156
a73dd0a
d731147
84117c2
b9d3383
ef35517
4acf22a
529d103
857d925
ad26bd1
8b30332
a0b4684
4d0df2d
55da2ab
3b85f8c
a407b20
590690b
3995276
21b8b67
4496d93
16502ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
#include "llvm/ADT/DenseMap.h" | ||
#include "llvm/ADT/STLExtras.h" | ||
#include "llvm/ADT/SmallVector.h" | ||
#include "llvm/ADT/StringMap.h" | ||
#include "llvm/ADT/TinyPtrVector.h" | ||
#include "llvm/ADT/iterator_range.h" | ||
|
||
|
@@ -443,29 +444,36 @@ class VPDef { | |
class VPlan; | ||
class VPBasicBlock; | ||
|
||
/// This class can be used to assign consecutive numbers to all VPValues in a | ||
/// VPlan and allows querying the numbering for printing, similar to the | ||
/// This class can be used to assign names to VPValues. For VPValues without | ||
/// underlying value, assign consecutive numbers and use those as names (wrapped | ||
/// in vp<>). Otherwise, use the name from the underlying value (wrapped in | ||
/// ir<>), appending a .V version number if there are multiple uses of the same | ||
/// name. Allows querying names for VPValues for printing, similar to the | ||
/// ModuleSlotTracker for IR values. | ||
class VPSlotTracker { | ||
DenseMap<const VPValue *, unsigned> Slots; | ||
/// Keep track of versioned names assigned to VPValues with underlying IR | ||
/// values. | ||
DenseMap<const VPValue *, std::string> VPValue2Name; | ||
/// Keep track of the next number to use to version the base name. | ||
StringMap<unsigned> BaseName2Version; | ||
|
||
/// Number to assign to the next VPValue without underlying value. | ||
unsigned NextSlot = 0; | ||
|
||
void assignSlot(const VPValue *V); | ||
void assignSlots(const VPlan &Plan); | ||
void assignSlots(const VPBasicBlock *VPBB); | ||
void assignName(const VPValue *V); | ||
void assignNames(const VPlan &Plan); | ||
void assignNames(const VPBasicBlock *VPBB); | ||
|
||
public: | ||
VPSlotTracker(const VPlan *Plan = nullptr) { | ||
if (Plan) | ||
assignSlots(*Plan); | ||
assignNames(*Plan); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Worth documenting? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adde documentation, thanks! |
||
unsigned getSlot(const VPValue *V) const { | ||
auto I = Slots.find(V); | ||
if (I == Slots.end()) | ||
return -1; | ||
return I->second; | ||
} | ||
/// Returns the name assigned to \p V, if there is one, otherwise try to | ||
/// construct one from the underlying value, if there's one; else return | ||
/// <badref>. | ||
std::string getOrCreateName(const VPValue *V) const; | ||
}; | ||
|
||
} // namespace llvm | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -986,8 +986,8 @@ define void @sinking_requires_duplication(ptr %addr) { | |
; CHECK-NEXT: Successor(s): pred.store.if, pred.store.continue | ||
; CHECK-EMPTY: | ||
; CHECK-NEXT: pred.store.if: | ||
; CHECK-NEXT: REPLICATE ir<%gep> = getelementptr ir<%addr>, vp<[[STEPS]]> | ||
; CHECK-NEXT: REPLICATE store ir<1.000000e+01>, ir<%gep> | ||
; CHECK-NEXT: REPLICATE ir<%gep>.1 = getelementptr ir<%addr>, vp<[[STEPS]]> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, this naming should clarify the relation to the original IR. It hopefully also clarifies the relation to the generated IR? |
||
; CHECK-NEXT: REPLICATE store ir<1.000000e+01>, ir<%gep>.1 | ||
; CHECK-NEXT: Successor(s): pred.store.continue | ||
; CHECK-EMPTY: | ||
; CHECK-NEXT: pred.store.continue: | ||
|
@@ -1129,8 +1129,8 @@ define void @ptr_induction_remove_dead_recipe(ptr %start, ptr %end) { | |
; CHECK-NEXT: Successor(s): pred.store.if, pred.store.continue | ||
; CHECK-EMPTY: | ||
; CHECK-NEXT: pred.store.if: | ||
; CHECK-NEXT: REPLICATE ir<%ptr.iv.next> = getelementptr inbounds vp<[[PTR_IV]]>, ir<-1> | ||
; CHECK-NEXT: REPLICATE store ir<95>, ir<%ptr.iv.next> | ||
; CHECK-NEXT: REPLICATE ir<%ptr.iv.next>.1 = getelementptr inbounds vp<[[PTR_IV]]>, ir<-1> | ||
; CHECK-NEXT: REPLICATE store ir<95>, ir<%ptr.iv.next>.1 | ||
; CHECK-NEXT: Successor(s): pred.store.continue | ||
; CHECK-EMPTY: | ||
; CHECK-NEXT: pred.store.continue: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth adding a comment, e.g.,
// Use the name of the underlying Value, wrapped in "ir<>", and versioned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added, thanks!