Skip to content

Commit

Permalink
[Polly] Fully-Indexed static expansion
Browse files Browse the repository at this point in the history
This commit implements the initial version of fully-indexed static
expansion.

```
 for(int i = 0; i<Ni; i++)
   for(int j = 0; j<Ni; j++)
S:     B[j] = j;
T: A[i] = B[i]
```

After the pass, we want this :
```
 for(int i = 0; i<Ni; i++)
   for(int j = 0; j<Ni; j++)
S:     B[i][j] = j;
T: A[i] = B[i][i]
```

For now we bail (fail) in the following cases:
  - Scalar access
  - Multiple writes per SAI
  - MayWrite Access
  - Expansion that leads to an access to the original array

Furthermore: We still miss checks for escaping references to the array
base pointers. A future commit will add the missing escape-checks to
stay correct in those cases. The expansion is still locked behind a
CLI-Option and should not yet be used.

Patch contributed by: Nicholas Bonfante <bonfante.nicolas@gmail.com>

Reviewers: simbuerg, Meinersbur, bollu

Reviewed By: Meinersbur

Subscribers: mgorny, llvm-commits, pollydev

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

llvm-svn: 310304
  • Loading branch information
simbuerg committed Aug 7, 2017
1 parent c85d26b commit 81fb6b3
Show file tree
Hide file tree
Showing 7 changed files with 724 additions and 0 deletions.
3 changes: 3 additions & 0 deletions polly/include/polly/LinkAllPasses.h
Expand Up @@ -55,6 +55,7 @@ llvm::Pass *createPPCGCodeGenerationPass(GPUArch Arch = GPUArch::NVPTX64,
llvm::Pass *createIslScheduleOptimizerPass();
llvm::Pass *createFlattenSchedulePass();
llvm::Pass *createDeLICMPass();
llvm::Pass *createMaximalStaticExpansionPass();

extern char &CodePreparationID;
} // namespace polly
Expand Down Expand Up @@ -88,6 +89,7 @@ struct PollyForcePassLinking {
polly::createPPCGCodeGenerationPass();
#endif
polly::createIslScheduleOptimizerPass();
polly::createMaximalStaticExpansionPass();
polly::createFlattenSchedulePass();
polly::createDeLICMPass();
polly::createDumpModulePass("", true);
Expand All @@ -109,6 +111,7 @@ void initializeCodeGenerationPass(llvm::PassRegistry &);
void initializePPCGCodeGenerationPass(llvm::PassRegistry &);
#endif
void initializeIslScheduleOptimizerPass(llvm::PassRegistry &);
void initializeMaximalStaticExpanderPass(llvm::PassRegistry &);
void initializePollyCanonicalizePass(llvm::PassRegistry &);
void initializeFlattenSchedulePass(llvm::PassRegistry &);
void initializeDeLICMPass(llvm::PassRegistry &);
Expand Down
1 change: 1 addition & 0 deletions polly/lib/CMakeLists.txt
Expand Up @@ -62,6 +62,7 @@ add_library(PollyCore OBJECT
Transform/DeLICM.cpp
Transform/ZoneAlgo.cpp
Transform/Simplify.cpp
Transform/MaximalStaticExpansion.cpp
${POLLY_HEADER_FILES}
)
set_target_properties(PollyCore PROPERTIES FOLDER "Polly")
Expand Down
9 changes: 9 additions & 0 deletions polly/lib/Support/RegisterPasses.cpp
Expand Up @@ -149,6 +149,11 @@ static cl::opt<bool> ImportJScop(
cl::desc("Import the polyhedral description of the detected Scops"),
cl::Hidden, cl::init(false), cl::ZeroOrMore, cl::cat(PollyCategory));

static cl::opt<bool> FullyIndexedStaticExpansion(
"polly-enable-mse",
cl::desc("Fully expand the memory accesses of the detected Scops"),
cl::Hidden, cl::init(false), cl::ZeroOrMore, cl::cat(PollyCategory));

static cl::opt<bool> ExportJScop(
"polly-export",
cl::desc("Export the polyhedral description of the detected Scops"),
Expand Down Expand Up @@ -251,6 +256,7 @@ void initializePollyPasses(PassRegistry &Registry) {
initializeDependenceInfoWrapperPassPass(Registry);
initializeJSONExporterPass(Registry);
initializeJSONImporterPass(Registry);
initializeMaximalStaticExpanderPass(Registry);
initializeIslAstInfoWrapperPassPass(Registry);
initializeIslScheduleOptimizerPass(Registry);
initializePollyCanonicalizePass(Registry);
Expand Down Expand Up @@ -330,6 +336,9 @@ void registerPollyPasses(llvm::legacy::PassManagerBase &PM) {
if (DeadCodeElim)
PM.add(polly::createDeadCodeElimPass());

if (FullyIndexedStaticExpansion)
PM.add(polly::createMaximalStaticExpansionPass());

if (EnablePruneUnprofitable)
PM.add(polly::createPruneUnprofitablePass());

Expand Down

0 comments on commit 81fb6b3

Please sign in to comment.