[llvm-commits] [polly] r156254 - in /polly/trunk: include/polly/CodeGen/CodeGeneration.h lib/CodeGen/BlockGenerators.cpp lib/CodeGen/CodeGeneration.cpp lib/Pocc.cpp lib/RegisterPasses.cpp lib/ScheduleOptimizer.cpp

Hongbin Zheng etherzhhb at gmail.com
Sun May 6 03:22:19 PDT 2012


Author: ether
Date: Sun May  6 05:22:19 2012
New Revision: 156254

URL: http://llvm.org/viewvc/llvm-project?rev=156254&view=rev
Log:
Allow polly ask bb-vectorizer to vectorize the loop body.

Modified:
    polly/trunk/include/polly/CodeGen/CodeGeneration.h
    polly/trunk/lib/CodeGen/BlockGenerators.cpp
    polly/trunk/lib/CodeGen/CodeGeneration.cpp
    polly/trunk/lib/Pocc.cpp
    polly/trunk/lib/RegisterPasses.cpp
    polly/trunk/lib/ScheduleOptimizer.cpp

Modified: polly/trunk/include/polly/CodeGen/CodeGeneration.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/CodeGen/CodeGeneration.h?rev=156254&r1=156253&r2=156254&view=diff
==============================================================================
--- polly/trunk/include/polly/CodeGen/CodeGeneration.h (original)
+++ polly/trunk/include/polly/CodeGen/CodeGeneration.h Sun May  6 05:22:19 2012
@@ -16,7 +16,14 @@
 #ifdef CLOOG_FOUND
 
 namespace polly {
-  extern bool EnablePollyVector;
+  enum VectorizerChoice {
+    VECTORIZER_NONE,
+    VECTORIZER_POLLY,
+    VECTORIZER_UNROLL_ONLY,
+    VECTORIZER_FIRST_NEED_GROUPED_UNROLL = VECTORIZER_UNROLL_ONLY,
+    VECTORIZER_BB
+  };
+  extern VectorizerChoice PollyVectorizerChoice;
 }
 
 #endif // CLOOG_FOUND

Modified: polly/trunk/lib/CodeGen/BlockGenerators.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/BlockGenerators.cpp?rev=156254&r1=156253&r2=156254&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/BlockGenerators.cpp (original)
+++ polly/trunk/lib/CodeGen/BlockGenerators.cpp Sun May  6 05:22:19 2012
@@ -14,6 +14,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "polly/ScopInfo.h"
+#include "polly/CodeGen/CodeGeneration.h"
 #include "polly/CodeGen/BlockGenerators.h"
 #include "polly/Support/GICHelper.h"
 
@@ -36,12 +37,6 @@
        cl::init(false), cl::ZeroOrMore);
 
 static cl::opt<bool>
-GroupedUnrolling("enable-polly-grouped-unroll",
-                 cl::desc("Perform grouped unrolling, but don't generate SIMD "
-                          "instuctions"), cl::Hidden, cl::init(false),
-                 cl::ZeroOrMore);
-
-static cl::opt<bool>
 SCEVCodegen("polly-codegen-scev",
             cl::desc("Use SCEV based code generation."), cl::Hidden,
             cl::init(false), cl::ZeroOrMore);
@@ -244,7 +239,6 @@
   ValueMapT &BBMap;
 };
 
