This is an archive of the discontinued LLVM Phabricator instance.

[LoongArch] Split SP adjustment
ClosedPublic

Authored by wangleiat on Oct 18 2022, 8:00 PM.

Details

Summary

This patch split the SP adjustment to reduce the instructions in
prologue and epilogue. In this way, the offset of the callee saved
register could fit in a single store.

Similar to D68011(RISCV).

Depends on D136074

Diff Detail

Event Timeline

wangleiat created this revision.Oct 18 2022, 8:00 PM
wangleiat requested review of this revision.Oct 18 2022, 8:00 PM
SixWeining accepted this revision.Oct 23 2022, 6:06 AM

LGTM.

llvm/lib/Target/LoongArch/LoongArchFrameLowering.cpp
302

Nit: Inline one-time-used variable.

llvm/test/CodeGen/LoongArch/stack-realignment.ll
557

With the addition of this patch, 7 instructions are reduced for this function.

This revision is now accepted and ready to land.Oct 23 2022, 6:06 AM
Allen added a subscriber: Allen.Oct 23 2022, 8:18 AM
Allen added inline comments.
llvm/test/CodeGen/LoongArch/split-sp-adjust.ll
6

Sorry for the naive question: do you split the offset of SP as the constraint of the load/store, which should be less than 2048 ?

wangleiat updated this revision to Diff 470031.Oct 23 2022, 7:09 PM

Address @SixWeining's comments.

wangleiat added inline comments.Oct 23 2022, 7:10 PM
llvm/lib/Target/LoongArch/LoongArchFrameLowering.cpp
302

Nit: Inline one-time-used variable.

Ok, I will fix it.

llvm/test/CodeGen/LoongArch/split-sp-adjust.ll
6

Thank you very much for your interest in LoongArch.
As you guessed, if we don't split the adjustment of SP, the load/store for callee-saved registers will use multiple instructions when offset >= 2048.

wangleiat updated this revision to Diff 471431.Oct 28 2022, 1:17 AM

Rebase and added some spaces.

This revision was landed with ongoing or failed builds.Oct 28 2022, 1:40 AM
Closed by commit rGf589e5067fc8: [LoongArch] Split SP adjustment (authored by wangleiat, committed by SixWeining). · Explain Why
This revision was automatically updated to reflect the committed changes.