[PATCH] D97977: [Polly][Optimizer] Apply user-directed unrolling.
Michael Kruse via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 4 13:47:30 PST 2021
Meinersbur created this revision.
Meinersbur added reviewers: sebastiankreutzer, QwertycowMoo, prateekpardeshi, grosser, jdoerfert, hfinkel.
Meinersbur added a project: Polly.
Herald added subscribers: mgrang, zzheng, hiraditya, mgorny.
Herald added a reviewer: bollu.
Meinersbur requested review of this revision.
Herald added a project: LLVM.
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 <https://reviews.llvm.org/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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D97977
Files:
llvm/lib/Transforms/Utils/LoopUtils.cpp
polly/include/polly/CodeGen/IRBuilder.h
polly/include/polly/ManualOptimizer.h
polly/include/polly/ScheduleTreeTransform.h
polly/include/polly/ScopInfo.h
polly/include/polly/Support/ScopHelper.h
polly/lib/Analysis/ScopBuilder.cpp
polly/lib/CMakeLists.txt
polly/lib/CodeGen/IRBuilder.cpp
polly/lib/CodeGen/IslNodeBuilder.cpp
polly/lib/Support/ScopHelper.cpp
polly/lib/Transform/ManualOptimizer.cpp
polly/lib/Transform/ScheduleOptimizer.cpp
polly/lib/Transform/ScheduleTreeTransform.cpp
polly/test/ScheduleOptimizer/ManualOptimization/disable_nonforced.ll
polly/test/ScheduleOptimizer/ManualOptimization/unroll_double.ll
polly/test/ScheduleOptimizer/ManualOptimization/unroll_full.ll
polly/test/ScheduleOptimizer/ManualOptimization/unroll_partial.ll
polly/test/ScheduleOptimizer/ManualOptimization/unroll_partial_followup.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97977.328290.patch
Type: text/x-patch
Size: 65819 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210304/5c41df9c/attachment-0001.bin>
More information about the llvm-commits
mailing list