This is an archive of the discontinued LLVM Phabricator instance.

Enable runtime unrolling with unroll pragma metadata
AcceptedPublic

Authored by meheff on Jun 30 2015, 4:35 PM.

Details

Reviewers
broune
hfinkel
Summary

Enable runtime unrolling for loops with unroll count metadata ("#pragma unroll N")
and a runtime trip count. Also, do not unroll loops with unroll full metadata if the
loop has a runtime loop count. Previously, such loops would be unrolled with a
very large threshold (pragma-unroll-threshold) if runtime unrolled happened to be
enabled resulting in a very large (and likely unwise) unroll factor.

Diff Detail

Event Timeline

meheff updated this revision to Diff 28824.Jun 30 2015, 4:35 PM
meheff retitled this revision from to Enable runtime unrolling with unroll pragma metadata.
meheff updated this object.
meheff edited the test plan for this revision. (Show Details)
meheff added a reviewer: hfinkel.
meheff set the repository for this revision to rL LLVM.
meheff added a subscriber: Unknown Object (MLST).
broune accepted this revision.Jun 30 2015, 8:34 PM
broune edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Jun 30 2015, 8:34 PM
hfinkel accepted this revision.Jul 2 2015, 4:39 PM
hfinkel edited edge metadata.

LGTM. But please don't commit this until my comment in D10857 is addressed.

meheff updated this revision to Diff 29424.Jul 9 2015, 8:16 PM
meheff updated this object.
meheff edited edge metadata.
meheff removed rL LLVM as the repository for this revision.

Update unrolling behavior for unroll(full) directive as discussed in http://reviews.llvm.org/D10857.

meheff added a comment.Jul 9 2015, 8:29 PM

Hal,

From your earlier comments it wasn't clear whether you were suggesting that
the front end should add unroll.full and unroll.disable.runtime metadata
with "#pragma unroll" OR if unroll.full metadata should imply no runtime
unrolling in the optimizer. I opted for the latter. It seemed more natural
for the front-end just to do a straight-forward map of the directives to
metadata, and then the optimizer has the logic to properly deal with funny
cases like pragma unroll on a runtime trip count loop.

Mark

Hal,

From your earlier comments it wasn't clear whether you were suggesting that
the front end should add unroll.full and unroll.disable.runtime metadata
with "#pragma unroll" OR if unroll.full metadata should imply no runtime
unrolling in the optimizer. I opted for the latter. It seemed more natural
for the front-end just to do a straight-forward map of the directives to
metadata, and then the optimizer has the logic to properly deal with funny
cases like pragma unroll on a runtime trip count loop.

Yes, makes sense to me. Specifically requesting full unrolling on a loop with a non-static trip count does not make sense, and the optimizer should ignore it.

Mark