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

Chris Lattner sabre at nondot.org
Sun Apr 1 23:35:01 PDT 2007



Changes in directory llvm/lib/Transforms/Scalar:

LoopStrengthReduce.cpp updated: 1.123 -> 1.124
---
Log message:

Pass the type of the store access, not the type of the store, into the 
target hook.  This allows us to codegen a loop as:

LBB1_1: @cond_next
        mov r2, #0
        str r2, [r0, +r3, lsl #2]
        add r3, r3, #1
        cmn r3, #1
        bne LBB1_1      @cond_next

instead of:

LBB1_1: @cond_next
        mov r2, #0
        str r2, [r0], #+4
        add r3, r3, #1
        cmn r3, #1
        bne LBB1_1      @cond_next

This looks the same, but has one fewer induction variable (and therefore,
one fewer register) live in the loop.



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

 LoopStrengthReduce.cpp |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)


Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.123 llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.124
--- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.123	Sun Apr  1 17:21:39 2007
+++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp	Mon Apr  2 01:34:44 2007
@@ -899,8 +899,15 @@
       Imm = SC->getValue()->getSExtValue();
     else
       Imm = 0;
-    if (!TLI->isLegalAddressScaleAndImm(Scale, Imm, 
-                                  UsersToProcess[i].Inst->getType()))
+    
+    // If this is a load or other access, pass the type of the access in.
+    const Type *AccessTy = Type::VoidTy;
+    if (StoreInst *SI = dyn_cast<StoreInst>(UsersToProcess[i].Inst))
+      AccessTy = SI->getOperand(0)->getType();
+    else if (LoadInst *LI = dyn_cast<LoadInst>(UsersToProcess[i].Inst))
+      AccessTy = LI->getType();
+    
+    if (!TLI->isLegalAddressScaleAndImm(Scale, Imm, AccessTy))
       return false;
   }
   return true;






More information about the llvm-commits mailing list