From 3105ebfaf7105ffe20530a70194fa8d85d07fb7c Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Sun, 20 Sep 2009 06:24:51 +0000 Subject: Teach the constant folder how to not a cmpinst. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82378 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/ConstantFold.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib') diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index 3f5c7efbb9..1cf7b290c1 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -704,6 +704,20 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context, break; case Instruction::Xor: if (CI2->equalsInt(0)) return C1; // X ^ 0 == X + + if (ConstantExpr *CE1 = dyn_cast(C1)) { + switch (CE1->getOpcode()) { + default: break; + case Instruction::ICmp: + case Instruction::FCmp: + // icmp pred ^ true -> icmp !pred + assert(CI2->equalsInt(1)); + CmpInst::Predicate pred = (CmpInst::Predicate)CE1->getPredicate(); + pred = CmpInst::getInversePredicate(pred); + return ConstantExpr::getCompare(pred, CE1->getOperand(0), + CE1->getOperand(1)); + } + } break; case Instruction::AShr: // ashr (zext C to Ty), C2 -> lshr (zext C, CSA), C2 -- cgit v1.2.3-18-g5258