This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Fold (add X, [-4096, -2049]) or (add X, [2048,4096]) into load/store address during isel.
ClosedPublic

Authored by craig.topper on Jun 28 2022, 10:10 AM.

Details

Summary

Previously we iseled this to a pair of ADDIs and relied on a post
isel peephole to fold one of the ADDIs into the load/store. Now
we split the immediate in two parts the same way isel does and fold
one of the pieces. If the add has a non-memory use it will emit
two isels and larger one will CSE with the ADDI we created for the
the memory use.

Diff Detail

Event Timeline

craig.topper created this revision.Jun 28 2022, 10:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 28 2022, 10:10 AM
craig.topper requested review of this revision.Jun 28 2022, 10:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 28 2022, 10:10 AM

Code is fine, but no tests?

Code is fine, but no tests?

I don't have a good way to show the change. The post-isel peephole already cleans this up. This is matching it earlier. I'm trying to remove the post-isel peephole.

asb added a comment.EditedJun 28 2022, 11:47 AM

Code is fine, but no tests?

I don't have a good way to show the change. The post-isel peephole already cleans this up. This is matching it earlier. I'm trying to remove the post-isel peephole.

So is this patch going to be updated to also remove the peephole? (just checking I'm following the planned staging of changes here!)

Code is fine, but no tests?

I don't have a good way to show the change. The post-isel peephole already cleans this up. This is matching it earlier. I'm trying to remove the post-isel peephole.

So is this patch going to be updated to also remove the peephole? (just checking I'm following the planned staging of changes here!)

We also have custom isel code for (add X, C) used by memory operations where C isn't a simm12 or suitable for addi pair. That code generates an (addi (X, C1-LoC), LoC) and relies on the peephole to fold the addi. We need to move that into the SelectRegAddrImm too. Then the peephole can be removed.

reames accepted this revision.Jun 28 2022, 1:43 PM

LGTM

This revision is now accepted and ready to land.Jun 28 2022, 1:43 PM
This revision was landed with ongoing or failed builds.Jun 28 2022, 5:00 PM
This revision was automatically updated to reflect the committed changes.