[llvm] b2f05fa - [JumpThreading] Remove extraneous calls to setEdgeProbability
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 27 21:13:50 PDT 2020
Author: Kazu Hirata
Date: 2020-10-27T21:12:54-07:00
New Revision: b2f05fae80b0c1a307a9e257157a0d70e6623eb8
URL: https://github.com/llvm/llvm-project/commit/b2f05fae80b0c1a307a9e257157a0d70e6623eb8
DIFF: https://github.com/llvm/llvm-project/commit/b2f05fae80b0c1a307a9e257157a0d70e6623eb8.diff
LOG: [JumpThreading] Remove extraneous calls to setEdgeProbability
This patch removes extraneous calls to setEdgeProbability introduced
in c91487769d80487eba1712a7a172a1c8977a9b4f.
The follow-up patch, a7b662d0f4098371b96ce4446fb0eba79b0b649f, has
since fixed BranchProbabilityInfo::eraseBlock, so we don't need to
worry about getting stale values from getEdgeProbability.
Also, since getEdgeProbability(BB, BB->getSingleSuccessor()) returns
edge probability 1/1 by default for BB with exactly one successor
edge, we don't need to explicitly call setEdgeProbability.
This patch introduces almost no functional change, but we do end up
reducing debug messages from setEdgeProbability.
Differential Revision: https://reviews.llvm.org/D90284
Added:
Modified:
llvm/lib/Transforms/Scalar/JumpThreading.cpp
Removed:
llvm/test/Transforms/JumpThreading/thread-prob-1.ll
llvm/test/Transforms/JumpThreading/thread-prob-2.ll
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
index 730b6f02858c..12deaaa0af58 100644
--- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
@@ -2432,15 +2432,8 @@ BasicBlock *JumpThreadingPass::SplitBlockPreds(BasicBlock *BB,
if (HasProfileData) // Update frequencies between Pred -> NewBB.
NewBBFreq += FreqMap.lookup(Pred);
}
- if (HasProfileData) {
- // Apply the summed frequency to NewBB.
+ if (HasProfileData) // Apply the summed frequency to NewBB.
BFI->setBlockFreq(NewBB, NewBBFreq.getFrequency());
-
- // NewBB has exactly one successor.
- SmallVector<BranchProbability, 1> BBSuccProbs;
- BBSuccProbs.push_back(BranchProbability::getOne());
- BPI->setEdgeProbability(NewBB, BBSuccProbs);
- }
}
DTU->applyUpdatesPermissive(Updates);
@@ -2513,11 +2506,6 @@ void JumpThreadingPass::UpdateBlockFreqAndEdgeWeight(BasicBlock *PredBB,
// Update edge probabilities in BPI.
BPI->setEdgeProbability(BB, BBSuccProbs);
- // NewBB has exactly one successor.
- SmallVector<BranchProbability, 1> NewBBSuccProbs;
- NewBBSuccProbs.push_back(BranchProbability::getOne());
- BPI->setEdgeProbability(NewBB, NewBBSuccProbs);
-
// Update the profile metadata as well.
//
// Don't do this if the profile of the transformed blocks was statically
@@ -2728,13 +2716,6 @@ void JumpThreadingPass::UnfoldSelectInstr(BasicBlock *Pred, BasicBlock *BB,
PHINode *Phi = dyn_cast<PHINode>(BI); ++BI)
if (Phi != SIUse)
Phi->addIncoming(Phi->getIncomingValueForBlock(Pred), NewBB);
-
- if (HasProfileData) {
- // NewBB has exactly one successor.
- SmallVector<BranchProbability, 1> BBSuccProbs;
- BBSuccProbs.push_back(BranchProbability::getOne());
- BPI->setEdgeProbability(NewBB, BBSuccProbs);
- }
}
bool JumpThreadingPass::TryToUnfoldSelect(SwitchInst *SI, BasicBlock *BB) {
diff --git a/llvm/test/Transforms/JumpThreading/thread-prob-1.ll b/llvm/test/Transforms/JumpThreading/thread-prob-1.ll
deleted file mode 100644
index 9069b3aa6b14..000000000000
--- a/llvm/test/Transforms/JumpThreading/thread-prob-1.ll
+++ /dev/null
@@ -1,42 +0,0 @@
-; RUN: opt -debug-only=branch-prob -jump-threading -S %s 2>&1 | FileCheck %s
-
-; Make sure that we set the branch probability for the newly created
-; basic block.
-
-define void @foo(i1 %arg1, i1 %arg2, i32 %arg3) !prof !0 !PGOFuncName !1 {
-entry:
- call void @bar(i32 0)
- br i1 %arg1, label %bb3, label %bb1, !prof !2
-
-bb1:
- call void @bar(i32 1)
- br i1 %arg2, label %bb2, label %bb3, !prof !3
-
-bb2:
- call void @bar(i32 2)
- br label %bb3
-
-bb3:
-; CHECK: set edge bb3.thr_comm -> 0 successor probability to 0x80000000 / 0x80000000
-%ptr = phi i32 [ 0, %bb1 ], [ 0, %entry ], [ %arg3, %bb2 ]
- call void @bar(i32 3)
- %bool = icmp eq i32 %ptr, 0
- br i1 %bool, label %exit, label %bb4, !prof !4
-; CHECK: set edge bb3.thread -> 0 successor probability to 0x80000000 / 0x80000000
-
-bb4:
- call void @bar(i32 %ptr)
- br label %exit
-
-exit:
- ret void
-}
-
-declare void @bar(i32)
-
-!0 = !{!"function_entry_count", i64 15985}
-!1 = !{!"foo:foo"}
-!2 = !{!"branch_weights", i32 15973, i32 36865}
-!3 = !{!"branch_weights", i32 2957, i32 5798}
-!4 = !{!"branch_weights", i32 1807, i32 35058}
-!5 = !{!"branch_weights", i32 38, i32 287958}
diff --git a/llvm/test/Transforms/JumpThreading/thread-prob-2.ll b/llvm/test/Transforms/JumpThreading/thread-prob-2.ll
deleted file mode 100644
index fbf62405349d..000000000000
--- a/llvm/test/Transforms/JumpThreading/thread-prob-2.ll
+++ /dev/null
@@ -1,32 +0,0 @@
-; RUN: opt -debug-only=branch-prob -jump-threading -S %s 2>&1 | FileCheck %s
-
-; Make sure that we set the branch probability for the newly created
-; basic block.
-
-define void @foo(i32 %v0, i1 %arg2) !prof !0 !PGOFuncName !1 {
-entry:
- %bool1 = icmp eq i32 %v0, 0
- br i1 %bool1, label %bb2, label %bb1, !prof !2
-
-bb1:
- %sel = select i1 %arg2, i32 %v0, i32 0, !prof !3
- br label %bb2
-; CHECK: set edge select.unfold -> 0 successor probability to 0x80000000 / 0x80000000
-
-bb2:
- %phi = phi i32 [ %sel, %bb1 ], [ 0, %entry ]
- %bool2 = icmp eq i32 %phi, 0
- br i1 %bool2, label %exit, label %bb3, !prof !4
-
-bb3:
- br label %exit
-
-exit:
- ret void
-}
-
-!0 = !{!"function_entry_count", i64 15985}
-!1 = !{!"foo.cpp:foo"}
-!2 = !{!"branch_weights", i32 0, i32 36865}
-!3 = !{!"branch_weights", i32 35058, i32 1807}
-!4 = !{!"branch_weights", i32 1807, i32 35058}
More information about the llvm-commits
mailing list