[PATCH] D91308: AMDGPU: Split large offsets when selecting global saddr mode

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 12 09:06:30 PST 2020


foad added inline comments.


================
Comment at: llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp:3512
+    ImmOffset = ConstOffset;
+  } else if (ConstOffset != 0 && isSGPR(PtrBaseDef->Reg)) {
+    // Offset is too large.
----------------
Don't bother if ConstOffset is negative.


================
Comment at: llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp:3519-3521
+    // Use signed division by a power of two to truncate towards 0.
+    int64_t D = 1LL << (NumBits - 1);
+    uint64_t RemainderOffset = (static_cast<int64_t>(ConstOffset) / D) * D;
----------------
This can be a bit simpler if you know ConstOffset isn't negative, e.g. just use a right shift instead of a divide.


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

https://reviews.llvm.org/D91308



More information about the llvm-commits mailing list