[PATCH] D126729: [RISCV] Support LUI+ADDIW in RISCVMergeBaseOffsetOpt::matchLargeOffset.

Luís Marques via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 8 06:59:46 PDT 2022


luismarques accepted this revision.
luismarques added a comment.
This revision is now accepted and ready to land.

In D126729#3566171 <https://reviews.llvm.org/D126729#3566171>, @luismarques wrote:

> Could this interact badly with the medlow upper address space bound of `0x000000007FFFF7FF`?

I guess not, while the `addiw` -> `addi` change isn't safe to represent any simm32 on RV64, it's going to error out in the linker with out-of-bounds `%hi` and `%lo`.

To clarify, I was thinking about whether something like this could happen:

Before (non-folded offset computed with `addiw`):

  lui     a0, 0x80000
  addiw   a0, a0, -2047
  a0 == 0x000000007ffff801

After (folded, using `addi`):

  lui     a0, 0x80000
  addi    a0, a0, -2047
  a0 == 0xffffffff7ffff801

LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126729/new/

https://reviews.llvm.org/D126729



More information about the llvm-commits mailing list