From 2f00acbb71c83bf9685cbef3e70b9474c793ffdb Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Tue, 21 Aug 2018 19:17:00 +0000 Subject: [PATCH] [InstCombine] Pull simple checks above a more complicated one. NFCI I'm assuming its easier to make sure the RHS of an XOR is all ones than it is to check for the many select patterns we have. So lets check that first. Same with the one use check. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340321 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp index a2dea10c565..e631e7396b1 100644 --- a/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ b/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp @@ -2919,12 +2919,10 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { // %res = select i1 %cmp2, i32 %x, i32 %noty // // Same is applicable for smin/umax/umin. - { + if (match(Op1, m_AllOnes()) && Op0->hasOneUse()) { Value *LHS, *RHS; SelectPatternFlavor SPF = matchSelectPattern(Op0, LHS, RHS).Flavor; - if (Op0->hasOneUse() && SelectPatternResult::isMinOrMax(SPF) && - match(Op1, m_AllOnes())) { - + if (SelectPatternResult::isMinOrMax(SPF)) { Value *X; if (match(RHS, m_Not(m_Value(X)))) std::swap(RHS, LHS); -- 2.11.0