diff options
author | Chris Lattner <sabre@nondot.org> | 2003-08-12 21:45:24 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-08-12 21:45:24 +0000 |
commit | e9608e37fcf78a3a63e2d8ec900520651486ff1d (patch) | |
tree | a58c50a6519958ac923b2b66bb82898f8c96e8cd /lib/Transforms/Scalar/Reassociate.cpp | |
parent | bb5395b586ae93fcd502c0d5a04b88badc1dfde6 (diff) | |
download | external_llvm-e9608e37fcf78a3a63e2d8ec900520651486ff1d.zip external_llvm-e9608e37fcf78a3a63e2d8ec900520651486ff1d.tar.gz external_llvm-e9608e37fcf78a3a63e2d8ec900520651486ff1d.tar.bz2 |
Fix bug: Reassociate/2003-08-12-InfiniteLoop.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7792 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/Reassociate.cpp')
-rw-r--r-- | lib/Transforms/Scalar/Reassociate.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/Transforms/Scalar/Reassociate.cpp b/lib/Transforms/Scalar/Reassociate.cpp index fe03211..580b4ef 100644 --- a/lib/Transforms/Scalar/Reassociate.cpp +++ b/lib/Transforms/Scalar/Reassociate.cpp @@ -126,12 +126,13 @@ bool Reassociate::ReassociateExpr(BinaryOperator *I) { if (LHSI->getOpcode() == I->getOpcode() && LHSI->use_size() == 1) { // If the rank of our current RHS is less than the rank of the LHS's LHS, // then we reassociate the two instructions... - if (RHSRank < getRank(LHSI->getOperand(0))) { - unsigned TakeOp = 0; - if (BinaryOperator *IOp = dyn_cast<BinaryOperator>(LHSI->getOperand(0))) - if (IOp->getOpcode() == LHSI->getOpcode()) - TakeOp = 1; // Hoist out non-tree portion + unsigned TakeOp = 0; + if (BinaryOperator *IOp = dyn_cast<BinaryOperator>(LHSI->getOperand(0))) + if (IOp->getOpcode() == LHSI->getOpcode()) + TakeOp = 1; // Hoist out non-tree portion + + if (RHSRank < getRank(LHSI->getOperand(TakeOp))) { // Convert ((a + 12) + 10) into (a + (12 + 10)) I->setOperand(0, LHSI->getOperand(TakeOp)); LHSI->setOperand(TakeOp, RHS); |