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

Chris Lattner lattner at cs.uiuc.edu
Mon Aug 15 17:38:22 PDT 2005



Changes in directory llvm/lib/Transforms/Scalar:

LoopStrengthReduce.cpp updated: 1.51 -> 1.52
---
Log message:

Fix a bad case in gzip where we put lots of things in registers across the
loop, because a IV-dependent value was used outside of the loop and didn't
have immediate-folding capability


---
Diffs of the changes:  (+17 -9)

 LoopStrengthReduce.cpp |   26 +++++++++++++++++---------
 1 files changed, 17 insertions(+), 9 deletions(-)


Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.51 llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.52
--- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.51	Sat Aug 13 02:42:01 2005
+++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp	Mon Aug 15 19:38:11 2005
@@ -737,15 +737,23 @@
   // fields of the BasedUsers.  We do this so that it increases the commonality
   // of the remaining uses.
   for (unsigned i = 0, e = UsersToProcess.size(); i != e; ++i) {
-    // Addressing modes can be folded into loads and stores.  Be careful that
-    // the store is through the expression, not of the expression though.
-    bool isAddress = isa<LoadInst>(UsersToProcess[i].Inst);
-    if (StoreInst *SI = dyn_cast<StoreInst>(UsersToProcess[i].Inst))
-      if (SI->getOperand(1) == UsersToProcess[i].OperandValToReplace)
-        isAddress = true;
-    
-    MoveImmediateValues(UsersToProcess[i].Base, UsersToProcess[i].Imm,
-                        isAddress, L);
+    // If the user is not in the current loop, this means it is using the exit
+    // value of the IV.  Do not put anything in the base, make sure it's all in
+    // the immediate field to allow as much factoring as possible.
+    if (!L->contains(UsersToProcess[i].Inst->getParent())) {
+      std::swap(UsersToProcess[i].Base, UsersToProcess[i].Imm);
+    } else {
+      
+      // Addressing modes can be folded into loads and stores.  Be careful that
+      // the store is through the expression, not of the expression though.
+      bool isAddress = isa<LoadInst>(UsersToProcess[i].Inst);
+      if (StoreInst *SI = dyn_cast<StoreInst>(UsersToProcess[i].Inst))
+        if (SI->getOperand(1) == UsersToProcess[i].OperandValToReplace)
+          isAddress = true;
+      
+      MoveImmediateValues(UsersToProcess[i].Base, UsersToProcess[i].Imm,
+                          isAddress, L);
+    }
   }
  
   // Now that we know what we need to do, insert the PHI node itself.






More information about the llvm-commits mailing list