-
 // Helper class to generate memory location.
 namespace {
 class IslGenerator {
@@ -670,7 +664,8 @@
 void VectorBlockGenerator::generateLoad(const LoadInst *Load,
                                         ValueMapT &VectorMap,
                                         VectorValueMapT &ScalarMaps) {
-  if (GroupedUnrolling || !VectorType::isValidElementType(Load->getType())) {
+  if (PollyVectorizerChoice >= VECTORIZER_FIRST_NEED_GROUPED_UNROLL ||
+      !VectorType::isValidElementType(Load->getType())) {
     for (int i = 0; i < getVectorWidth(); i++)
       ScalarMaps[i][Load] = generateScalarLoad(Load, ScalarMaps[i],
                                                GlobalMaps[i]);

Modified: polly/trunk/lib/CodeGen/CodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/CodeGeneration.cpp?rev=156254&r1=156253&r2=156254&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/CodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/CodeGeneration.cpp Sun May  6 05:22:19 2012
@@ -57,14 +57,6 @@
 struct isl_set;
 
 namespace polly {
-
-bool EnablePollyVector;
-
-static cl::opt<bool, true>
-Vector("enable-polly-vector",
-       cl::desc("Enable polly vector code generation"), cl::Hidden,
-       cl::location(EnablePollyVector), cl::init(false), cl::ZeroOrMore);
-
 static cl::opt<bool>
 OpenMP("enable-polly-openmp",
        cl::desc("Generate OpenMP parallel code"), cl::Hidden,
@@ -616,6 +608,7 @@
 }
 
 void ClastStmtCodeGen::codegen(const clast_for *f) {
+  bool Vector = PollyVectorizerChoice != VECTORIZER_NONE;
   if ((Vector || OpenMP) && P->getAnalysis<Dependences>().isParallelFor(f)) {
     if (Vector && isInnermostLoop(f) && (-1 != getNumberOfIterations(f))
         && (getNumberOfIterations(f) <= 16)) {

Modified: polly/trunk/lib/Pocc.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Pocc.cpp?rev=156254&r1=156253&r2=156254&view=diff
==============================================================================
--- polly/trunk/lib/Pocc.cpp (original)
+++ polly/trunk/lib/Pocc.cpp Sun May  6 05:22:19 2012
@@ -118,7 +118,7 @@
   if (!DisablePollyTiling)
     arguments.push_back("--pluto-tile");
 
-  if (EnablePollyVector)
+  if (PollyVectorizerChoice != VECTORIZER_NONE)
     arguments.push_back("--pluto-prevector");
 
   arguments.push_back(0);

Modified: polly/trunk/lib/RegisterPasses.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/RegisterPasses.cpp?rev=156254&r1=156253&r2=156254&view=diff
==============================================================================
--- polly/trunk/lib/RegisterPasses.cpp (original)
+++ polly/trunk/lib/RegisterPasses.cpp Sun May  6 05:22:19 2012
@@ -18,6 +18,7 @@
 #include "polly/ScopDetection.h"
 #include "polly/ScopInfo.h"
 #include "polly/TempScopInfo.h"
+#include "polly/CodeGen/CodeGeneration.h"
 
 #include "llvm/Analysis/Passes.h"
 #include "llvm/Analysis/CFGPrinter.h"
@@ -25,6 +26,7 @@
 #include "llvm/PassManager.h"
 #include "llvm/PassRegistry.h"
 #include "llvm/Transforms/Scalar.h"
+#include "llvm/Transforms/Vectorize.h"
 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
 #include "llvm/Support/CommandLine.h"
 
@@ -61,6 +63,21 @@
             clEnumValEnd),
           cl::Hidden, cl::init(OPTIMIZER_ISL), cl::ZeroOrMore);
 
+static cl::opt<polly::VectorizerChoice, true>
+Vectorizer("polly-vectorizer",
+          cl::desc("Select the scheduling optimizer"),
+          cl::values(
+            clEnumValN(polly::VECTORIZER_NONE, "none", "No Vectorization"),
+            clEnumValN(polly::VECTORIZER_POLLY, "polly",
+                       "Polly internal vectorizer"),
+            clEnumValN(polly::VECTORIZER_UNROLL_ONLY, "unroll-only",
+                       "Only grouped unroll the vectorize candidate loops"),
+            clEnumValN(polly::VECTORIZER_BB, "bb",
+                       "The Basic Block vectorizer driven by Polly"),
+            clEnumValEnd),
+          cl::Hidden, cl::location(PollyVectorizerChoice),
+          cl::init(polly::VECTORIZER_NONE), cl::ZeroOrMore);
+
 static cl::opt<bool>
 ImportJScop("polly-import",
             cl::desc("Export the polyhedral description of the detected Scops"),
@@ -174,6 +191,8 @@
   PM.add(polly::createRegionSimplifyPass());
 }
 
+VectorizerChoice polly::PollyVectorizerChoice;
+
 void polly::registerPollyPasses(llvm::PassManagerBase &PM, bool DisableCodegen) {
   bool RunCodegen = !DisableCodegen;
 
@@ -215,8 +234,15 @@
     PM.add(polly::createJSONExporterPass());
 
 #ifdef CLOOG_FOUND
-  if (RunCodegen)
+  if (RunCodegen) {
     PM.add(polly::createCodeGenerationPass());
+
+    if (PollyVectorizerChoice == VECTORIZER_BB) {
+      VectorizeConfig C;
+      C.FastDep = true;
+      PM.add(createBBVectorizePass(C));
+    }
+  }
 #endif
 
   if (CFGPrinter)

Modified: polly/trunk/lib/ScheduleOptimizer.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/ScheduleOptimizer.cpp?rev=156254&r1=156253&r2=156254&view=diff
==============================================================================
--- polly/trunk/lib/ScheduleOptimizer.cpp (original)
+++ polly/trunk/lib/ScheduleOptimizer.cpp Sun May  6 05:22:19 2012
@@ -412,7 +412,7 @@
       PartialSchedule = isl_union_map_flat_range_product(PartialSchedule,
 							 SuffixSchedule);
       isl_band_list_free(Children);
-    } else if (EnablePollyVector) {
+    } else if (PollyVectorizerChoice != VECTORIZER_NONE) {
       for (int j = 0;  j < isl_band_n_member(Band); j++) {
 	if (isl_band_member_is_zero_distance(Band, j)) {
           isl_map *TileMap;





More information about the llvm-commits mailing list