Enable partial and runtime loop unrolling for NVPTX.
authorMark Heffernan <meheff@google.com>
Mon, 13 Jul 2015 18:33:21 +0000 (18:33 +0000)
committerMark Heffernan <meheff@google.com>
Mon, 13 Jul 2015 18:33:21 +0000 (18:33 +0000)
Enable partial and runtime loop unrolling for NVPTX backend via
TTI::UnrollingPreferences with a small threshold. This partially unrolls
small loops which are often unrolled by the PTX to SASS compiler
and unrolling earlier can be beneficial.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242049 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
lib/Target/NVPTX/NVPTXTargetTransformInfo.h

index 241b145f71965b7fb13284b75fabb1f5a0ca6033..e7250cdba5ac7c195fac8bab9a4465e50d4b3ce5 100644 (file)
@@ -117,3 +117,15 @@ unsigned NVPTXTTIImpl::getArithmeticInstrCost(
                                          Opd1PropInfo, Opd2PropInfo);
   }
 }
+
+void NVPTXTTIImpl::getUnrollingPreferences(Loop *L,
+                                           TTI::UnrollingPreferences &UP) {
+  BaseT::getUnrollingPreferences(L, UP);
+
+  // Enable partial unrolling and runtime unrolling, but reduce the
+  // threshold.  This partially unrolls small loops which are often
+  // unrolled by the PTX to SASS compiler and unrolling earlier can be
+  // beneficial.
+  UP.Partial = UP.Runtime = true;
+  UP.PartialThreshold = UP.Threshold / 4;
+}
index c8a855ae8b0ace706083c3442b554991ec55e8b0..5bcd1e27a558c63a084cc2859f273c0d9da89ec1 100644 (file)
@@ -58,6 +58,8 @@ public:
       TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue,
       TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None,
       TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None);
+
+  void getUnrollingPreferences(Loop *L, TTI::UnrollingPreferences &UP);
 };
 
 } // end namespace llvm