This is an archive of the discontinued LLVM Phabricator instance.

[RISC-V] Implement RISCVInstrInfo::isCopyInstrImpl()
ClosedPublic

Authored by arichardson on Aug 25 2020, 4:25 AM.

Details

Summary

This does not result in changes for any of the current tests, but it might
improve debug information in some cases.

Diff Detail

Event Timeline

arichardson created this revision.Aug 25 2020, 4:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2020, 4:25 AM
arichardson requested review of this revision.Aug 25 2020, 4:25 AM

This is technically correct, but looking at the other targets it seems that the hook is generally being used more restrictively for instructions where you actually have some expectation of it being a copy/move. Do we really want to go down this route? In principle we'd have to later expand this to e.g. all of the bitmanip instructions that can implement copies and so on, which seems a bit like a reductio ad absurdum. Having tests showing at least a little bit of benefit would help make the case for this patch :-)

Drop additional cases, keeping only the ones also listed in isAsCheapAsAMove().

luismarques added inline comments.Sep 2 2020, 6:44 AM
llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
541–542

Do the ORI, XORI cases also provide a measurable benefit here, as they do for isAsCheapAsAMove? Taking a step back, is there a principled way to decide which instructions we include? I can see two cases that are easy to defend: (1) keeping only canonical move instructions; (2) adding all instructions that provide some benefit. Without tests it's not obvious to me that ORI and XORI fit the second case. Did you check if the commits for other uses of this hook had tests that we could adapt?

luismarques accepted this revision.Sep 17 2020, 1:55 AM

I was hoping others would chime in regarding what instructions should be handled in this hook.

@arichardson How do you feel about removing the ORI/XORI and landing this patch? (I also have no major objections to just landing as is). We can always further improve it later. Ideally this would add tests, but if that's not easy I think it's OK to land it as is.

This revision is now accepted and ready to land.Sep 17 2020, 1:55 AM

I was hoping others would chime in regarding what instructions should be handled in this hook.

@arichardson How do you feel about removing the ORI/XORI and landing this patch? (I also have no major objections to just landing as is). We can always further improve it later. Ideally this would add tests, but if that's not easy I think it's OK to land it as is.

Sure, will do that.

I was hoping others would chime in regarding what instructions should be handled in this hook.

@arichardson How do you feel about removing the ORI/XORI and landing this patch? (I also have no major objections to just landing as is). We can always further improve it later. Ideally this would add tests, but if that's not easy I think it's OK to land it as is.

Sure, will do that.

Yeah I agree without further info I think we should land just the canonical moves.

llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
548
This revision was automatically updated to reflect the committed changes.