[llvm] r265558 - LoopUnroll: only allow non-modulo Partial unrolling when Runtime=true

Fiona Glaser via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 6 09:43:45 PDT 2016


Author: escha
Date: Wed Apr  6 11:43:45 2016
New Revision: 265558

URL: http://llvm.org/viewvc/llvm-project?rev=265558&view=rev
Log:
LoopUnroll: only allow non-modulo Partial unrolling when Runtime=true

Patch by Evgeny Stupachenko <evstupac at gmail.com>.

Modified:
    llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp
    llvm/trunk/test/Transforms/LoopUnroll/partial-unroll-const-bounds.ll

Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp?rev=265558&r1=265557&r2=265558&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp Wed Apr  6 11:43:45 2016
@@ -639,10 +639,12 @@ static bool tryToUnrollLoop(Loop *L, Dom
       Count = (std::max(UP.PartialThreshold, 3u) - 2) / (LoopSize - 2);
       while (Count != 0 && TripCount % Count != 0)
         Count--;
-      if (Count <= 1) {
+      if (AllowRuntime && Count <= 1) {
         // If there is no Count that is modulo of TripCount, set Count to
         // largest power-of-two factor that satisfies the threshold limit.
-        Count = (std::max(UP.PartialThreshold, 3u) - 2) / (LoopSize - 2);
+        // As we'll create fixup loop, do the type of unrolling only if
+        // runtime unrolling is allowed.
+        Count = DefaultUnrollRuntimeCount;
         UnrolledSize = (LoopSize - 2) * Count + 2;
         while (Count != 0 && UnrolledSize > UP.PartialThreshold) {
           Count >>= 1;

Modified: llvm/trunk/test/Transforms/LoopUnroll/partial-unroll-const-bounds.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopUnroll/partial-unroll-const-bounds.ll?rev=265558&r1=265557&r2=265558&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LoopUnroll/partial-unroll-const-bounds.ll (original)
+++ llvm/trunk/test/Transforms/LoopUnroll/partial-unroll-const-bounds.ll Wed Apr  6 11:43:45 2016
@@ -1,4 +1,4 @@
-; RUN: opt < %s -S -unroll-threshold=20 -loop-unroll -unroll-allow-partial | FileCheck %s
+; RUN: opt < %s -S -unroll-threshold=20 -loop-unroll -unroll-allow-partial -unroll-runtime | FileCheck %s
 
 ; The Loop TripCount is 9. However unroll factors 3 or 9 exceed given threshold.
 ; The test checks that we choose a smaller, power-of-two, unroll count and do not give up on unrolling.




More information about the llvm-commits mailing list