1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

[InstCombine] Replace two calls to getNumUses() with !hasNUsesOrMore

We were calling getNumUses to check for 1 or 2 uses. But getNumUses is linear in the number of uses. We can instead use !hasNUsesOrMore(3) which will stop the linear scan as soon as it determines there are at least 3 uses even if there are more.

llvm-svn: 340939
This commit is contained in:
Craig Topper 2018-08-29 17:09:21 +00:00
parent ff55c20b91
commit f60fdf7989

View File

@ -1822,7 +1822,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
// MIN(~a, ~b) -> ~MAX(a, b)
Value *A, *B;
if (match(LHS, m_Not(m_Value(A))) && match(RHS, m_Not(m_Value(B))) &&
(LHS->getNumUses() <= 2 || RHS->getNumUses() <= 2)) {
(!LHS->hasNUsesOrMore(3) || !RHS->hasNUsesOrMore(3))) {
CmpInst::Predicate InvertedPred = getInverseMinMaxPred(SPF);
Value *InvertedCmp = Builder.CreateICmp(InvertedPred, A, B);
Value *NewSel = Builder.CreateSelect(InvertedCmp, A, B);