This is an archive of the discontinued LLVM Phabricator instance.

[LoongArch] Make use of addu16i.d for adds with suitable immediates
ClosedPublic

Authored by xen0n on Feb 10 2023, 1:32 AM.

Details

Summary

Ideally addu16i.d could be paired with {ld,st}ptr for faster memory
accesses with 32-bit-aligned offsets (it was designed for this purpose),
but it would require more work and the original use case (GP-relative
accesses) does not exist any more with the current LoongArch psABI.

It could still be used for accelerating additions of certain constants
though, which is what this patch intends to do.

Diff Detail

Event Timeline

xen0n created this revision.Feb 10 2023, 1:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 10 2023, 1:32 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
xen0n requested review of this revision.Feb 10 2023, 1:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 10 2023, 1:32 AM
SixWeining added inline comments.Feb 10 2023, 1:55 AM
llvm/test/CodeGen/LoongArch/ir-instruction/add.ll
186

Thanks.

Mabbe you can add these as baseline tests (no-functional-change or NFC patch) :)
https://github.com/llvm/llvm-project/blob/main/llvm/docs/TestingGuide.rst#precommit-workflow-for-tests

xen0n added inline comments.Feb 10 2023, 3:03 AM
llvm/test/CodeGen/LoongArch/ir-instruction/add.ll
186

Okay I'll split patches shortly. Thanks for the suggestion.

xen0n updated this revision to Diff 496755.Feb 12 2023, 4:42 AM

Rebase & split tests out & implement matching of paired addu16i.d + addi patterns

xen0n retitled this revision from [LoongArch] Emit addu16i.d for simple adds with eligible immediates to [LoongArch] Make use of addu16i.d for adds with suitable immediates.Feb 12 2023, 4:43 AM
xen0n edited the summary of this revision. (Show Details)
xen0n marked an inline comment as done.Feb 12 2023, 4:45 AM
SixWeining accepted this revision.Feb 12 2023, 6:53 PM

Thanks for the improvements. LGTM. What do others think?

This revision is now accepted and ready to land.Feb 12 2023, 6:53 PM
gonglingqin accepted this revision.Feb 12 2023, 7:56 PM

LGTM. Thanks!

This revision was landed with ongoing or failed builds.Feb 14 2023, 5:17 PM
This revision was automatically updated to reflect the committed changes.