This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Eagerly delete instructions in MergeBaseOffset.
ClosedPublic

Authored by craig.topper on Jul 19 2022, 1:22 PM.

Details

Summary

The only iterator we're holding points to HiLUI and we never
delete that so I think it is safe to delete everything else
immediately.

I want to split detectAndFoldOffset into two phases. First, combine
LUI+ADDI with any ADD/ADDI/SHXADD that comes after it. This may
open opportunities to fold the ADDI from the LUI+ADDI into a
load/store address. So the load/store folding should run as a
second phase even if the ADD/ADDI/SHXADD made changes.

In order to do this we need to eagerly delete instructions in the
first phase so that we don't have dead users of the LUI+ADDI
when we start the second phase.

Patches to split the phases will come later.

Diff Detail

Event Timeline

craig.topper created this revision.Jul 19 2022, 1:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 19 2022, 1:22 PM
craig.topper requested review of this revision.Jul 19 2022, 1:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 19 2022, 1:22 PM
asb added a comment.Jul 21 2022, 2:47 AM

The change seems functionally correct to me, and the reasoning for the change makes sense. I think the comments for each modified function just need to be updated.

llvm/lib/Target/RISCV/RISCVMergeBaseOffset.cpp
70–72

Comment needs updating to reflect this mutates the MBB rather than just detecting the pattern

134–136

Comment needs updating to reflect this mutates the MBB rather than just detecting the pattern

209

Comment needs updating to reflect this mutates the MBB rather than just detecting the pattern

Update comments

craig.topper added inline comments.Jul 21 2022, 2:03 PM
llvm/lib/Target/RISCV/RISCVMergeBaseOffset.cpp
70–72

This code didn't get updated so I think it is still correct.

luismarques accepted this revision.Jul 29 2022, 3:33 PM

LGTM.

PS: This is going to force me to rebase D123265 again, though... :(

This revision is now accepted and ready to land.Jul 29 2022, 3:33 PM

@craig.topper Thanks for helping push D123265 through. I can rebase this for you if you want, it seems easier than the other way around.

asb accepted this revision.Aug 1 2022, 3:04 AM

LGTM, thanks for updating the comments.

This revision was landed with ongoing or failed builds.Aug 1 2022, 9:33 AM
This revision was automatically updated to reflect the committed changes.