[llvm-commits] [llvm] r66449 - /llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp

Dan Gohman gohman at apple.com
Mon Mar 9 13:46:50 PDT 2009


Author: djg
Date: Mon Mar  9 15:46:50 2009
New Revision: 66449

URL: http://llvm.org/viewvc/llvm-project?rev=66449&view=rev
Log:
Move the sorting of the StrideOrder array earlier so that it doesn't
have to be done twice.

Modified:
    llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=66449&r1=66448&r2=66449&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Mon Mar  9 15:46:50 2009
@@ -2147,7 +2147,6 @@
   Value *NewCmpRHS = NULL;
   int64_t Scale = 1;
   SCEVHandle NewOffset = SE->getIntegerSCEV(0, UIntPtrTy);
-  std::stable_sort(StrideOrder.begin(), StrideOrder.end(), StrideCompare());
 
   if (ConstantInt *C = dyn_cast<ConstantInt>(Cond->getOperand(1))) {
     int64_t CmpVal = C->getValue().getSExtValue();
@@ -2611,6 +2610,9 @@
     DEBUG(L->dump());
 #endif
 
+    // Sort the StrideOrder so we process larger strides first.
+    std::stable_sort(StrideOrder.begin(), StrideOrder.end(), StrideCompare());
+
     // Optimize induction variables.  Some indvar uses can be transformed to use
     // strides that will be needed for other purposes.  A common example of this
     // is the exit test for the loop, which can often be rewritten to use the
@@ -2629,9 +2631,6 @@
     // IVsByStride keeps IVs for one particular loop.
     assert(IVsByStride.empty() && "Stale entries in IVsByStride?");
 
-    // Sort the StrideOrder so we process larger strides first.
-    std::stable_sort(StrideOrder.begin(), StrideOrder.end(), StrideCompare());
-
     // Note: this processes each stride/type pair individually.  All users
     // passed into StrengthReduceStridedIVUsers have the same type AND stride.
     // Also, note that we iterate over IVUsesByStride indirectly by using





More information about the llvm-commits mailing list