aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2008-08-06 04:54:03 +0000
committerNick Lewycky <nicholas@mxc.ca>2008-08-06 04:54:03 +0000
commitb30591ec646b5f53c1163bf9bd74091248598589 (patch)
tree59f08c6890c531135a27ab46a5a07960e2ea4a45 /lib/Transforms
parent5226698f679755690c1263e89dd9c0a93f3d6203 (diff)
downloadexternal_llvm-b30591ec646b5f53c1163bf9bd74091248598589.zip
external_llvm-b30591ec646b5f53c1163bf9bd74091248598589.tar.gz
external_llvm-b30591ec646b5f53c1163bf9bd74091248598589.tar.bz2
Reinstate this optimization, but without the miscompile. Thanks to Bill for
tracking down that this was breaking llvm-gcc bootstrap on Linux. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54394 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index d15b6cf..fbd0d20 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -3586,6 +3586,21 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
}
}
+ { // (icmp ult A, C) & (icmp ult B, C) --> (icmp ult (A|B), C)
+ // where C is a power of 2
+ Value *A, *B;
+ ConstantInt *C1, *C2;
+ ICmpInst::Predicate LHSCC, RHSCC;
+ if (match(&I, m_And(m_ICmp(LHSCC, m_Value(A), m_ConstantInt(C1)),
+ m_ICmp(RHSCC, m_Value(B), m_ConstantInt(C2)))))
+ if (C1 == C2 && LHSCC == RHSCC && LHSCC == ICmpInst::ICMP_ULT &&
+ C1->getValue().isPowerOf2()) {
+ Instruction *NewOr = BinaryOperator::CreateOr(A, B);
+ InsertNewInstBefore(NewOr, I);
+ return new ICmpInst(LHSCC, NewOr, C1);
+ }
+ }
+
if (ICmpInst *RHS = dyn_cast<ICmpInst>(Op1)) {
// (icmp1 A, B) & (icmp2 A, B) --> (icmp3 A, B)
if (Instruction *R = AssociativeOpt(I, FoldICmpLogical(*this, RHS)))