[llvm-commits] CVS: llvm/lib/Transforms/Scalar/Reassociate.cpp ScalarReplAggregates.cpp

Reid Spencer reid at x10sys.com
Sat Jan 20 16:30:04 PST 2007



Changes in directory llvm/lib/Transforms/Scalar:

Reassociate.cpp updated: 1.72 -> 1.73
ScalarReplAggregates.cpp updated: 1.67 -> 1.68
---
Log message:

For PR970: http://llvm.org/PR970 :
Clean up handling of isFloatingPoint() and dealing with PackedType.
Patch by Gordon Henriksen!


---
Diffs of the changes:  (+25 -29)

 Reassociate.cpp          |   52 +++++++++++++++++++++--------------------------
 ScalarReplAggregates.cpp |    2 -
 2 files changed, 25 insertions(+), 29 deletions(-)


Index: llvm/lib/Transforms/Scalar/Reassociate.cpp
diff -u llvm/lib/Transforms/Scalar/Reassociate.cpp:1.72 llvm/lib/Transforms/Scalar/Reassociate.cpp:1.73
--- llvm/lib/Transforms/Scalar/Reassociate.cpp:1.72	Sun Jan 14 20:27:26 2007
+++ llvm/lib/Transforms/Scalar/Reassociate.cpp	Sat Jan 20 18:29:25 2007
@@ -186,11 +186,7 @@
 /// LowerNegateToMultiply - Replace 0-X with X*-1.
 ///
 static Instruction *LowerNegateToMultiply(Instruction *Neg) {
-  Constant *Cst;
-  if (Neg->getType()->isFloatingPoint())
-    Cst = ConstantFP::get(Neg->getType(), -1);
-  else
-    Cst = ConstantInt::getAllOnesValue(Neg->getType());
+  Constant *Cst = ConstantInt::getAllOnesValue(Neg->getType());
 
   std::string NegName = Neg->getName(); Neg->setName("");
   Instruction *Res = BinaryOperator::createMul(Neg->getOperand(1), Cst, NegName,
@@ -661,32 +657,32 @@
     std::map<Value*, unsigned> FactorOccurrences;
     unsigned MaxOcc = 0;
     Value *MaxOccVal = 0;
-    if (!I->getType()->isFloatingPoint()) {
-      for (unsigned i = 0, e = Ops.size(); i != e; ++i) {
-        if (BinaryOperator *BOp = dyn_cast<BinaryOperator>(Ops[i].Op))
-          if (BOp->getOpcode() == Instruction::Mul && BOp->use_empty()) {
-            // Compute all of the factors of this added value.
-            std::vector<Value*> Factors;
-            FindSingleUseMultiplyFactors(BOp, Factors);
-            assert(Factors.size() > 1 && "Bad linearize!");
-            
-            // Add one to FactorOccurrences for each unique factor in this op.
-            if (Factors.size() == 2) {
-              unsigned Occ = ++FactorOccurrences[Factors[0]];
-              if (Occ > MaxOcc) { MaxOcc = Occ; MaxOccVal = Factors[0]; }
-              if (Factors[0] != Factors[1]) {   // Don't double count A*A.
-                Occ = ++FactorOccurrences[Factors[1]];
-                if (Occ > MaxOcc) { MaxOcc = Occ; MaxOccVal = Factors[1]; }
+    for (unsigned i = 0, e = Ops.size(); i != e; ++i) {
+      if (BinaryOperator *BOp = dyn_cast<BinaryOperator>(Ops[i].Op)) {
+        if (BOp->getOpcode() == Instruction::Mul && BOp->use_empty()) {
+          // Compute all of the factors of this added value.
+          std::vector<Value*> Factors;
+          FindSingleUseMultiplyFactors(BOp, Factors);
+          assert(Factors.size() > 1 && "Bad linearize!");
+
+          // Add one to FactorOccurrences for each unique factor in this op.
+          if (Factors.size() == 2) {
+            unsigned Occ = ++FactorOccurrences[Factors[0]];
+            if (Occ > MaxOcc) { MaxOcc = Occ; MaxOccVal = Factors[0]; }
+            if (Factors[0] != Factors[1]) {   // Don't double count A*A.
+              Occ = ++FactorOccurrences[Factors[1]];
+              if (Occ > MaxOcc) { MaxOcc = Occ; MaxOccVal = Factors[1]; }
+            }
+          } else {
+            std::set<Value*> Duplicates;
+            for (unsigned i = 0, e = Factors.size(); i != e; ++i) {
+              if (Duplicates.insert(Factors[i]).second) {
+                unsigned Occ = ++FactorOccurrences[Factors[i]];
+                if (Occ > MaxOcc) { MaxOcc = Occ; MaxOccVal = Factors[i]; }
               }
-            } else {
-              std::set<Value*> Duplicates;
-              for (unsigned i = 0, e = Factors.size(); i != e; ++i)
-                if (Duplicates.insert(Factors[i]).second) {
-                  unsigned Occ = ++FactorOccurrences[Factors[i]];
-                  if (Occ > MaxOcc) { MaxOcc = Occ; MaxOccVal = Factors[i]; }
-                }
             }
           }
+        }
       }
     }
 


Index: llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp
diff -u llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.67 llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.68
--- llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.67	Fri Jan 19 15:13:56 2007
+++ llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp	Sat Jan 20 18:29:25 2007
@@ -519,7 +519,7 @@
         return 0;
       
     } else if (StoreInst *SI = dyn_cast<StoreInst>(User)) {
-      // Storing the pointer, not the into the value?
+      // Storing the pointer, not into the value?
       if (SI->getOperand(0) == V) return 0;
       
       // NOTE: We could handle storing of FP imms into integers here!






More information about the llvm-commits mailing list