[all-commits] [llvm/llvm-project] eb26ed: [RISCV] Exploit sh3add/sh2add for stack offsets by...

Philip Reames via All-commits all-commits at lists.llvm.org
Mon Apr 8 14:53:43 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: eb26edbbf8479aacac0b03413159c8836994a734
      https://github.com/llvm/llvm-project/commit/eb26edbbf8479aacac0b03413159c8836994a734
  Author: Philip Reames <preames at rivosinc.com>
  Date:   2024-04-08 (Mon, 08 Apr 2024)

  Changed paths:
    M llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
    M llvm/test/CodeGen/RISCV/prolog-epilogue.ll
    M llvm/test/CodeGen/RISCV/stack-offset.ll

  Log Message:
  -----------
  [RISCV] Exploit sh3add/sh2add for stack offsets by shifted 12-bit constants (#87950)

If we're falling back to generic constant formation in a register +
add/sub, we can check if we have a constant which is 12-bits but left
shifted by 2 or 3. If so, we can use a sh2add or sh3add to perform the
shift and add in a single instruction.

This is profitable when the unshifted constant would require two
instructions (LUI/ADDI) to form, but is never harmful since we're going
to need at least two instructions regardless of the constant value.

Since stacks are aligned to 16 bytes by default, sh3add allows addresing
(aligned) data out to 2^14 (i.e. 16kb) in at most two instructions
w/zba.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list