[PATCH] D126392: [RISCV] Use two ADDIs to do some stack pointer adjustments.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 27 08:56:31 PDT 2022
craig.topper added inline comments.
================
Comment at: llvm/lib/Target/RISCV/RISCVFrameLowering.cpp:315
+ // it can be created with LUI.
+ int64_t MaxAdj = 2048 - getStackAlign().value();
+ if (Val > -4096 && Val <= (2 * MaxAdj)) {
----------------
reames wrote:
> reames wrote:
> > luismarques wrote:
> > > Nit: `MaxAdj` -> `MaxAdjStep`
> > Hm, I think you can do slightly better here.
> >
> > 2048 is an 11 bit value. This makes sense as you need the high bit to be zero (since immediates are sign extended).
> >
> > However, since you're subtracting off a non-zero value, I think you can actually use 4096 as your starting value. That *isn't* representable as a positive 12 bit value, but every value *less than* that is.
> >
> Ignore this. I managed to misread my hex values. 2048 is correct here in exactly the way I was suggesting for 4096.
Maybe I should mention that this line was taken directly from RISCVFrameLowering::getFirstSPAdjustAmount.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126392/new/
https://reviews.llvm.org/D126392
More information about the llvm-commits
mailing list