Fix bug: Reassociate/2003-08-12-InfiniteLoop.ll
authorChris Lattner <sabre@nondot.org>
Tue, 12 Aug 2003 21:45:24 +0000 (21:45 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 12 Aug 2003 21:45:24 +0000 (21:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7792 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/Reassociate.cpp

index fe032116c55d0f571e35985c1cfb952e869126e5..580b4efac74b61be2a61ccf29e1445698d27beaf 100644 (file)
@@ -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);