summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-10-26 17:18:16 +0000
committerChris Lattner <sabre@nondot.org>2005-10-26 17:18:16 +0000
commit38a1b00a0fd36d948c3aef2a5c6d42bbb74de305 (patch)
treee302abe5c8bb5ac9abafc8c05cf7b23e146463b3 /llvm/lib/Transforms
parentf277ac7caab8adb14f4e4bf9f0c4f5c447088e2b (diff)
downloadbcm5719-llvm-38a1b00a0fd36d948c3aef2a5c6d42bbb74de305.tar.gz
bcm5719-llvm-38a1b00a0fd36d948c3aef2a5c6d42bbb74de305.zip
fold nested and's early to avoid inefficiencies in MaskedValueIsZero. This
fixes a very slow compile in PR639. llvm-svn: 24011
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 9ba0512a78b..f3325096895 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -1725,6 +1725,15 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
// and X, -1 == X
if (AndRHS->isAllOnesValue())
return ReplaceInstUsesWith(I, Op0);
+
+ // and (and X, c1), c2 -> and (x, c1&c2). Handle this case here, before
+ // calling MaskedValueIsZero, to avoid inefficient cases where we traipse
+ // through many levels of ands.
+ {
+ Value *X; ConstantInt *C1;
+ if (match(Op0, m_And(m_Value(X), m_ConstantInt(C1))))
+ return BinaryOperator::createAnd(X, ConstantExpr::getAnd(C1, AndRHS));
+ }
if (MaskedValueIsZero(Op0, AndRHS)) // LHS & RHS == 0
return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
OpenPOWER on IntegriCloud