This is an archive of the discontinued LLVM Phabricator instance.

[LSR] Filter for postinc formulae
ClosedPublic

Authored by dmgreen on May 19 2020, 11:45 PM.

Details

Summary

In more complicated loops we can easily hit the complexity limits of loop strength reduction. If we do and filtering occurs, it's all too easy to remove the wrong formulae for post-inc preferring accesses due to it attempting to maximise register re-use. The patch adds an alternative filtering step when the target is preferring postinc to pick postinc formulae instead, hopefully lowering the complexity to below the limit so that aggressive filtering is not needed.

There is also a change in here to stop considering existing addrecs as free under postinc. We should already be modelling them as a reg so don't want it to cause us to get the cost wrong. (I'm not sure that code makes sense in general, but there are X86 tests specifically for it where it seems to be helping so have left it around for the standard non-post-inc case).

Diff Detail

Event Timeline

dmgreen created this revision.May 19 2020, 11:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 19 2020, 11:45 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
samparker accepted this revision.May 20 2020, 1:39 AM

I thought hexagon also took advantage of this logic, so I'm surprised that there's not any changes for them. Anyway, LGTM.

This revision is now accepted and ready to land.May 20 2020, 1:39 AM
sgundapa accepted this revision.May 20 2020, 2:53 PM

Thanks for the patch David.
I do see this patch generating post-incs in at-least one of the tests I have.

This revision was automatically updated to reflect the committed changes.