[LoopUnroll] Check partial unrolling is enabled before initialization. NFC.
authorHaicheng Wu <haicheng@codeaurora.org>
Thu, 27 Oct 2016 18:40:02 +0000 (18:40 +0000)
committerHaicheng Wu <haicheng@codeaurora.org>
Thu, 27 Oct 2016 18:40:02 +0000 (18:40 +0000)
Differential Revision: https://reviews.llvm.org/D23891

llvm-svn: 285330

llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp

index 9c55ee3..b351e09 100644 (file)
@@ -803,8 +803,6 @@ static bool computeUnrollCount(
   // 4rd priority is partial unrolling.
   // Try partial unroll only when TripCount could be staticaly calculated.
   if (TripCount) {
-    if (UP.Count == 0)
-      UP.Count = TripCount;
     UP.Partial |= ExplicitUnroll;
     if (!UP.Partial) {
       DEBUG(dbgs() << "  will not try to unroll partially because "
@@ -812,6 +810,8 @@ static bool computeUnrollCount(
       UP.Count = 0;
       return false;
     }
+    if (UP.Count == 0)
+      UP.Count = TripCount;
     if (UP.PartialThreshold != NoThreshold) {
       // Reduce unroll count to be modulo of TripCount for partial unrolling.
       UnrolledSize = (uint64_t)(LoopSize - BEInsns) * UP.Count + BEInsns;