[PATCH] D126392: [RISCV] Use two ADDIs to do some stack pointer adjustments.

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 27 08:52:35 PDT 2022


reames 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:
> 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.  


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