Index: include/polly/CodeGen/BlockGenerators.h =================================================================== --- include/polly/CodeGen/BlockGenerators.h +++ include/polly/CodeGen/BlockGenerators.h @@ -33,8 +33,6 @@ } namespace polly { -extern bool SCEVCodegen; - using namespace llvm; class ScopStmt; class MemoryAccess; Index: include/polly/CodeGen/CodeGeneration.h =================================================================== --- include/polly/CodeGen/CodeGeneration.h +++ include/polly/CodeGen/CodeGeneration.h @@ -18,26 +18,6 @@ #include "isl/map.h" namespace polly { -enum VectorizerChoice { - VECTORIZER_NONE, - VECTORIZER_POLLY, - VECTORIZER_UNROLL_ONLY, - VECTORIZER_FIRST_NEED_GROUPED_UNROLL = VECTORIZER_UNROLL_ONLY, - VECTORIZER_BB -}; -extern VectorizerChoice PollyVectorizerChoice; - -enum CodeGenChoice { -#ifdef CLOOG_FOUND - CODEGEN_CLOOG, -#endif - CODEGEN_ISL, - CODEGEN_NONE -}; -extern CodeGenChoice PollyCodeGenChoice; - -/// @brief Flag to turn on/off annotation of alias scopes. -extern bool PollyAnnotateAliasScopes; static inline int getNumberOfIterations(__isl_take isl_set *Domain) { int Dim = isl_set_dim(Domain, isl_dim_set); Index: include/polly/Options.h =================================================================== --- include/polly/Options.h +++ include/polly/Options.h @@ -7,7 +7,8 @@ // //===----------------------------------------------------------------------===// // -// Introduce an option category for Polly. +// Introduce an option category for Polly and expose all options to other +// passes or projects. The default values can be found in Options.cpp. // //===----------------------------------------------------------------------===// @@ -17,4 +18,127 @@ #include "llvm/Support/CommandLine.h" extern llvm::cl::OptionCategory PollyCategory; + +namespace polly { + +/// @name SCoP detection options +/// +///{ + +/// @brief Use ScalarEvolution to synthesize values instead of copying them. +/// +/// @note This will lift the restriction on canonical induction variables. +extern bool PollySCEVCodegen; + +/// @brief Flag to enable runtime alias checks (isl backend only). +/// +/// @note This will lift the restriction on non-aliasing pointers. +extern bool PollyUseRuntimeAliasChecks; + +/// @brief Flag to check for SCoPs in regions without loops. +extern bool PollyDetectScopsInRegionsWithoutLoops; + +/// @brief Flag to check for SCoPs in functions without loops. +extern bool PollyDetectScopsInFunctionsWithoutLoops; + +/// @brief Flag to enable over approximation of non-affine memory accesses. +extern bool PollyAllowNonAffine; + +/// @brief Flag to enable tracking of reasons for invalid SCoPs. +extern bool PollyTrackFailures; + +/// @brief Flag to enable delinearization of memory accesses. +extern bool PollyDelinearize; + +/// @brief Flag to ignore possible alising (no runtime checks!). +extern bool PollyIgnoreAliasing; + +/// @brief Flag to enable verification of the SCoPs after optimization. +extern bool PollyDetectionVerify; + +/// @brief Flag to enable additional information about the detected SCoPs. +extern bool PollyDetectionReport; + +/// @brief Flag to force detection to keep going even if a region is not a SCoP. +extern bool PollyKeepGoing; + +/// @brief Flag to disable multiplicative reductions. +extern bool PollyDisableMultiplicativeReductions; + +/// @brief Limit for the maximal number of parameters involved in an RTC access. +extern unsigned PollyRunTimeChecksMaxParameters; + +/// @brief Limit detection to regions with a name containing this string. +extern std::string PollyOnlyRegion; + +/// @brief Limit detection to functions with a name containing this string. +extern std::string PollyOnlyFunction; + +///} + +/// @name Scheduling options +/// +/// TODO: Expose more options to other LLVM passes. +/// +///{ + +/// @brief Limit on isl operations before Polly stops the dependence analysis. +extern unsigned PollyDependenceComputeOut; + +/// @brief Flag to decide whether or not Polly will apply tiling. +extern bool PollyDisableTiling; + +/// @brief Flag to disable legality check for imported schedules. +extern bool PollyDependenceNoLegalityCheck; + +/// @brief The possible choices Polly has to generate dependence information. +enum AnalysisType { + VALUE_BASED_ANALYSIS, ///< Exact dependences without transitive dependences + MEMORY_BASED_ANALYSIS ///< Overapproximation of dependences +}; + +/// @brief The kind of analysis polly will use to compute dependences. +extern AnalysisType PollyDependenceAnalysisType; + +///} + +/// @name Code generation options +/// +/// TODO: Some of the options are not explained very well. +/// +///{ + +/// @brief Assume aligned memory accesses. +/// +/// @TODO This options seems depraced and if not badly named. +extern bool PollyAssumeAligned; + +/// @brief Use Polly to add alias scopes to new generated SCoPs. +extern bool PollyAnnotateAliasScopes; + +/// @brief The possible choices Polly has to generate "vectorized" code. +enum VectorizerChoice { + VECTORIZER_NONE, ///< Generate scalar code + VECTORIZER_POLLY, ///< Generate vectorized code + VECTORIZER_UNROLL_ONLY, ///< Only unroll vectorizable loops + VECTORIZER_BB ///< Unroll vectorizable loops + BB Vectorizer +}; + +/// @brief The kind of vectorization Polly will use. +extern VectorizerChoice PollyVectorizerChoice; + +/// @brief The possible choices Polly has to generate LLVM-IR. +enum CodeGenChoice { +#ifdef CLOOG_FOUND + CODEGEN_CLOOG, ///< Use the cloog backend (only if build with cloog) +#endif + CODEGEN_ISL, ///< Use the isl backend + CODEGEN_NONE ///< Do not generate LLVM-IR (analyze only) +}; + +/// @brief The kind of code generation Polly will use +extern CodeGenChoice PollyCodeGenChoice; + +///} +} #endif Index: include/polly/ScheduleOptimizer.h =================================================================== --- include/polly/ScheduleOptimizer.h +++ /dev/null @@ -1,19 +0,0 @@ -//===------ polly/ScheduleOptimizer.h - The Schedule Optimizer *- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -//===----------------------------------------------------------------------===// - -#ifndef POLLY_SCHEDULE_OPTIMIZER_H -#define POLLY_SCHEDULE_OPTIMIZER_H - -namespace polly { -extern bool DisablePollyTiling; -} - -#endif Index: include/polly/ScopDetection.h =================================================================== --- include/polly/ScopDetection.h +++ include/polly/ScopDetection.h @@ -107,10 +107,6 @@ typedef std::map BaseToAFs; typedef std::map BaseToElSize; -extern bool PollyTrackFailures; -extern bool PollyDelinearize; -extern bool PollyUseRuntimeAliasChecks; - /// @brief A function attribute which will cause Polly to skip the function extern llvm::StringRef PollySkipFnAttr; Index: include/polly/TempScopInfo.h =================================================================== --- include/polly/TempScopInfo.h +++ include/polly/TempScopInfo.h @@ -29,8 +29,6 @@ namespace polly { -extern bool PollyDelinearize; - //===---------------------------------------------------------------------===// /// @brief A memory access described by a SCEV expression and the access type. class IRAccess { Index: lib/Analysis/Dependences.cpp =================================================================== --- lib/Analysis/Dependences.cpp +++ lib/Analysis/Dependences.cpp @@ -39,29 +39,6 @@ #define DEBUG_TYPE "polly-dependence" -static cl::opt OptComputeOut( - "polly-dependences-computeout", - cl::desc("Bound the dependence analysis by a maximal amount of " - "computational steps"), - cl::Hidden, cl::init(250000), cl::ZeroOrMore, cl::cat(PollyCategory)); - -static cl::opt LegalityCheckDisabled( - "disable-polly-legality", cl::desc("Disable polly legality check"), - cl::Hidden, cl::init(false), cl::ZeroOrMore, cl::cat(PollyCategory)); - -enum AnalysisType { VALUE_BASED_ANALYSIS, MEMORY_BASED_ANALYSIS }; - -static cl::opt OptAnalysisType( - "polly-dependences-analysis-type", - cl::desc("The kind of dependence analysis to use"), - cl::values(clEnumValN(VALUE_BASED_ANALYSIS, "value-based", - "Exact dependences without transitive dependences"), - clEnumValN(MEMORY_BASED_ANALYSIS, "memory-based", - "Overapproximation of dependences"), - clEnumValEnd), - cl::Hidden, cl::init(VALUE_BASED_ANALYSIS), cl::ZeroOrMore, - cl::cat(PollyCategory)); - //===----------------------------------------------------------------------===// Dependences::Dependences() : ScopPass(ID) { RAW = WAR = WAW = nullptr; } @@ -235,7 +212,7 @@ MayWrite = isl_union_map_coalesce(MayWrite); long MaxOpsOld = isl_ctx_get_max_operations(S.getIslCtx()); - isl_ctx_set_max_operations(S.getIslCtx(), OptComputeOut); + isl_ctx_set_max_operations(S.getIslCtx(), PollyDependenceComputeOut); isl_options_set_on_error(S.getIslCtx(), ISL_ON_ERROR_CONTINUE); DEBUG(dbgs() << "Read: " << Read << "\n"; @@ -247,7 +224,7 @@ // isl_union_map_compute_flow. RAW = WAW = WAR = RED = nullptr; - if (OptAnalysisType == VALUE_BASED_ANALYSIS) { + if (PollyDependenceAnalysisType == VALUE_BASED_ANALYSIS) { isl_union_map_compute_flow( isl_union_map_copy(Read), isl_union_map_copy(Write), isl_union_map_copy(MayWrite), isl_union_map_copy(Schedule), &RAW, @@ -431,7 +408,7 @@ bool Dependences::isValidScattering(StatementToIslMapTy *NewScattering) { Scop &S = getCurScop(); - if (LegalityCheckDisabled) + if (PollyDependenceNoLegalityCheck) return true; isl_union_map *Dependences = getDependences(TYPE_RAW | TYPE_WAW | TYPE_WAR); Index: lib/Analysis/ScopDetection.cpp =================================================================== --- lib/Analysis/ScopDetection.cpp +++ lib/Analysis/ScopDetection.cpp @@ -71,80 +71,6 @@ #define DEBUG_TYPE "polly-detect" -static cl::opt - DetectScopsWithoutLoops("polly-detect-scops-in-functions-without-loops", - cl::desc("Detect scops in functions without loops"), - cl::Hidden, cl::init(false), cl::ZeroOrMore, - cl::cat(PollyCategory)); - -static cl::opt - DetectRegionsWithoutLoops("polly-detect-scops-in-regions-without-loops", - cl::desc("Detect scops in regions without loops"), - cl::Hidden, cl::init(false), cl::ZeroOrMore, - cl::cat(PollyCategory)); - -static cl::opt OnlyFunction( - "polly-only-func", - cl::desc("Only run on functions that contain a certain string"), - cl::value_desc("string"), cl::ValueRequired, cl::init(""), - cl::cat(PollyCategory)); - -static cl::opt OnlyRegion( - "polly-only-region", - cl::desc("Only run on certain regions (The provided identifier must " - "appear in the name of the region's entry block"), - cl::value_desc("identifier"), cl::ValueRequired, cl::init(""), - cl::cat(PollyCategory)); - -static cl::opt - IgnoreAliasing("polly-ignore-aliasing", - cl::desc("Ignore possible aliasing of the array bases"), - cl::Hidden, cl::init(false), cl::ZeroOrMore, - cl::cat(PollyCategory)); - -bool polly::PollyUseRuntimeAliasChecks; -static cl::opt XPollyUseRuntimeAliasChecks( - "polly-use-runtime-alias-checks", - cl::desc("Use runtime alias checks to resolve possible aliasing."), - cl::location(PollyUseRuntimeAliasChecks), cl::Hidden, cl::ZeroOrMore, - cl::init(true), cl::cat(PollyCategory)); - -static cl::opt - ReportLevel("polly-report", - cl::desc("Print information about the activities of Polly"), - cl::init(false), cl::ZeroOrMore, cl::cat(PollyCategory)); - -static cl::opt - AllowNonAffine("polly-allow-nonaffine", - cl::desc("Allow non affine access functions in arrays"), - cl::Hidden, cl::init(false), cl::ZeroOrMore, - cl::cat(PollyCategory)); - -static cl::opt - TrackFailures("polly-detect-track-failures", - cl::desc("Track failure strings in detecting scop regions"), - cl::location(PollyTrackFailures), cl::Hidden, cl::ZeroOrMore, - cl::init(true), cl::cat(PollyCategory)); - -static cl::opt KeepGoing("polly-detect-keep-going", - cl::desc("Do not fail on the first error."), - cl::Hidden, cl::ZeroOrMore, cl::init(false), - cl::cat(PollyCategory)); - -static cl::opt - PollyDelinearizeX("polly-delinearize", - cl::desc("Delinearize array access functions"), - cl::location(PollyDelinearize), cl::Hidden, - cl::ZeroOrMore, cl::init(false), cl::cat(PollyCategory)); - -static cl::opt - VerifyScops("polly-detect-verify", - cl::desc("Verify the detected SCoPs after each transformation"), - cl::Hidden, cl::init(false), cl::ZeroOrMore, - cl::cat(PollyCategory)); - -bool polly::PollyTrackFailures = false; -bool polly::PollyDelinearize = false; StringRef polly::PollySkipFnAttr = "polly.skip.fn"; //===----------------------------------------------------------------------===// @@ -197,12 +123,12 @@ return; // Disable runtime alias checks if we ignore aliasing all together. - if (IgnoreAliasing) { + if (PollyIgnoreAliasing) { PollyUseRuntimeAliasChecks = false; return; } - if (AllowNonAffine) { + if (PollyAllowNonAffine) { DEBUG(errs() << "WARNING: We disable runtime alias checks as non affine " "accesses are enabled.\n"); PollyUseRuntimeAliasChecks = false; @@ -413,7 +339,7 @@ // No array shape derived. if (Shape->DelinearizedSizes.empty()) { - if (AllowNonAffine) + if (PollyAllowNonAffine) continue; for (const auto &Pair : Context.Accesses[BasePointer]) { @@ -423,7 +349,7 @@ if (!isAffineExpr(&Context.CurRegion, AF, *SE, BaseValue)) { invalid(Context, /*Assert=*/true, AF, Insn, BaseValue); - if (!KeepGoing) + if (!PollyKeepGoing) return false; } } @@ -464,10 +390,10 @@ // (Possibly) report non affine access if (IsNonAffine) { BasePtrHasNonAffine = true; - if (!AllowNonAffine) + if (!PollyAllowNonAffine) invalid(Context, /*Assert=*/true, AF, Insn, BaseValue); - if (!KeepGoing && !AllowNonAffine) + if (!PollyKeepGoing && !PollyAllowNonAffine) return false; } } @@ -521,7 +447,7 @@ if (!isAffineExpr(&Context.CurRegion, AccessFunction, *SE, BaseValue)) Context.NonAffineAccesses.insert(BasePointer); - } else if (!AllowNonAffine) { + } else if (!PollyAllowNonAffine) { if (!isAffineExpr(&Context.CurRegion, AccessFunction, *SE, BaseValue)) return invalid(Context, /*Assert=*/true, AccessFunction, &Inst, BaseValue); @@ -532,7 +458,7 @@ if (IntToPtrInst *Inst = dyn_cast(BaseValue)) return invalid(Context, /*Assert=*/true, Inst); - if (IgnoreAliasing) + if (PollyIgnoreAliasing) return true; // Check if the base pointer of the memory access does alias with @@ -577,7 +503,7 @@ DetectionContext &Context) const { if (PHINode *PN = dyn_cast(&Inst)) if (!canSynthesize(PN, LI, SE, &Context.CurRegion)) { - if (SCEVCodegen) + if (PollySCEVCodegen) return invalid(Context, /*Assert=*/true, &Inst); else @@ -609,7 +535,7 @@ } bool ScopDetection::isValidLoop(Loop *L, DetectionContext &Context) const { - if (!SCEVCodegen) { + if (!PollySCEVCodegen) { // If code generation is not in scev based mode, we need to ensure that // each loop has a canonical induction variable. PHINode *IndVar = L->getCanonicalInductionVariable(); @@ -706,7 +632,7 @@ } void ScopDetection::findScops(Region &R) { - if (!DetectRegionsWithoutLoops && regionWithoutLoops(R, LI)) + if (!PollyDetectScopsInRegionsWithoutLoops && regionWithoutLoops(R, LI)) return; bool IsValidRegion = isValidRegion(R); @@ -763,17 +689,18 @@ for (const BasicBlock *BB : R.blocks()) { Loop *L = LI->getLoopFor(BB); - if (L && L->getHeader() == BB && (!isValidLoop(L, Context) && !KeepGoing)) + if (L && L->getHeader() == BB && + (!isValidLoop(L, Context) && !PollyKeepGoing)) return false; } for (BasicBlock *BB : R.blocks()) - if (!isValidCFG(*BB, Context) && !KeepGoing) + if (!isValidCFG(*BB, Context) && !PollyKeepGoing) return false; for (BasicBlock *BB : R.blocks()) for (BasicBlock::iterator I = BB->begin(), E = --BB->end(); I != E; ++I) - if (!isValidInstruction(*I, Context) && !KeepGoing) + if (!isValidInstruction(*I, Context) && !PollyKeepGoing) return false; if (!hasAffineMemoryAccesses(Context)) @@ -817,7 +744,7 @@ return false; } - if (!R.getEntry()->getName().count(OnlyRegion)) { + if (!R.getEntry()->getName().count(PollyOnlyRegion)) { DEBUG({ dbgs() << "Region entry does not match -polly-region-only"; dbgs() << "\n"; @@ -908,7 +835,7 @@ bool ScopDetection::runOnFunction(llvm::Function &F) { LI = &getAnalysis(); RI = &getAnalysis().getRegionInfo(); - if (!DetectScopsWithoutLoops && LI->empty()) + if (!PollyDetectScopsInFunctionsWithoutLoops && LI->empty()) return false; AA = &getAnalysis(); @@ -917,7 +844,7 @@ releaseMemory(); - if (OnlyFunction != "" && !F.getName().count(OnlyFunction)) + if (PollyOnlyFunction != "" && !F.getName().count(PollyOnlyFunction)) return false; if (!isValidFunction(F)) @@ -934,7 +861,7 @@ for (const Region *R : ValidRegions) emitValidRemarks(F, R); - if (ReportLevel >= 1) + if (PollyDetectionReport) printLocations(F); return false; @@ -947,7 +874,7 @@ } void polly::ScopDetection::verifyAnalysis() const { - if (!VerifyScops) + if (!PollyDetectionVerify) return; for (const Region *R : ValidRegions) Index: lib/Analysis/ScopInfo.cpp =================================================================== --- lib/Analysis/ScopInfo.cpp +++ lib/Analysis/ScopInfo.cpp @@ -56,19 +56,6 @@ STATISTIC(ScopFound, "Number of valid Scops"); STATISTIC(RichScopFound, "Number of Scops containing a loop"); -// Multiplicative reductions can be disabled separately as these kind of -// operations can overflow easily. Additive reductions and bit operations -// are in contrast pretty stable. -static cl::opt DisableMultiplicativeReductions( - "polly-disable-multiplicative-reductions", - cl::desc("Disable multiplicative reductions"), cl::Hidden, cl::ZeroOrMore, - cl::init(false), cl::cat(PollyCategory)); - -static cl::opt RunTimeChecksMaxParameters( - "polly-rtc-max-parameters", - cl::desc("The maximal number of parameters allowed in RTCs."), cl::Hidden, - cl::ZeroOrMore, cl::init(8), cl::cat(PollyCategory)); - /// Translate a 'const SCEV *' expression in an isl_pw_aff. struct SCEVAffinator : public SCEVVisitor { public: @@ -359,7 +346,7 @@ return MemoryAccess::RT_NONE; // Fall through case Instruction::Mul: - if (DisableMultiplicativeReductions) + if (PollyDisableMultiplicativeReductions) return MemoryAccess::RT_NONE; return MemoryAccess::RT_MUL; default: @@ -855,7 +842,7 @@ : Parent(parent), BB(&bb), IVS(Nest.size()), NestLoops(Nest.size()) { // Setup the induction variables. for (unsigned i = 0, e = Nest.size(); i < e; ++i) { - if (!SCEVCodegen) { + if (!PollySCEVCodegen) { PHINode *PN = Nest[i]->getCanonicalInductionVariable(); assert(PN && "Non canonical IV in Scop!"); IVS[i] = PN; @@ -905,7 +892,7 @@ return; // Skip if it is a multiplicative reduction and we disabled them - if (DisableMultiplicativeReductions && + if (PollyDisableMultiplicativeReductions && (BinOp->getOpcode() == Instruction::Mul || BinOp->getOpcode() == Instruction::FMul)) return; @@ -1219,13 +1206,13 @@ // 11 | 6.78 // 12 | 30.38 // - if (isl_set_n_param(Set) > RunTimeChecksMaxParameters) { + if (isl_set_n_param(Set) > PollyRunTimeChecksMaxParameters) { unsigned InvolvedParams = 0; for (unsigned u = 0, e = isl_set_n_param(Set); u < e; u++) if (isl_set_involves_dims(Set, isl_dim_param, u, 1)) InvolvedParams++; - if (InvolvedParams > RunTimeChecksMaxParameters) { + if (InvolvedParams > PollyRunTimeChecksMaxParameters) { isl_set_free(Set); return -1; } Index: lib/Analysis/TempScopInfo.cpp =================================================================== --- lib/Analysis/TempScopInfo.cpp +++ lib/Analysis/TempScopInfo.cpp @@ -14,6 +14,7 @@ //===----------------------------------------------------------------------===// #include "polly/TempScopInfo.h" +#include "polly/Options.h" #include "polly/ScopDetection.h" #include "polly/LinkAllPasses.h" #include "polly/CodeGen/BlockGenerators.h" Index: lib/CodeGen/BlockGenerators.cpp =================================================================== --- lib/CodeGen/BlockGenerators.cpp +++ lib/CodeGen/BlockGenerators.cpp @@ -34,23 +34,9 @@ using namespace llvm; using namespace polly; -static cl::opt - Aligned("enable-polly-aligned", - cl::desc("Assumed aligned memory accesses."), cl::Hidden, - cl::value_desc("OpenMP code generation enabled if true"), - cl::init(false), cl::ZeroOrMore, cl::cat(PollyCategory)); - -static cl::opt - SCEVCodegenF("polly-codegen-scev", - cl::desc("Use SCEV based code generation."), cl::Hidden, - cl::location(SCEVCodegen), cl::init(false), cl::ZeroOrMore, - cl::cat(PollyCategory)); - -bool polly::SCEVCodegen; - bool polly::canSynthesize(const Instruction *I, const llvm::LoopInfo *LI, ScalarEvolution *SE, const Region *R) { - if (SCEVCodegen) { + if (PollySCEVCodegen) { if (!I || !SE->isSCEVable(I->getType())) return false; @@ -109,7 +95,7 @@ if (Value *New = lookupAvailableValue(Old, BBMap, GlobalMap)) return New; - if (SCEVCodegen && SE.isSCEVable(Old->getType())) + if (PollySCEVCodegen && SE.isSCEVable(Old->getType())) if (const SCEV *Scev = SE.getSCEVAtScope(const_cast(Old), L)) { if (!isa(Scev)) { const SCEV *NewScev = apply(Scev, LTS, SE); @@ -332,7 +318,7 @@ Builder.CreateBitCast(NewPointer, VectorPtrType, "vector_ptr"); LoadInst *VecLoad = Builder.CreateLoad(VectorPtr, Load->getName() + "_p_vec_full"); - if (!Aligned) + if (!PollyAssumeAligned) VecLoad->setAlignment(8); if (NegativeStride) { @@ -359,7 +345,7 @@ LoadInst *ScalarLoad = Builder.CreateLoad(VectorPtr, Load->getName() + "_p_splat_one"); - if (!Aligned) + if (!PollyAssumeAligned) ScalarLoad->setAlignment(8); Constant *SplatVector = Constant::getNullValue( @@ -395,7 +381,7 @@ void VectorBlockGenerator::generateLoad(const LoadInst *Load, ValueMapT &VectorMap, VectorValueMapT &ScalarMaps) { - if (PollyVectorizerChoice >= VECTORIZER_FIRST_NEED_GROUPED_UNROLL || + if (PollyVectorizerChoice >= VECTORIZER_UNROLL_ONLY || !VectorType::isValidElementType(Load->getType())) { for (int i = 0; i < getVectorWidth(); i++) ScalarMaps[i][Load] = @@ -474,7 +460,7 @@ Builder.CreateBitCast(NewPointer, VectorPtrType, "vector_ptr"); StoreInst *Store = Builder.CreateStore(Vector, VectorPtr); - if (!Aligned) + if (!PollyAssumeAligned) Store->setAlignment(8); } else { for (unsigned i = 0; i < ScalarMaps.size(); i++) { Index: lib/CodeGen/IslCodeGeneration.cpp =================================================================== --- lib/CodeGen/IslCodeGeneration.cpp +++ lib/CodeGen/IslCodeGeneration.cpp @@ -19,6 +19,7 @@ // //===----------------------------------------------------------------------===// #include "polly/Config/config.h" +#include "polly/Options.h" #include "polly/CodeGen/IslExprBuilder.h" #include "polly/CodeGen/BlockGenerators.h" #include "polly/CodeGen/CodeGeneration.h" Index: lib/Options.cpp =================================================================== --- /dev/null +++ lib/Options.cpp @@ -0,0 +1,174 @@ +//===---------- Options.cpp - Initialize the Polly Module -----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Home of all options available in Polly. +// +// TODO: Sort/categorize the options +// +//===----------------------------------------------------------------------===// + +#include "polly/Options.h" + +using namespace llvm; +using namespace polly; + +namespace polly { +bool PollyKeepGoing; +bool PollyDelinearize; +bool PollyTrackFailures; +bool PollyDisableTiling; +bool PollyAssumeAligned; +bool PollyAllowNonAffine; +bool PollyIgnoreAliasing; +bool PollyDetectionVerify; +bool PollyDetectionReport; +bool PollyUseRuntimeAliasChecks; +bool PollyDependenceNoLegalityCheck; +bool PollyDisableMultiplicativeReductions; +bool PollyDetectScopsInRegionsWithoutLoops; +bool PollyDetectScopsInFunctionsWithoutLoops; + +unsigned PollyDependenceComputeOut; +unsigned PollyRunTimeChecksMaxParameters; + +enum CodeGenChoice PollyCodeGenChoice; +enum VectorizerChoice PollyVectorizerChoice; +enum AnalysisType PollyDependenceAnalysisType; + +std::string PollyOnlyRegion; +std::string PollyOnlyFunction; +} + +static cl::opt PollyDetectScopsInFunctionsWithoutLoopsX( + "polly-detect-scops-in-functions-without-loops", + cl::desc("Detect scops in functions without loops"), + cl::location(PollyDetectScopsInFunctionsWithoutLoops), cl::Hidden, + cl::init(false), cl::ZeroOrMore, cl::cat(PollyCategory)); + +static cl::opt PollyDetectScopsInRegionsWithoutLoopsX( + "polly-detect-scops-in-regions-without-loops", + cl::desc("Detect scops in regions without loops"), + cl::location(PollyDetectScopsInRegionsWithoutLoops), cl::Hidden, + cl::init(false), cl::ZeroOrMore, cl::cat(PollyCategory)); + +static cl::opt PollyIgnoreAliasingX( + "polly-ignore-aliasing", + cl::desc("Ignore possible aliasing of the array bases"), + cl::location(PollyIgnoreAliasing), cl::Hidden, cl::init(false), + cl::ZeroOrMore, cl::cat(PollyCategory)); + +static cl::opt PollyUseRuntimeAliasChecksX( + "polly-use-runtime-alias-checks", + cl::desc("Use runtime alias checks to resolve possible aliasing."), + cl::location(PollyUseRuntimeAliasChecks), cl::Hidden, cl::ZeroOrMore, + cl::init(true), cl::cat(PollyCategory)); + +static cl::opt PollyAllowNonAffineX( + "polly-allow-nonaffine", + cl::desc("Allow non affine access functions in arrays"), + cl::location(PollyAllowNonAffine), cl::Hidden, cl::init(false), + cl::ZeroOrMore, cl::cat(PollyCategory)); + +static cl::opt PollyTrackFailuresX( + "polly-detect-track-failures", + cl::desc("Track failure strings in detecting scop regions"), + cl::location(PollyTrackFailures), cl::Hidden, cl::ZeroOrMore, + cl::init(true), cl::cat(PollyCategory)); + +static cl::opt + PollyDelinearizeX("polly-delinearize", + cl::desc("Delinearize array access functions"), + cl::location(PollyDelinearize), cl::Hidden, + cl::ZeroOrMore, cl::init(false), cl::cat(PollyCategory)); + +static cl::opt PollyOnlyFunctionX( + "polly-only-func", + cl::desc("Only run on functions that contain a certain string"), + cl::location(PollyOnlyFunction), cl::value_desc("string"), + cl::ValueRequired, cl::init(""), cl::cat(PollyCategory)); + +static cl::opt PollyOnlyRegionX( + "polly-only-region", + cl::desc("Only run on certain regions (The provided identifier must " + "appear in the name of the region's entry block"), + cl::location(PollyOnlyRegion), cl::value_desc("identifier"), + cl::ValueRequired, cl::init(""), cl::cat(PollyCategory)); + +static cl::opt PollyDetectionReportX( + "polly-report", cl::desc("Print information about the activities of Polly"), + cl::location(PollyDetectionReport), cl::init(false), cl::ZeroOrMore, + cl::cat(PollyCategory)); + +static cl::opt + PollyKeepGoingX("polly-detect-keep-going", + cl::desc("Do not fail on the first error."), + cl::location(PollyKeepGoing), cl::Hidden, cl::ZeroOrMore, + cl::init(false), cl::cat(PollyCategory)); + +static cl::opt PollyDetectionVerifyX( + "polly-detect-verify", + cl::desc("Verify the detected SCoPs after each transformation"), + cl::location(PollyDetectionVerify), cl::Hidden, cl::init(false), + cl::ZeroOrMore, cl::cat(PollyCategory)); + +// Multiplicative reductions can be disabled separately as these kind of +// operations can overflow easily. Additive reductions and bit operations +// are in contrast pretty stable. +static cl::opt PollyDisableMultiplicativeReductionsX( + "polly-disable-multiplicative-reductions", + cl::desc("Disable multiplicative reductions"), + cl::location(PollyDisableMultiplicativeReductions), cl::Hidden, + cl::ZeroOrMore, cl::init(false), cl::cat(PollyCategory)); + +static cl::opt PollyRunTimeChecksMaxParametersX( + "polly-rtc-max-parameters", + cl::desc("The maximal number of parameters allowed in RTCs."), + cl::location(PollyRunTimeChecksMaxParameters), cl::Hidden, cl::ZeroOrMore, + cl::init(8), cl::cat(PollyCategory)); + +static cl::opt PollyDependenceComputeOutX( + "polly-dependences-computeout", + cl::desc("Bound the dependence analysis by a maximal amount of " + "computational steps"), + cl::location(PollyDependenceComputeOut), cl::Hidden, cl::init(250000), + cl::ZeroOrMore, cl::cat(PollyCategory)); + +static cl::opt PollyDependenceNoLegalityCheckX( + "polly-dependences-no-legality-check", + cl::location(PollyDependenceNoLegalityCheck), + cl::desc("Disable polly legality check"), cl::Hidden, cl::init(false), + cl::ZeroOrMore, cl::cat(PollyCategory)); + +static cl::opt PollyDependenceAnalysisTypeX( + "polly-dependences-analysis-type", + cl::desc("The kind of dependence analysis to use"), + cl::values(clEnumValN(VALUE_BASED_ANALYSIS, "value-based", + "Exact dependences without transitive dependences"), + clEnumValN(MEMORY_BASED_ANALYSIS, "memory-based", + "Overapproximation of dependences"), + clEnumValEnd), + cl::location(PollyDependenceAnalysisType), cl::Hidden, + cl::init(VALUE_BASED_ANALYSIS), cl::ZeroOrMore, cl::cat(PollyCategory)); + +static cl::opt + PollySCEVCodegenX("polly-codegen-scev", + cl::desc("Use SCEV based code generation."), cl::Hidden, + cl::location(PollySCEVCodegen), cl::init(false), + cl::ZeroOrMore, cl::cat(PollyCategory)); + +static cl::opt PollyAssumeAlignedX( + "polly-assume-aligned", cl::desc("Assumed aligned memory accesses."), + cl::location(PollyAssumeAligned), cl::Hidden, cl::init(false), + cl::ZeroOrMore, cl::cat(PollyCategory)); + +static cl::opt + PollyDisableTilingX("polly-no-tiling", + cl::desc("Disable tiling in the scheduler"), + cl::location(PollyDisableTiling), cl::init(false), + cl::ZeroOrMore, cl::cat(PollyCategory)); Index: lib/Transform/ScheduleOptimizer.cpp =================================================================== --- lib/Transform/ScheduleOptimizer.cpp +++ lib/Transform/ScheduleOptimizer.cpp @@ -17,7 +17,6 @@ // Design and Implementation, PLDI ’08, pages 101–113. ACM, 2008. //===----------------------------------------------------------------------===// -#include "polly/ScheduleOptimizer.h" #include "isl/aff.h" #include "isl/band.h" #include "isl/constraint.h" @@ -37,15 +36,6 @@ #define DEBUG_TYPE "polly-opt-isl" -namespace polly { -bool DisablePollyTiling; -} -static cl::opt - DisableTiling("polly-no-tiling", - cl::desc("Disable tiling in the scheduler"), - cl::location(polly::DisablePollyTiling), cl::init(false), - cl::ZeroOrMore, cl::cat(PollyCategory)); - static cl::opt OptimizeDeps("polly-opt-optimize-only", cl::desc("Only a certain kind of dependences (all/raw)"), @@ -301,7 +291,7 @@ PartialSchedule = isl_band_get_partial_schedule(Band); *Dimensions = isl_band_n_member(Band); - if (DisableTiling) + if (PollyDisableTiling) return PartialSchedule; // It does not make any sense to tile a band with just one dimension.