[llvm-commits] [llvm] r56834 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2008-09-29-FoldingOr.ll
Nick Lewycky
nicholas at mxc.ca
Mon Sep 29 23:08:34 PDT 2008
Author: nicholas
Date: Tue Sep 30 01:08:34 2008
New Revision: 56834
URL: http://llvm.org/viewvc/llvm-project?rev=56834&view=rev
Log:
Fix misoptimization of: xor i1 (icmp eq (X, C1), icmp s[lg]t (X, C2))
Added:
llvm/trunk/test/Transforms/InstCombine/2008-09-29-FoldingOr.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=56834&r1=56833&r2=56834&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Tue Sep 30 01:08:34 2008
@@ -3023,7 +3023,7 @@
I.setOperand(1, RHSNeg);
return &I;
}
-
+
// If the sign bits of both operands are zero (i.e. we can prove they are
// unsigned inputs), turn this into a urem.
if (I.getType()->isInteger()) {
@@ -4205,7 +4205,8 @@
// Ensure that the larger constant is on the RHS.
ICmpInst *LHS = cast<ICmpInst>(Op0);
bool NeedsSwap;
- if (ICmpInst::isSignedPredicate(LHSCC))
+ if (ICmpInst::isEquality(LHSCC) ? ICmpInst::isSignedPredicate(RHSCC)
+ : ICmpInst::isSignedPredicate(LHSCC))
NeedsSwap = LHSCst->getValue().sgt(RHSCst->getValue());
else
NeedsSwap = LHSCst->getValue().ugt(RHSCst->getValue());
Added: llvm/trunk/test/Transforms/InstCombine/2008-09-29-FoldingOr.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2008-09-29-FoldingOr.ll?rev=56834&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/2008-09-29-FoldingOr.ll (added)
+++ llvm/trunk/test/Transforms/InstCombine/2008-09-29-FoldingOr.ll Tue Sep 30 01:08:34 2008
@@ -0,0 +1,10 @@
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {or i1}
+; PR2844
+
+define i32 @test(i32 %p_74) {
+ %A = icmp eq i32 %p_74, 0 ; <i1> [#uses=1]
+ %B = icmp slt i32 %p_74, -638208501 ; <i1> [#uses=1]
+ %or.cond = or i1 %A, %B ; <i1> [#uses=1]
+ %iftmp.10.0 = select i1 %or.cond, i32 0, i32 1 ; <i32> [#uses=1]
+ ret i32 %iftmp.10.0
+}
More information about the llvm-commits
mailing list