diff options
author | Chris Lattner <sabre@nondot.org> | 2005-09-02 07:07:58 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-09-02 07:07:58 +0000 |
commit | 7b4ad94282b94e1827be29b4db73fdf6e241f748 (patch) | |
tree | b936df4c559aa504e1b1487c98648a48f6c92ff6 /lib/Transforms/Scalar/Reassociate.cpp | |
parent | 2cd85da3ed8e703729fb5adfe8cc2f9b1dd2f6a8 (diff) |
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!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23214 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/Reassociate.cpp')
-rw-r--r-- | lib/Transforms/Scalar/Reassociate.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/Reassociate.cpp b/lib/Transforms/Scalar/Reassociate.cpp index fb143c9827..142ede38e1 100644 --- a/lib/Transforms/Scalar/Reassociate.cpp +++ b/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); |