[llvm] AMDGPU: Only allow 31bit positive offset for scratch (PR #71895)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 14 22:37:20 PST 2023


================
@@ -1859,7 +1859,7 @@ bool AMDGPUDAGToDAGISel::SelectScratchSVAddr(SDNode *N, SDValue Addr,
       std::tie(SplitImmOffset, RemainderOffset)
         = TII->splitFlatOffset(COffsetVal, AMDGPUAS::PRIVATE_ADDRESS, true);
 
-      if (isUInt<32>(RemainderOffset)) {
+      if (RemainderOffset > 0 && isInt<32>(RemainderOffset)) {
----------------
arsenm wrote:

I think it's good to get all the edge cases right, even if it's an unrealistically large allocation. We haven't sorted out how TLS should work, but it's possible we'll end up using scratch instructions to access it at weird offsets 

https://github.com/llvm/llvm-project/pull/71895


More information about the llvm-commits mailing list