This is an archive of the discontinued LLVM Phabricator instance.

[LoopUnrollAndJam] Allow unroll and jam loops forced by user.
ClosedPublic

Authored by Whitney on Sep 16 2020, 12:13 PM.

Details

Summary

Allow unroll and jam loops forced by user.
LoopUnrollAndJamPass is still disabled by default in the NPM pipeline, and can be controlled by -enable-npm-unroll-and-jam.

Diff Detail

Unit TestsFailed

Event Timeline

Whitney created this revision.Sep 16 2020, 12:13 PM
Whitney requested review of this revision.Sep 16 2020, 12:13 PM

Why is this specific to the PowerPC-backend. Doesn't the LoopUnrollAndJamPass pick-up the transformation metadata already?

Whitney added a comment.EditedSep 16 2020, 6:36 PM

Why is this specific to the PowerPC-backend. Doesn't the LoopUnrollAndJamPass pick-up the transformation metadata already?

When -enable-npm-unroll-and-jam is false (default), LoopUnrollAndJamPass doesn't unroll and jam any loops, no matter UP.UnrollAndJam is true or not.
When -enable-npm-unroll-and-jam is true, LoopUnrollAndJamPass try to unroll and jam all loops with UP.UnrollAndJam set to true.
When invoking LoopUnrollAndJamPass directly, LoopUnrollAndJamPass doesn't unroll and jam any loops when UP.UnrollAndJam is false, even if the loops have the unroll and jam metadata.

UP.UnrollAndJam is only set to true on ARM, or by option allow-unroll-and-jam. We want to allow unroll and jam loops on PowerPC, but only if they are forced by user for now.

I guess in my mind unroll and jam was a lot like runtime loop unrolling, which has to be enabled per target.

If there is an explicit pragma though, that does sound like it should override the targets default decision. I think the logic in tryToUnrollAndJamLoop could be updated to handle that.

A test for that would be good to see too.

Whitney updated this revision to Diff 292497.Sep 17 2020, 7:31 AM
Whitney retitled this revision from [PPC][LoopUnrollAndJam] Allow unroll and jam loops forced by user. to [LoopUnrollAndJam] Allow unroll and jam loops forced by user..
Whitney added a reviewer: dmgreen.
dmgreen accepted this revision.Sep 17 2020, 10:13 AM

Nice. I was worried this would be a bit convoluted, but it's clean like this just setting UP.UnrollAndJam.

LGTM

This revision is now accepted and ready to land.Sep 17 2020, 10:13 AM

Thanks for the fix!

llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp
303–304 ↗(On Diff #292497)

Seems the culprit was probably this line, making the backend's decision to not unroll a higher priority than the user's.

Meinersbur accepted this revision.Sep 17 2020, 10:17 AM
This revision was landed with ongoing or failed builds.Sep 17 2020, 12:40 PM
This revision was automatically updated to reflect the committed changes.
Whitney marked an inline comment as done.
Whitney added inline comments.Sep 17 2020, 12:42 PM
llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp
303–304 ↗(On Diff #292497)

I think now we get the priority right, 1. Option AllowUnrollAndJam 2. User pragma 3. backend's decision. :)