[llvm] [AMDGPU] Account for inline asm size in inst_pref_size calculation (PR #192306)

Stanislav Mekhanoshin via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 15 12:51:19 PDT 2026


================
@@ -1,10 +1,20 @@
 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 --amdgpu-memcpy-loop-unroll=100000 < %s | FileCheck --check-prefixes=GCN,GFX11 %s
 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1200 --amdgpu-memcpy-loop-unroll=100000 < %s | FileCheck --check-prefixes=GCN,GFX12 %s
 
+;; Verify that inst_pref_size resolves to the correct value in the object file.
+;; COMPUTE_PGM_RSRC3 is at offset 0x2C in each 64-byte kernel descriptor.
+;; GFX11 inst_pref_size is bits [9:4], so value N is encoded as N << 4.
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 --amdgpu-memcpy-loop-unroll=100000 -filetype=obj < %s -o %t.o
+; RUN: llvm-objdump -s -j .rodata %t.o | FileCheck --check-prefix=OBJ %s
+
+; The inst_pref_size is computed via MCExpr label subtraction
+; (code_end - func_sym), which resolves at assembly/link time.
+; In text output it appears as a symbolic expression.
+
 ; GCN-LABEL: .amdhsa_kernel large
-; GFX11: .amdhsa_inst_pref_size 3
+; GFX11: .amdhsa_inst_pref_size {{.*}}instprefsize({{.*}}large, 6){{.*}}
----------------
rampitec wrote:

Ough, I see. This number is field width. I really want to see the expression expanded in the test.

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


More information about the llvm-commits mailing list