[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:50:49 PDT 2022


reames added a comment.

Minor improvement noted after LGTM.  Feel free to roll into approved patch if you agree with my comment.



================
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)) {
----------------
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.  



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