From: Chris Lattner Date: Thu, 22 Nov 2007 23:47:13 +0000 (+0000) Subject: Fix PR1817. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=eec8b9a7d6630d45985e72f5fa396b48ba490d68;p=oota-llvm.git Fix PR1817. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44284 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index e8cd86778ae..c8df4128643 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -3463,7 +3463,12 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) { LHSCC != ICmpInst::ICMP_UGE && LHSCC != ICmpInst::ICMP_ULE && RHSCC != ICmpInst::ICMP_UGE && RHSCC != ICmpInst::ICMP_ULE && LHSCC != ICmpInst::ICMP_SGE && LHSCC != ICmpInst::ICMP_SLE && - RHSCC != ICmpInst::ICMP_SGE && RHSCC != ICmpInst::ICMP_SLE) { + RHSCC != ICmpInst::ICMP_SGE && RHSCC != ICmpInst::ICMP_SLE && + + // Don't try to fold ICMP_SLT + ICMP_ULT. + (ICmpInst::isEquality(LHSCC) || ICmpInst::isEquality(RHSCC) || + ICmpInst::isSignedPredicate(LHSCC) == + ICmpInst::isSignedPredicate(RHSCC))) { // Ensure that the larger constant is on the RHS. ICmpInst::Predicate GT = ICmpInst::isSignedPredicate(LHSCC) ? ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT; diff --git a/test/Transforms/InstCombine/2007-11-22-IcmpCrash.ll b/test/Transforms/InstCombine/2007-11-22-IcmpCrash.ll new file mode 100644 index 00000000000..1f211b65d3f --- /dev/null +++ b/test/Transforms/InstCombine/2007-11-22-IcmpCrash.ll @@ -0,0 +1,16 @@ +; RUN: llvm-as < %s | opt -instcombine -disable-output +; PR1817 + +define i1 @test1(i32 %X) { + %A = icmp slt i32 %X, 10 + %B = icmp ult i32 %X, 10 + %C = and i1 %A, %B + ret i1 %C +} + +define i1 @test2(i32 %X) { + %A = icmp slt i32 %X, 10 + %B = icmp ult i32 %X, 10 + %C = or i1 %A, %B + ret i1 %C +}