summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2018-03-12 18:46:05 +0000
committerCraig Topper <craig.topper@intel.com>2018-03-12 18:46:05 +0000
commitee99aa4dd086b907bf4552f5b368a73e5f087655 (patch)
tree7a4bb18472ebefa218ea14a4ac9b11fbf0de289c /llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
parent3b4ad9c12d2e0c4ac67b2f0661aa0072dd0b64cb (diff)
downloadbcm5719-llvm-ee99aa4dd086b907bf4552f5b368a73e5f087655.tar.gz
bcm5719-llvm-ee99aa4dd086b907bf4552f5b368a73e5f087655.zip
[InstCombine] Replace calls to getNumUses with hasNUses or hasNUsesOrMore
getNumUses is a linear time operation. It traverses the user linked list to the end and counts as it goes. Since we are only interested in small constant counts, we should use hasNUses or hasNUsesMore more that terminate the traversal as soon as it can provide the answer. There are still two other locations in InstCombine, but changing those would force a rebase of D44266 which if accepted would remove them. Differential Revision: https://reviews.llvm.org/D44398 llvm-svn: 327315
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index de1971ca542..1f89ca635a9 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -1333,7 +1333,7 @@ static Instruction *factorizeMinMaxTree(SelectPatternFlavor SPF, Value *LHS,
// the select.
Value *MinMaxOp = nullptr;
Value *ThirdOp = nullptr;
- if (LHS->getNumUses() <= 2 && RHS->getNumUses() > 2) {
+ if (!LHS->hasNUsesOrMore(3) && RHS->hasNUsesOrMore(3)) {
// If the LHS is only used in this chain and the RHS is used outside of it,
// reuse the RHS min/max because that will eliminate the LHS.
if (D == A || C == A) {
@@ -1347,7 +1347,7 @@ static Instruction *factorizeMinMaxTree(SelectPatternFlavor SPF, Value *LHS,
MinMaxOp = RHS;
ThirdOp = A;
}
- } else if (RHS->getNumUses() <= 2) {
+ } else if (!RHS->hasNUsesOrMore(3)) {
// Reuse the LHS. This will eliminate the RHS.
if (D == A || D == B) {
// min(min(a, b), min(c, a)) --> min(min(a, b), c)
OpenPOWER on IntegriCloud