Skip to content

Commit 2a05971

Browse files
committed
[SLP]Add index of the node to the short name output.
Improves debugging experience, does nothing with the functionality.
1 parent 4189add commit 2a05971

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,11 @@ static unsigned getNumElems(unsigned Size, unsigned PartNumElems,
309309

310310
#if !defined(NDEBUG)
311311
/// Print a short descriptor of the instruction bundle suitable for debug output.
312-
static std::string shortBundleName(ArrayRef<Value *> VL) {
312+
static std::string shortBundleName(ArrayRef<Value *> VL, int Idx = -1) {
313313
std::string Result;
314314
raw_string_ostream OS(Result);
315+
if (Idx >= 0)
316+
OS << "Idx: " << Idx << ", ";
315317
OS << "n=" << VL.size() << " [" << *VL.front() << ", ..]";
316318
OS.flush();
317319
return Result;
@@ -10639,7 +10641,7 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef<Value *> VectorizedVals) {
1063910641
// Some gather nodes might be absolutely the same as some vectorizable
1064010642
// nodes after reordering, need to handle it.
1064110643
LLVM_DEBUG(dbgs() << "SLP: Adding cost 0 for bundle "
10642-
<< shortBundleName(TE.Scalars) << ".\n"
10644+
<< shortBundleName(TE.Scalars, TE.Idx) << ".\n"
1064310645
<< "SLP: Current total cost = " << Cost << "\n");
1064410646
continue;
1064510647
}
@@ -10648,7 +10650,7 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef<Value *> VectorizedVals) {
1064810650
InstructionCost C = getEntryCost(&TE, VectorizedVals, CheckedExtracts);
1064910651
Cost += C;
1065010652
LLVM_DEBUG(dbgs() << "SLP: Adding cost " << C << " for bundle "
10651-
<< shortBundleName(TE.Scalars) << ".\n"
10653+
<< shortBundleName(TE.Scalars, TE.Idx) << ".\n"
1065210654
<< "SLP: Current total cost = " << Cost << "\n");
1065310655
}
1065410656

@@ -12638,10 +12640,8 @@ ResTy BoUpSLP::processBuildVector(const TreeEntry *E, Type *ScalarTy,
1263812640
Entries.front().front()->isSame(E->Scalars)) {
1263912641
// Perfect match in the graph, will reuse the previously vectorized
1264012642
// node. Cost is 0.
12641-
LLVM_DEBUG(
12642-
dbgs()
12643-
<< "SLP: perfect diamond match for gather bundle "
12644-
<< shortBundleName(E->Scalars) << ".\n");
12643+
LLVM_DEBUG(dbgs() << "SLP: perfect diamond match for gather bundle "
12644+
<< shortBundleName(E->Scalars, E->Idx) << ".\n");
1264512645
// Restore the mask for previous partially matched values.
1264612646
Mask.resize(E->Scalars.size());
1264712647
const TreeEntry *FrontTE = Entries.front().front();

llvm/test/Transforms/SLPVectorizer/SystemZ/SLP-cmp-cost-query.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ define void @fun(ptr nocapture, i32 zeroext) local_unnamed_addr #0 {
3131
._crit_edge: ; preds = %.lr.ph
3232
ret void
3333

34-
; CHECK: SLP: Adding cost -1 for bundle n=2 [ %4 = icmp ult i32 %2, %1, ..]
34+
; CHECK: SLP: Adding cost -1 for bundle Idx: 3, n=2 [ %4 = icmp ult i32 %2, %1, ..]
3535
}
3636

0 commit comments

Comments
 (0)