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

Chris Lattner lattner at cs.uiuc.edu
Tue Aug 9 16:39:47 PDT 2005



Changes in directory llvm/lib/Transforms/Scalar:

LoopStrengthReduce.cpp updated: 1.44 -> 1.45
---
Log message:

Fix some 80 column violations.

Once we compute the evolution for a GEP, tell SE about it.  This allows users
of the GEP to know it, if the users are not direct.  This allows us to compile
this testcase:

void fbSolidFillmmx(int w, unsigned char *d) {
    while (w >= 64) {
        *(unsigned long long *) (d +  0) = 0;
        *(unsigned long long *) (d +  8) = 0;
        *(unsigned long long *) (d + 16) = 0;
        *(unsigned long long *) (d + 24) = 0;
        *(unsigned long long *) (d + 32) = 0;
        *(unsigned long long *) (d + 40) = 0;
        *(unsigned long long *) (d + 48) = 0;
        *(unsigned long long *) (d + 56) = 0;
        w -= 64;
        d += 64;
    }
}

into:

.LBB_fbSolidFillmmx_2:  ; no_exit
        li r2, 0
        stw r2, 0(r4)
        stw r2, 4(r4)
        stw r2, 8(r4)
        stw r2, 12(r4)
        stw r2, 16(r4)
        stw r2, 20(r4)
        stw r2, 24(r4)
        stw r2, 28(r4)
        stw r2, 32(r4)
        stw r2, 36(r4)
        stw r2, 40(r4)
        stw r2, 44(r4)
        stw r2, 48(r4)
        stw r2, 52(r4)
        stw r2, 56(r4)
        stw r2, 60(r4)
        addi r4, r4, 64
        addi r3, r3, -64
        cmpwi cr0, r3, 63
        bgt .LBB_fbSolidFillmmx_2       ; no_exit

instead of:

.LBB_fbSolidFillmmx_2:  ; no_exit
        li r11, 0
        stw r11, 0(r4)
        stw r11, 4(r4)
        stwx r11, r10, r4
        add r12, r10, r4
        stw r11, 4(r12)
        stwx r11, r9, r4
        add r12, r9, r4
        stw r11, 4(r12)
        stwx r11, r8, r4
        add r12, r8, r4
        stw r11, 4(r12)
        stwx r11, r7, r4
        add r12, r7, r4
        stw r11, 4(r12)
        stwx r11, r6, r4
        add r12, r6, r4
        stw r11, 4(r12)
        stwx r11, r5, r4
        add r12, r5, r4
        stw r11, 4(r12)
        stwx r11, r2, r4
        add r12, r2, r4
        stw r11, 4(r12)
        addi r4, r4, 64
        addi r3, r3, -64
        cmpwi cr0, r3, 63
        bgt .LBB_fbSolidFillmmx_2       ; no_exit


---
Diffs of the changes:  (+11 -6)

 LoopStrengthReduce.cpp |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)


Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.44 llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.45
--- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.44	Mon Aug  8 20:13:47 2005
+++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp	Tue Aug  9 18:39:36 2005
@@ -204,8 +204,12 @@
 /// GetExpressionSCEV - Compute and return the SCEV for the specified
 /// instruction.
 SCEVHandle LoopStrengthReduce::GetExpressionSCEV(Instruction *Exp, Loop *L) {
+  // Scalar Evolutions doesn't know how to compute SCEV's for GEP instructions.
+  // If this is a GEP that SE doesn't know about, compute it now and insert it.
+  // If this is not a GEP, or if we have already done this computation, just let
+  // SE figure it out.
   GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(Exp);
-  if (!GEP)
+  if (!GEP || SE->hasSCEV(GEP))
     return SE->getSCEV(Exp);
     
   // Analyze all of the subscripts of this getelementptr instruction, looking
@@ -241,6 +245,7 @@
     }
   }
 
+  SE->setSCEV(GEP, GEPVal);
   return GEPVal;
 }
 
@@ -692,7 +697,7 @@
   assert(SomeLoopPHI->getNumIncomingValues() == 2 &&
          "This loop isn't canonicalized right");
   BasicBlock *LatchBlock =
-    SomeLoopPHI->getIncomingBlock(SomeLoopPHI->getIncomingBlock(0) == Preheader);
+   SomeLoopPHI->getIncomingBlock(SomeLoopPHI->getIncomingBlock(0) == Preheader);
   
   // Create a new Phi for this base, and stick it in the loop header.
   const Type *ReplacedTy = CommonExprs->getType();
@@ -898,10 +903,10 @@
     while ((PN = dyn_cast<PHINode>(I))) {
       ++I;  // Preincrement iterator to avoid invalidating it when deleting PN.
       
-      // At this point, we know that we have killed one or more GEP instructions.
-      // It is worth checking to see if the cann indvar is also dead, so that we
-      // can remove it as well.  The requirements for the cann indvar to be
-      // considered dead are:
+      // At this point, we know that we have killed one or more GEP
+      // instructions.  It is worth checking to see if the cann indvar is also
+      // dead, so that we can remove it as well.  The requirements for the cann
+      // indvar to be considered dead are:
       // 1. the cann indvar has one use
       // 2. the use is an add instruction
       // 3. the add has one use






More information about the llvm-commits mailing list