Add comment.
[oota-llvm.git] / lib / Transforms / Scalar / Reassociate.cpp
index bec91dbe67caf50b63ac624e1db95bed1ed774c3..47c767feb63921f90a408badbda9b847f707bfc3 100644 (file)
@@ -404,7 +404,7 @@ static bool ShouldBreakUpSubtract(Instruction *Sub) {
       isReassociableOp(Sub->getOperand(0), Instruction::Sub))
     return true;
   if (isReassociableOp(Sub->getOperand(1), Instruction::Add) ||
-      isReassociableOp(Sub->getOperand(0), Instruction::Sub))
+      isReassociableOp(Sub->getOperand(1), Instruction::Sub))
     return true;
   if (Sub->hasOneUse() && 
       (isReassociableOp(Sub->use_back(), Instruction::Add) ||
@@ -779,10 +779,8 @@ void Reassociate::ReassociateBB(BasicBlock *BB) {
     // see if we can convert it to X+-Y.
     if (BI->getOpcode() == Instruction::Sub) {
       if (ShouldBreakUpSubtract(BI)) {
-        if (Instruction *NI = BreakUpSubtract(BI)) {
-          MadeChange = true;
-          BI = NI;
-        }
+        BI = BreakUpSubtract(BI);
+        MadeChange = true;
       } else if (BinaryOperator::isNeg(BI)) {
         // Otherwise, this is a negation.  See if the operand is a multiply tree
         // and if this is not an inner node of a multiply tree.