[PATCH] D79690: [RISCV] Fold ADDIs into load/stores with nonzero offsets

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 24 11:55:48 PDT 2020


efriedma added inline comments.


================
Comment at: llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp:231
+      // Check if off2 falls within that margin; if so off1+off2 can't overflow.
+      unsigned Alignment = GA->getGlobal()->getAlignment();
+      if (Offset2 != 0 && Offset2 >= Alignment)
----------------
luismarques wrote:
> efriedma wrote:
> > FYI, D80368 removes GlobalValue::getAlignment().  Value::getPointerAlignment() is the suggested replacement.
> Thanks for the heads-up. I guess in this case we want `GlobalObject::getAlignment()`? If I understand correctly, that's the one that gives the alignment of the variable itself, which is what we need to rely upon to obtain the margin of safety before the 12-bit immediate overflow can occur.
`GlobalObject::getAlignment()` is deprecated in favor of `GlobalObject::getAlign()`.

Using `GlobalObject::getAlign()` isn't wrong, but it's probably not the best approach.  In this context, probably the biggest issue is that it can return None; you can handle that conservatively, but handling it correctly is sort of tricky.  `getPointerAlignment()` wraps up all the necessary logic in a single call.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79690





More information about the llvm-commits mailing list