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

Evan Cheng evan.cheng at apple.com
Mon Mar 12 16:27:54 PDT 2007



Changes in directory llvm/lib/Transforms/Scalar:

LoopStrengthReduce.cpp updated: 1.116 -> 1.117
---
Log message:

Use new TargetLowering addressing modes hooks.

---
Diffs of the changes:  (+18 -20)

 LoopStrengthReduce.cpp |   38 ++++++++++++++++++--------------------
 1 files changed, 18 insertions(+), 20 deletions(-)


Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.116 llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.117
--- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.116	Fri Mar  9 15:19:53 2007
+++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp	Mon Mar 12 18:27:37 2007
@@ -612,12 +612,12 @@
 /// immediate field of a target instruction.
 static bool isTargetConstant(const SCEVHandle &V, const TargetLowering *TLI) {
   if (SCEVConstant *SC = dyn_cast<SCEVConstant>(V)) {
-    int64_t V = SC->getValue()->getSExtValue();
+    int64_t VC = SC->getValue()->getSExtValue();
     if (TLI)
-      return TLI->isLegalAddressImmediate(V);
+      return TLI->isLegalAddressImmediate(VC, V->getType());
     else
       // Defaults to PPC. PPC allows a sign-extended 16-bit immediate field.
-      return (V > -(1 << 16) && V < (1 << 16)-1);
+      return (VC > -(1 << 16) && VC < (1 << 16)-1);
   }
 
   if (SCEVUnknown *SU = dyn_cast<SCEVUnknown>(V))
@@ -878,24 +878,22 @@
     int64_t SInt = SC->getValue()->getSExtValue();
     if (SInt == 1) return 0;
 
-    for (TargetLowering::legal_am_scale_iterator
-           I = TLI->legal_am_scale_begin(), E = TLI->legal_am_scale_end();
-         I != E; ++I) {
-      unsigned Scale = *I;
-      if (unsigned(abs(SInt)) < Scale || (SInt % Scale) != 0)
+    for (std::map<SCEVHandle, IVsOfOneStride>::iterator SI= IVsByStride.begin(),
+           SE = IVsByStride.end(); SI != SE; ++SI) {
+      int64_t SSInt = cast<SCEVConstant>(SI->first)->getValue()->getSExtValue();
+      if (unsigned(abs(SInt)) < SSInt || (SInt % SSInt) != 0)
         continue;
-      std::map<SCEVHandle, IVsOfOneStride>::iterator SI =
-        IVsByStride.find(SCEVUnknown::getIntegerSCEV(SInt/Scale, UIntPtrTy));
-      if (SI == IVsByStride.end())
-        continue;
-      for (std::vector<IVExpr>::iterator II = SI->second.IVs.begin(),
-             IE = SI->second.IVs.end(); II != IE; ++II)
-        // FIXME: Only handle base == 0 for now.
-        // Only reuse previous IV if it would not require a type conversion.
-        if (isZero(II->Base) && II->Base->getType() == Ty) {
-          IV = *II;
-          return Scale;
-        }
+      int64_t Scale = SInt / SSInt;
+      if (TLI->isLegalAddressScale(Scale, Ty)) {
+        for (std::vector<IVExpr>::iterator II = SI->second.IVs.begin(),
+               IE = SI->second.IVs.end(); II != IE; ++II)
+          // FIXME: Only handle base == 0 for now.
+          // Only reuse previous IV if it would not require a type conversion.
+          if (isZero(II->Base) && II->Base->getType() == Ty) {
+            IV = *II;
+            return Scale;
+          }
+      }
     }
   }
 






More information about the llvm-commits mailing list