[PATCH] D150862: [RISCV][CodeGenPrepare] Select the optimal base offset for GEPs with large offset

Luke Lau via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 19 07:02:43 PDT 2023


luke added inline comments.


================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:16341
+  // Infer type of memory ops from the result element type of GEPs to use
+  // compressed load/store insts.
+  if (Subtarget.hasStdExtCOrZca()) {
----------------
Just a heads up, using the source/result element types of GEPs to infer the type of memory access is not always accurate, I've encountered this myself in https://reviews.llvm.org/D149889

It's also mentioned in CodeGenPrepare.cpp:
```
          // The result type of the GEP might not be the type of the memory
          // access.
```

I don't think this should block this patch, I just wanted to point it out. The code here is consistent with how CodeGenPrepare is inferring it.


================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:16355
+      Alignment = DL.getPointerSize();
+      Range = 32 * Alignment; // simm5 scaled by size of XLEN
+    }
----------------
You can use `Subtarget.getXLen()`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150862



More information about the llvm-commits mailing list