[PATCH] D55716: [LoopUnroll] Honor '#pragma unroll' even with -fno-unroll-loops.

Michael Kruse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 14 13:29:11 PST 2018


Meinersbur created this revision.
Meinersbur added reviewers: hfinkel, dmgreen, rupprecht.
Herald added subscribers: zzheng, mehdi_amini.

When using clang with `-fno-unroll-loops` (implicitly added with `-O1`), the LoopUnrollPass is not not added to the (legacy) pass pipeline. This also means that it will not process any loop metadata such as `llvm.loop.unroll.enable` (which is generated by `#pragma unroll` or `#pragma clang loop unroll(enable)`) and remain in the IR until the WarnMissedTransformationsPass emits a warning that a forced transformation has not been applied (see https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20181210/610833.html). Such explicit transformations should take precedence over disabling heuristics.

This patch unconditionally adds LoopUnrollPass to the optimizing pipeline (i.e. it is not added with `-O0`), but passes a flag indicating whether automatic unrolling is dis-/enabled. This is the same approach as LoopVectorize uses.

The new pass manager's pipeline builder has no option to disable unrolling, hence the problem does not apply.


https://reviews.llvm.org/D55716

Files:
  include/llvm/Transforms/Scalar.h
  include/llvm/Transforms/Scalar/LoopUnrollPass.h
  lib/Transforms/IPO/PassManagerBuilder.cpp
  lib/Transforms/Scalar/LoopUnrollPass.cpp
  test/Transforms/LoopUnroll/disable-loop-unrolling_forced.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55716.178269.patch
Type: text/x-patch
Size: 12096 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181214/fd9823dd/attachment.bin>


More information about the llvm-commits mailing list