[llvm] r343550 - [SimplifyCFG] Use Value::hasNUses instead of 'getNumUses() =='. NFCI
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 1 16:09:53 PDT 2018
Author: ctopper
Date: Mon Oct 1 16:09:52 2018
New Revision: 343550
URL: http://llvm.org/viewvc/llvm-project?rev=343550&view=rev
Log:
[SimplifyCFG] Use Value::hasNUses instead of 'getNumUses() =='. NFCI
getNumUses is linear in the number of uses. Since we're looking for a specific use count, we can use hasNUses which will stop as soon as it determines there are more than N uses instead of walking all of them.
Modified:
llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=343550&r1=343549&r2=343550&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Mon Oct 1 16:09:52 2018
@@ -2001,7 +2001,7 @@ static bool SpeculativelyExecuteBB(Branc
I = SinkCandidateUseCounts.begin(),
E = SinkCandidateUseCounts.end();
I != E; ++I)
- if (I->first->getNumUses() == I->second) {
+ if (I->first->hasNUses(I->second)) {
++SpeculationCost;
if (SpeculationCost > 1)
return false;
More information about the llvm-commits
mailing list