[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed Oct 26 10:18:27 PDT 2005
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.392 -> 1.393
---
Log message:
fold nested and's early to avoid inefficiencies in MaskedValueIsZero. This
fixes a very slow compile in PR639: http://llvm.cs.uiuc.edu/PR639 .
---
Diffs of the changes: (+9 -0)
InstructionCombining.cpp | 9 +++++++++
1 files changed, 9 insertions(+)
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.392 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.393
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.392 Mon Oct 24 01:35:18 2005
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Wed Oct 26 12:18:16 2005
@@ -1725,6 +1725,15 @@
// 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()));
More information about the llvm-commits
mailing list