This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Enable UpperBound unrolling for all loops
ClosedPublic

Authored by dmgreen on Mar 23 2021, 4:51 AM.

Details

Summary

This UpperBound unrolling was already enabled so long as a series of conditions in ARMTTIImpl::getUnrollingPreferences pass. This just always enables it as it can help fully unroll loops that would not otherwise pass those tests.

Diff Detail

Event Timeline

dmgreen created this revision.Mar 23 2021, 4:51 AM
dmgreen requested review of this revision.Mar 23 2021, 4:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 23 2021, 4:51 AM
SjoerdMeijer added inline comments.Mar 23 2021, 5:02 AM
llvm/test/Transforms/LoopUnroll/ARM/upperbound.ll
78

I find this test change a bit difficult to read. What exactly is changing here?
This first check here s just a check to see if the loop executes at all, but from the other changes below I find it difficult to see if this gets now unrolled or if there are other changes.

dmgreen added inline comments.Mar 23 2021, 6:29 AM
llvm/test/Transforms/LoopUnroll/ARM/upperbound.ll
78

It is getting fully unrolled, which combined with the array values becoming constant and known, managed to simplify most of the unrolled code away. I was just using it as an example of something that will now be unrolled beneficially.

SjoerdMeijer added inline comments.Mar 23 2021, 1:38 PM
llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
2130

Looking at this again, I am now confused why we always want to enable this while....

2139

... here we check of Oz and Os. So we could bail here, but still set UpperBound to true. Is that correct or what we want?

llvm/test/Transforms/LoopUnroll/ARM/upperbound.ll
78

Ah, okay, got it, cheers.

dmgreen added inline comments.Mar 24 2021, 12:35 AM
llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
2139

The loop unroller will already handle Oz and Os correctly, and I think these values are already the same as the defaults it has.

The loop unroller will only unroll loops if it thinks the size will be less after unrolling than the size of the loop. So very rarely, and usually only for loops with 1 or 2 iterations.

UpperBound should not change that and should be safe to always enable.

SjoerdMeijer accepted this revision.Mar 24 2021, 1:55 AM
SjoerdMeijer added inline comments.
llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
2139

Okidoki, thanks, LGTM.

This revision is now accepted and ready to land.Mar 24 2021, 1:55 AM
This revision was landed with ongoing or failed builds.Mar 24 2021, 9:39 AM
This revision was automatically updated to reflect the committed changes.