[llvm] [AMDGPU] Ensure positive InstOffset for buffer operations (PR #145504)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 25 02:04:48 PDT 2025


================
@@ -4464,12 +4464,13 @@ bool AMDGPUAsmParser::validateOffset(const MCInst &Inst,
     return validateSMEMOffset(Inst, Operands);
 
   const auto &Op = Inst.getOperand(OpNum);
+  // GFX12+ buffer ops: InstOffset is signed 24, but must be positive
   if (isGFX12Plus() &&
       (TSFlags & (SIInstrFlags::MUBUF | SIInstrFlags::MTBUF))) {
     const unsigned OffsetSize = 24;
-    if (!isIntN(OffsetSize, Op.getImm())) {
+    if (!isUIntN(OffsetSize - 1, Op.getImm())) {
       Error(getFlatOffsetLoc(Operands),
-            Twine("expected a ") + Twine(OffsetSize) + "-bit signed offset");
+            Twine("expected a ") + Twine(OffsetSize - 1) + "-bit positive offset for buffer ops");
----------------
jayfoad wrote:

"non-negative" is more correct than "positive", since 0 is OK. Same in the rest of the patch.

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


More information about the llvm-commits mailing list