Author: lattner Date: Thu Nov 22 17:47:13 2007 New Revision: 44284 URL: http://llvm.org/viewvc/llvm-project?rev=44284&view=rev Log: Fix PR1817.
Added: llvm/trunk/test/Transforms/InstCombine/2007-11-22-IcmpCrash.ll Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=44284&r1=44283&r2=44284&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Thu Nov 22 17:47:13 2007 @@ -3463,7 +3463,12 @@ 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; Added: llvm/trunk/test/Transforms/InstCombine/2007-11-22-IcmpCrash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2007-11-22-IcmpCrash.ll?rev=44284&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/2007-11-22-IcmpCrash.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/2007-11-22-IcmpCrash.ll Thu Nov 22 17:47:13 2007 @@ -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 +} _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits