[llvm] [AMDGPU] Fix negative immediate offset for unbuffered smem loads (PR #89165)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 21 12:04:23 PDT 2024


================
@@ -2912,7 +2914,14 @@ uint64_t convertSMRDOffsetUnits(const MCSubtargetInfo &ST,
 }
 
 std::optional<int64_t> getSMRDEncodedOffset(const MCSubtargetInfo &ST,
-                                            int64_t ByteOffset, bool IsBuffer) {
+                                            int64_t ByteOffset, bool IsBuffer,
+                                            bool HasSOffset) {
+  // For unbuffered smem loads, it is illegal for the Immediate Offset to be
+  // negative if the resulting (Offset + (M0 or SOffset or zero) is negative.
+  // Handle case where SOffset is not present.
+  if (!IsBuffer && hasSMRDSignedImmOffset(ST) && !HasSOffset && ByteOffset < 0)
----------------
arsenm wrote:

Keep the subtarget check last like in the other case 

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


More information about the llvm-commits mailing list