This is an archive of the discontinued LLVM Phabricator instance.

[LoopUnroll] Clean up remarks for unroll remainder
ClosedPublic

Authored by dmgreen on Oct 10 2017, 6:21 AM.

Details

Summary

The optimisation remarks for loop unrolling with an unrolled remainder looks something like:

test.c:7:18: remark: completely unrolled loop with 3 iterations [-Rpass=loop-unroll]
            C[i] += A[i*N+j];
                 ^
test.c:6:9: remark: unrolled loop by a factor of 4 with run-time trip count [-Rpass=loop-unroll]
        for(int j = 0; j < N; j++)
        ^

This removes the first of the two messages.

Diff Detail

Repository
rL LLVM

Event Timeline

dmgreen created this revision.Oct 10 2017, 6:21 AM
fhahn added inline comments.Oct 10 2017, 10:53 AM
lib/Transforms/Utils/LoopUnroll.cpp
504 ↗(On Diff #118371)

Do I understand correctly that we want to only display this remark in case the following condition is true, so if we successfully unrolled the loop with a run-time trip count (condition at line 428)?

RuntimeTripCount && TripMultiple % Count != 0 && 
     UnrollRuntimeLoopRemainder(....)

I am probably missing something, but it seems like this code path does not consider the TripMultiple % Count != 0 from the condition.

Hello again. Thanks for taking a look.

lib/Transforms/Utils/LoopUnroll.cpp
504 ↗(On Diff #118371)

Currently with -unroll-runtime=true -unroll-remainder (like we have for cortex-m cores), the remainder loop is unrolled. It does this by calling UnrollLoop() from inside UnrollRuntimeLoopRemainder(). When that happens we get two remarks, one from the "outer" UnrollLoop for the original loop, one from the inner UnrollLoop() for the remainder loop. I'm trying to remove that second one for the remainder loop.

Clang-format moved things around a bit here, but I've just made it so that the ORE is optional, and not passed through to the inner UnrollRuntimeLoopRemainder/UnrollLoop.

fhahn added a comment.Oct 25 2017, 2:21 AM

LGTM, please consider moving the test.

lib/Transforms/Utils/LoopUnroll.cpp
504 ↗(On Diff #118371)

Ah yes. Not sure what I was looking at when I left the comment.

test/Transforms/LoopUnroll/runtime-unroll-remainder.ll
2 ↗(On Diff #118371)

I think it would make sense to move the test to test/Transforms/LoopUnroll/loop-remarks.ll?

fhahn accepted this revision.Oct 25 2017, 2:21 AM
This revision is now accepted and ready to land.Oct 25 2017, 2:21 AM
dmgreen updated this revision to Diff 120743.Oct 29 2017, 4:21 AM

Rebase and moved test over to loop-remarks.ll

Thanks Dave, I think looks good to commit now.

This revision was automatically updated to reflect the committed changes.