This is an archive of the discontinued LLVM Phabricator instance.

[LSR] Cleanup of getPreferredAddresingMode. NFC.
ClosedPublic

Authored by SjoerdMeijer on Feb 16 2021, 5:25 AM.

Details

Summary

This is a follow up D96600 and cleans up all calls to getPreferredAddresingMode. i.e., we really don't need to query the same things again and again, but get the preferred addressing mode once. So this should be a lot friendlier for compile times, especially if we start implementing getPreferredAddresingMode.

Diff Detail

Event Timeline

SjoerdMeijer created this revision.Feb 16 2021, 5:25 AM
SjoerdMeijer requested review of this revision.Feb 16 2021, 5:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 16 2021, 5:25 AM
dmgreen added inline comments.Feb 16 2021, 8:56 AM
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
5565

Should the EnableBackedgeIndexing option override what the target defines? Or could it be removed, or replaced?

SjoerdMeijer added inline comments.Feb 16 2021, 9:08 AM
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3810

Should the EnableBackedgeIndexing option override what the target defines? Or could it be removed, or replaced?

Good point. I think in general an option takes precedence, but that's not really happening here.

I think haIving an option for this would be good (I noticed it would at least be convenient for testing), which accepts values that match the values this hook returns: preindexed, postindexed, and none. I was thinking of doing that as a follow up of this NFC, so that would mean generalising and renaming this EnableBackedgeIndexing if that sounds like a good idea (so leave this as a NFC).

samparker added inline comments.Feb 16 2021, 9:11 AM
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3810

I was also going to suggest, in the previous patch, to just remove the option. I just added it for testing and I don't think it's useful now.

fhahn accepted this revision.Feb 16 2021, 1:28 PM

LGTM, the target's preferred addressing mode should be independent of the contents of the loop, which may change between the different calls in the original code.

Please resolve @dmgreen's comment before landing. For me, adjusting EnableBackedgeIndexing handling would be fine as a follow up.

This revision is now accepted and ready to land.Feb 16 2021, 1:28 PM

Thanks guys.

I will commit this to get this NFC out of the way, and then follow up shortly to make some changes to options as I also found that's convenient to have for testing.
I will rename EnableBackedgeIndexing to PreferredAddressingMode, and let it accept the 3 values corresponding to the enum values of AddressingModeKind.

This revision was automatically updated to reflect the committed changes.