[PATCH] Use loop unrolling pragma metadata in the loop unroller (take 2)

Mark Heffernan meheff at google.com
Mon Jun 16 01:24:39 PDT 2014


Hi eliben, hfinkel, reames,

This is the second attempt at adding support for using the unrolling pragma metadata in the loop unroller.  The previous patch (r210721) was reverted as it was a suspect in test failures (root cause was determined to be a different patch).

Again, here are the supported pragmas and their meaning (they are passed through the IR as metadata):

#pragma clang loop unroll(enable)  // unroll the loop completely
#pragma clang loop unroll(disable)  // do not unroll the loop.
#pragma clang loop unroll_count(N)  // unroll the loop N time

If the unroller is unable to unroll the loop as directed by the pragma then the unroller will still generally be more aggressive than the default limits.

This change includes more refactoring than the original patch.  After a second look, I felt this was necessary as the original logic was a bit convoluted and layering on the pragma handling just made it worse.  Hopefully this change makes it easier to understand.

Hal, this addresses your suggestions of making the pragma unroll limit a cl opt and a size threshold (rather than an unroll count), also it emits optimization remarks if the loop cannot be unrolled as directed by the pragma.

http://reviews.llvm.org/D4147

Files:
  lib/Transforms/Scalar/LoopUnrollPass.cpp
  test/Transforms/LoopUnroll/unroll-pragmas.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4147.10421.patch
Type: text/x-patch
Size: 17788 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140616/5e61ceda/attachment.bin>


More information about the llvm-commits mailing list