From cbe23e33ba0fa5c90b37bef84c810be0f98e32fc Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Sun, 17 Aug 2008 07:54:14 +0000 Subject: [PATCH] I found a better place for this optz'n. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54877 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../Scalar/InstructionCombining.cpp | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 065507f060e..32232a65889 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -5241,20 +5241,6 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { return new ICmpInst(I.getPredicate(), A, B); } - ConstantInt *CI2; - // (icmp u/s (xor A SignBit), C) -> (icmp s/u A, (xor C SignBit)) - if (!I.isEquality() && - match(Op0, m_Xor(m_Value(A), m_ConstantInt(CI2)))) { - if (CI2->getValue().isSignBit()) { - const APInt &SignBit = CI2->getValue(); - ICmpInst::Predicate Pred = I.isSignedPredicate() - ? I.getUnsignedPredicate() - : I.getSignedPredicate(); - return new ICmpInst(Pred, A, - ConstantInt::get(CI->getValue() ^ SignBit)); - } - } - // If we have a icmp le or icmp ge instruction, turn it into the appropriate // icmp lt or icmp gt instruction. This allows us to rely on them being // folded in the code below. @@ -5822,6 +5808,16 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI, else return new ICmpInst(ICmpInst::ICMP_SLT, CompareVal, AddOne(RHS)); } + + // (icmp u/s (xor A SignBit), C) -> (icmp s/u A, (xor C SignBit)) + if (!ICI.isEquality() && XorCST->getValue().isSignBit()) { + const APInt &SignBit = XorCST->getValue(); + ICmpInst::Predicate Pred = ICI.isSignedPredicate() + ? ICI.getUnsignedPredicate() + : ICI.getSignedPredicate(); + return new ICmpInst(Pred, LHSI->getOperand(0), + ConstantInt::get(RHSV ^ SignBit)); + } } break; case Instruction::And: // (icmp pred (and X, AndCST), RHS)