From f947b3edb5a2dd687fe65dcc38afebeeef811762 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Mon, 6 Aug 2007 20:04:16 +0000 Subject: It's safe to fold not of fcmp. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40870 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/InstructionCombining.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib/Transforms/Scalar/InstructionCombining.cpp') diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 15dec4fbcf..d8df139efa 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -4134,12 +4134,17 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { if (ConstantInt *RHS = dyn_cast(Op1)) { - // xor (icmp A, B), true = not (icmp A, B) = !icmp A, B - if (ICmpInst *ICI = dyn_cast(Op0)) - if (RHS == ConstantInt::getTrue() && ICI->hasOneUse()) + // xor (cmp A, B), true = not (cmp A, B) = !cmp A, B + if (RHS == ConstantInt::getTrue() && Op0->hasOneUse()) { + if (ICmpInst *ICI = dyn_cast(Op0)) return new ICmpInst(ICI->getInversePredicate(), ICI->getOperand(0), ICI->getOperand(1)); + if (FCmpInst *FCI = dyn_cast(Op0)) + return new FCmpInst(FCI->getInversePredicate(), + FCI->getOperand(0), FCI->getOperand(1)); + } + if (BinaryOperator *Op0I = dyn_cast(Op0)) { // ~(c-X) == X-c-1 == X+(-c-1) if (Op0I->getOpcode() == Instruction::Sub && RHS->isAllOnesValue()) -- cgit v1.2.3-70-g09d2