[llvm-commits] CVS: llvm/lib/Transforms/Scalar/Reassociate.cpp
Chris Lattner
lattner at cs.uiuc.edu
Fri Sep 2 00:08:10 PDT 2005
Changes in directory llvm/lib/Transforms/Scalar:
Reassociate.cpp updated: 1.54 -> 1.55
---
Log message:
Fix a problem that Dan Berlin noticed, where reassociation would not succeed
in building maximal expressions before simplifying them. In particular, i
cases like this:
X-(A+B+X)
the code would consider A+B+X to be a maximal expression (not understanding
that the single use '-' would be turned into a + later), simplify it (a noop)
then later get simplified again.
Each of these simplify steps is where the cost of reassociation comes from,
so this patch should speed up the already fast pass a bit.
Thanks to Dan for noticing this!
---
Diffs of the changes: (+6 -0)
Reassociate.cpp | 6 ++++++
1 files changed, 6 insertions(+)
Index: llvm/lib/Transforms/Scalar/Reassociate.cpp
diff -u llvm/lib/Transforms/Scalar/Reassociate.cpp:1.54 llvm/lib/Transforms/Scalar/Reassociate.cpp:1.55
--- llvm/lib/Transforms/Scalar/Reassociate.cpp:1.54 Fri Sep 2 01:38:04 2005
+++ llvm/lib/Transforms/Scalar/Reassociate.cpp Fri Sep 2 02:07:58 2005
@@ -612,6 +612,12 @@
if (I->hasOneUse() && isReassociableOp(I->use_back(), I->getOpcode()))
continue;
+ // If this is an add tree that is used by a sub instruction, ignore it
+ // until we process the subtract.
+ if (I->hasOneUse() && I->getOpcode() == Instruction::Add &&
+ cast<Instruction>(I->use_back())->getOpcode() == Instruction::Sub)
+ continue;
+
// First, walk the expression tree, linearizing the tree, collecting
std::vector<ValueEntry> Ops;
LinearizeExprTree(I, Ops);
More information about the llvm-commits
mailing list