summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-09-02 07:07:58 +0000
committerChris Lattner <sabre@nondot.org>2005-09-02 07:07:58 +0000
commitb5e381a8cf6a4bdbb446d9e99eb4e4418016fb8c (patch)
treefb0af2bbe8732267fe47b1886ffff6e9df3a3f8b /llvm/lib
parent9fe263aa75d35d1937407b76fa365dacf9de5c45 (diff)
downloadbcm5719-llvm-b5e381a8cf6a4bdbb446d9e99eb4e4418016fb8c.tar.gz
bcm5719-llvm-b5e381a8cf6a4bdbb446d9e99eb4e4418016fb8c.zip
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! llvm-svn: 23214
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Scalar/Reassociate.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp
index fb143c98279..142ede38e1c 100644
--- a/llvm/lib/Transforms/Scalar/Reassociate.cpp
+++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp
@@ -612,6 +612,12 @@ void Reassociate::ReassociateBB(BasicBlock *BB) {
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);
OpenPOWER on IntegriCloud