[Hexagon] peel loops with runtime small trip counts
authorIkhlas Ajbar <iajbar@codeaurora.org>
Tue, 3 Apr 2018 22:55:09 +0000 (22:55 +0000)
committerIkhlas Ajbar <iajbar@codeaurora.org>
Tue, 3 Apr 2018 22:55:09 +0000 (22:55 +0000)
Move the check canPeel() to Hexagon Target before setting PeelCount.

Differential Revision: https://reviews.llvm.org/D44880

llvm-svn: 329129

llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp
llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp

index 786f8eb..d5401a2 100644 (file)
@@ -21,6 +21,7 @@
 #include "llvm/IR/User.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Transforms/Utils/UnrollLoop.h"
 
 using namespace llvm;
 
@@ -45,7 +46,7 @@ void HexagonTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
                                              TTI::UnrollingPreferences &UP) {
   UP.Runtime = UP.Partial = true;
   // Only try to peel innermost loops with small runtime trip counts.
-  if (L && L->empty() &&
+  if (L && L->empty() && canPeel(L) &&
       SE.getSmallConstantTripCount(L) == 0 &&
       SE.getSmallConstantMaxTripCount(L) > 0 &&
       SE.getSmallConstantMaxTripCount(L) <= 5) {
index ad454d7..a1b25a2 100644 (file)
@@ -978,9 +978,6 @@ static LoopUnrollResult tryToUnrollLoop(
   if (UP.Threshold == 0 && (!UP.Partial || UP.PartialThreshold == 0))
     return LoopUnrollResult::Unmodified;
 
-  if (UP.PeelCount && !canPeel(L))
-    UP.PeelCount = 0;
-
   SmallPtrSet<const Value *, 32> EphValues;
   CodeMetrics::collectEphemeralValues(L, &AC, EphValues);