aboutsummaryrefslogtreecommitdiffstats
path: root/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
commite9f15e538a87dcc92880ebd1ca5c3e88f1e1cb53 (patch)
treee6b386a60a96c93784d7a2d19983751854ac27f4 /lib/Transforms
parenta7ad198f896d29aac57f48220ecefb8a51163393 (diff)
downloadexternal_llvm-e9f15e538a87dcc92880ebd1ca5c3e88f1e1cb53.tar.gz
external_llvm-e9f15e538a87dcc92880ebd1ca5c3e88f1e1cb53.tar.bz2
external_llvm-e9f15e538a87dcc92880ebd1ca5c3e88f1e1cb53.zip
fold nested and's early to avoid inefficiencies in MaskedValueIsZero. This
fixes a very slow compile in PR639. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24011 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 9ba0512a78..f332509689 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/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()));