[all-commits] [llvm/llvm-project] 3f170e: [Polly][Optimizer] Apply user-directed unrolling.
Michael Kruse via All-commits
all-commits at lists.llvm.org
Mon Mar 15 11:08:09 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 3f170eb197906c2a793e62b54870296a4f5d722a
https://github.com/llvm/llvm-project/commit/3f170eb197906c2a793e62b54870296a4f5d722a
Author: Michael Kruse <llvm-project at meinersbur.de>
Date: 2021-03-15 (Mon, 15 Mar 2021)
Changed paths:
M polly/include/polly/CodeGen/IRBuilder.h
A polly/include/polly/ManualOptimizer.h
M polly/include/polly/ScheduleTreeTransform.h
M polly/include/polly/ScopInfo.h
M polly/include/polly/Support/ScopHelper.h
M polly/lib/Analysis/ScopBuilder.cpp
M polly/lib/CMakeLists.txt
M polly/lib/CodeGen/IRBuilder.cpp
M polly/lib/CodeGen/IslNodeBuilder.cpp
M polly/lib/Support/ScopHelper.cpp
A polly/lib/Transform/ManualOptimizer.cpp
M polly/lib/Transform/ScheduleOptimizer.cpp
M polly/lib/Transform/ScheduleTreeTransform.cpp
A polly/test/ScheduleOptimizer/ManualOptimization/disable_nonforced.ll
A polly/test/ScheduleOptimizer/ManualOptimization/unroll_double.ll
A polly/test/ScheduleOptimizer/ManualOptimization/unroll_full.ll
A polly/test/ScheduleOptimizer/ManualOptimization/unroll_partial.ll
A polly/test/ScheduleOptimizer/ManualOptimization/unroll_partial_followup.ll
Log Message:
-----------
[Polly][Optimizer] Apply user-directed unrolling.
Make Polly look for unrolling metadata (https://llvm.org/docs/TransformMetadata.html#loop-unrolling) that is usually only interpreted by the LoopUnroll pass and apply it to the SCoP's schedule.
While not that useful by itself (there already is an unroll pass), it introduces mechanism to apply arbitrary loop transformation directives in arbitrary order to the schedule. Transformations are applied until no more directives are found. Since ISL's rescheduling would discard the manual transformations and it is assumed that when the user specifies the sequence of transformations, they do not want any other transformations to apply. Applying user-directed transformations can be controlled using the `-polly-pragma-based-opts` switch and is enabled by default.
This does not influence the SCoP detection heuristic. As a consequence, loop that do not fulfill SCoP requirements or the initial profitability heuristic will be ignored. `-polly-process-unprofitable` can be used to disable the latter.
Other than manually editing the IR, there is currently no way for the user to add loop transformations in an order other than the order in the default pipeline, or transformations other than the one supported by clang's LoopHint. See the `unroll_double.ll` test as example that clang currently is unable to emit. My own extension of `#pragma clang loop` allowing an arbitrary order and additional transformations is available here: https://github.com/meinersbur/llvm-project/tree/pragma-clang-loop. An effort to upstream this functionality as `#pragma clang transform` (because `#pragma clang loop` has an implicit transformation order defined by the loop pipeline) is D69088.
Additional transformations from my downstream pragma-clang-loop branch are tiling, interchange, reversal, unroll-and-jam, thread-parallelization and array packing. Unroll was chosen because it uses already-defined metadata and does not require correctness checks.
Reviewed By: sebastiankreutzer
Differential Revision: https://reviews.llvm.org/D97977
More information about the All-commits
mailing list