This is an archive of the discontinued LLVM Phabricator instance.

Do not add unroll disable metadata after unrolling pass for loops with #pragma clang loop unroll(full)
ClosedPublic

Authored by meheff on Jul 23 2014, 11:43 AM.

Details

Reviewers
jingyue
Summary

Currently all loop unrolling hint metadata is removed after a loop is unrolled and this metadata is replaced with metadata which disables further unrolling (llvm.loop.unroll.disable). This makes sense for the hint which specify loop unroll factor, that is "llvm.loop.unroll.count N" which would be added for "#pragma clang loop unroll_count(N)"). This prevents unrolling beyond what the pragma specified. However, disabling further unrolling doesn't make sense for full unrolling metadata in which we want to keep trying to unroll the loop in subsequent unrolling passes. This patch fixes this oversight by leaving full unrolling metadata in place after unrolling.

Mark

Diff Detail

Event Timeline

meheff updated this revision to Diff 11815.Jul 23 2014, 11:43 AM
meheff retitled this revision from to Do not add unroll disable metadata after unrolling pass for loops with #pragma clang loop unroll(full).
meheff updated this object.
meheff edited the test plan for this revision. (Show Details)
meheff added a reviewer: jingyue.
meheff added a subscriber: Unknown Object (MLST).
jingyue edited edge metadata.Jul 23 2014, 12:01 PM

LGTM with some minor comments. Thanks!

lib/Transforms/Scalar/LoopUnrollPass.cpp
460

I'd say PragmaCount != 0 because it's an integer.

test/Transforms/LoopUnroll/unroll-pragmas-disabled.ll
41

To be clear, can we explain why this loop cannot be unrolled?

56

Would it be better if we make the trip count a variable, so that the loop can't be unrolled regardless of the threshold? I think that would make the test more resilience.

Thanks! Committed with r213789.

lib/Transforms/Scalar/LoopUnrollPass.cpp
460

Done.

test/Transforms/LoopUnroll/unroll-pragmas-disabled.ll
41

Done.

56

Done. Trip count is now dynamic.

jingyue accepted this revision.Jul 23 2014, 2:45 PM
jingyue edited edge metadata.
This revision is now accepted and ready to land.Jul 23 2014, 2:45 PM
jingyue closed this revision.Jul 23 2014, 2:45 PM