This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Optimize scalable frame setup when VLEN is precisely known
ClosedPublic

Authored by reames on Nov 7 2022, 2:57 PM.

Details

Summary

If we know the exact value of VLEN, the frame offset adjustment for scalable stack slots becomes a fixed constant. This avoids the need to read vlenb, and may allow the offset to be folded into the immediate field of an add/sub.

We could go further here, and fold the offset into a single larger frame adjustment - instead of having a separate scalable adjustment step - but that requires a bit more code reorganization. I may (or may not) return to that in a future patch.

Diff Detail

Event Timeline

reames created this revision.Nov 7 2022, 2:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 7 2022, 2:57 PM
reames requested review of this revision.Nov 7 2022, 2:57 PM
craig.topper requested changes to this revision.Nov 18 2022, 9:17 AM
craig.topper added inline comments.
llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
403

Move vreg creation to line 402?

llvm/test/CodeGen/RISCV/rvv/rv64-spill-vector-csr.ll
90

This instruction doesn't exist. You need addi sp, sp, -512

107

addi sp, sp, 512

This revision now requires changes to proceed.Nov 18 2022, 9:17 AM
reames updated this revision to Diff 476558.Nov 18 2022, 12:14 PM

Restructure to address @craig.topper's comments. Thanks for catching that bug.

reames updated this revision to Diff 476570.Nov 18 2022, 12:43 PM

Realized I was duplicating logic which already existed. I also had the same off by a factor of 8 bug as the prior patch.

reames updated this revision to Diff 476571.Nov 18 2022, 12:44 PM

Uploaded wrong patch version.

This revision is now accepted and ready to land.Nov 18 2022, 1:56 PM
This revision was landed with ongoing or failed builds.Nov 18 2022, 3:37 PM
This revision was automatically updated to reflect the committed changes.