* We were forgetting to pass varargs arguments through a call
[oota-llvm.git] / lib / Transforms / Scalar / Reassociate.cpp
index 94446d09b859fd5138360e8500d95d84dbe53128..822a2d894776db3e986d61656ca405e270625fea 100644 (file)
@@ -1,4 +1,11 @@
 //===- Reassociate.cpp - Reassociate binary expressions -------------------===//
+// 
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// 
+//===----------------------------------------------------------------------===//
 //
 // This pass reassociates commutative expressions in an order that is designed
 // to promote better constant propagation, GCSE, LICM, PRE...
@@ -14,9 +21,6 @@
 // (starting at 2), which effectively gives values in deep loops higher rank
 // than values not in loops.
 //
-// This code was originally written by Chris Lattner, and was then cleaned up
-// and perfected by Casey Carter.
-//
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Transforms/Scalar.h"
@@ -78,7 +82,7 @@ unsigned Reassociate::getRank(Value *V) {
     // for PHI nodes, we cannot have infinite recursion here, because there
     // cannot be loops in the value graph that do not go through PHI nodes.
     //
-    if (I->getOpcode() == Instruction::PHINode ||
+    if (I->getOpcode() == Instruction::PHI ||
         I->getOpcode() == Instruction::Alloca ||
         I->getOpcode() == Instruction::Malloc || isa<TerminatorInst>(I) ||
         I->mayWriteToMemory())  // Cannot move inst if it writes to memory!
@@ -129,7 +133,7 @@ bool Reassociate::ReassociateExpr(BinaryOperator *I) {
   // only expression using it...
   //
   if (BinaryOperator *LHSI = dyn_cast<BinaryOperator>(LHS))
-    if (LHSI->getOpcode() == I->getOpcode() && LHSI->use_size() == 1) {
+    if (LHSI->getOpcode() == I->getOpcode() && LHSI->hasOneUse()) {
       // If the rank of our current RHS is less than the rank of the LHS's LHS,
       // then we reassociate the two instructions...
 
@@ -180,7 +184,7 @@ static Value *NegateValue(Value *V, BasicBlock::iterator &BI) {
   // we introduce tons of unnecessary negation instructions...
   //
   if (Instruction *I = dyn_cast<Instruction>(V))
-    if (I->getOpcode() == Instruction::Add && I->use_size() == 1) {
+    if (I->getOpcode() == Instruction::Add && I->hasOneUse()) {
       Value *RHS = NegateValue(I->getOperand(1), BI);
       Value *LHS = NegateValue(I->getOperand(0), BI);
 
@@ -245,7 +249,7 @@ bool Reassociate::ReassociateBB(BasicBlock *BB) {
         Instruction *RHSI = dyn_cast<Instruction>(I->getOperand(1));
         if (LHSI && (int)LHSI->getOpcode() == I->getOpcode() &&
             RHSI && (int)RHSI->getOpcode() == I->getOpcode() &&
-            RHSI->use_size() == 1) {
+            RHSI->hasOneUse()) {
           // Insert a new temporary instruction... (A+B)+C
           BinaryOperator *Tmp = BinaryOperator::create(I->getOpcode(), LHSI,
                                                        RHSI->getOperand(0),