[PATCH] D139645: [WebAssembly] Fold adds with global addresses into load offset

Luke Lau via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 12 01:49:19 PST 2022


luke added inline comments.


================
Comment at: llvm/lib/Target/WebAssembly/WebAssemblyRegisterInfo.cpp:78-92
+    auto &OffsetOp = MI.getOperand(OffsetOperandNum);
+    // Don't fold offset in if offset is a global address to be resolved later
+    if (OffsetOp.isImm()) {
+      assert(FrameOffset >= 0 && OffsetOp.getImm() >= 0);
+      int64_t Offset = OffsetOp.getImm() + FrameOffset;
+
+      if (static_cast<uint64_t>(Offset) <=
----------------
Now that (add tga x) is now selected into something like i32.load offset=tga, x, the above assertion was being triggered because it assumed that any offset operand would always be an immediate, not a target global address. So this just wraps around it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139645



More information about the llvm-commits mailing list