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

via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 21 00:08:59 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)) {
----------------
ruiling wrote:

While we can write LLVM IR like: `%ptr = getelementptr inbounds i8, ptr addrspace(5) %arg, i64 u0x80000000` for a positive offset with 31bit being one, it will be lowered into `t4: i32 = add t2, Constant:i32<-2147483648>` as our private address is 32bit. Seems like we cannot make a test to show difference here.

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


More information about the llvm-commits mailing list