This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Support (addi (addi globaladdr, C1), C2) in RISCVMergeBaseOffset.
ClosedPublic

Authored by craig.topper on Jun 1 2022, 5:59 PM.

Details

Summary

Add with immediates in the range [-4096, -2049] or [2048, 4095] get
convert to two ADDIs. Teach RISCVMergeBaseOffset to recognize this
pattern as well.

Diff Detail

Event Timeline

craig.topper created this revision.Jun 1 2022, 5:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2022, 5:59 PM
craig.topper requested review of this revision.Jun 1 2022, 5:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2022, 5:59 PM
luismarques accepted this revision.Jun 8 2022, 7:25 AM

LGTM.

llvm/lib/Target/RISCV/RISCVMergeBaseOffset.cpp
209–223

BTW, shouldn't the preexisting code check the type of the tail ADDI immediate machine operand (that it is MO_Immediate or something like that)? If so, then the same applies to this second ADDI.

This revision is now accepted and ready to land.Jun 8 2022, 7:25 AM
craig.topper added inline comments.Jun 8 2022, 8:13 AM
llvm/lib/Target/RISCV/RISCVMergeBaseOffset.cpp
209–223

I think it has to be an immediate because we started from a global address LUI+ADDI pair. Any user of that could only be an ADDI with a real immediate. It couldn't be part of another global address and it couldn't be a frame index.

This revision was landed with ongoing or failed builds.Jun 8 2022, 8:26 AM
This revision was automatically updated to reflect the committed changes.