[llvm] r219239 - LoopUnroll: Only check for ScalarEvolution analysis once, NFC

Duncan P. N. Exon Smith dexonsmith at apple.com
Tue Oct 7 14:12:44 PDT 2014


Author: dexonsmith
Date: Tue Oct  7 16:12:44 2014
New Revision: 219239

URL: http://llvm.org/viewvc/llvm-project?rev=219239&view=rev
Log:
LoopUnroll: Only check for ScalarEvolution analysis once, NFC

A follow-up commit will add use to a tight loop.  We might as well just
find it once anyway.

Modified:
    llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp

Modified: llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp?rev=219239&r1=219238&r2=219239&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp Tue Oct  7 16:12:44 2014
@@ -224,11 +224,10 @@ bool llvm::UnrollLoop(Loop *L, unsigned
 
   // Notify ScalarEvolution that the loop will be substantially changed,
   // if not outright eliminated.
-  if (PP) {
-    ScalarEvolution *SE = PP->getAnalysisIfAvailable<ScalarEvolution>();
-    if (SE)
-      SE->forgetLoop(L);
-  }
+  ScalarEvolution *SE =
+      PP ? PP->getAnalysisIfAvailable<ScalarEvolution>() : nullptr;
+  if (SE)
+    SE->forgetLoop(L);
 
   // If we know the trip count, we know the multiple...
   unsigned BreakoutTrip = 0;
@@ -459,7 +458,6 @@ bool llvm::UnrollLoop(Loop *L, unsigned
     }
 
     // Simplify any new induction variables in the partially unrolled loop.
-    ScalarEvolution *SE = PP->getAnalysisIfAvailable<ScalarEvolution>();
     if (SE && !CompletelyUnroll) {
       SmallVector<WeakVH, 16> DeadInsts;
       simplifyLoopIVs(L, SE, LPM, DeadInsts);
@@ -508,7 +506,6 @@ bool llvm::UnrollLoop(Loop *L, unsigned
     if (OuterL) {
       DataLayoutPass *DLP = PP->getAnalysisIfAvailable<DataLayoutPass>();
       const DataLayout *DL = DLP ? &DLP->getDataLayout() : nullptr;
-      ScalarEvolution *SE = PP->getAnalysisIfAvailable<ScalarEvolution>();
       simplifyLoop(OuterL, DT, LI, PP, /*AliasAnalysis*/ nullptr, SE, DL, AT);
 
       // LCSSA must be performed on the outermost affected loop. The unrolled





More information about the llvm-commits mailing list