[llvm] [AMDGPU] Capping max number of registers for indirect calls (PR #199765)

Janek van Oirschot via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 7 21:46:05 PDT 2026


================
@@ -547,17 +547,17 @@ define amdgpu_kernel void @f256() #256 {
 attributes #256 = { nounwind "amdgpu-flat-work-group-size"="256,256" }
 
 ; GCN-LABEL: {{^}}f512:
-; GFX9:             .set .Lf512.num_vgpr, max(128, amdgpu.max_num_vgpr)
-; GFX90A:           .set .Lf512.num_vgpr, max(128, amdgpu.max_num_vgpr)
-; GFX90A:           .set .Lf512.num_agpr, max(128, amdgpu.max_num_agpr)
-; GFX10WGP-WAVE32:  .set .Lf512.num_vgpr, max(256, amdgpu.max_num_vgpr)
-; GFX10WGP-WAVE64:  .set .Lf512.num_vgpr, max(256, amdgpu.max_num_vgpr)
-; GFX10CU-WAVE32:   .set .Lf512.num_vgpr, max(128, amdgpu.max_num_vgpr)
-; GFX10CU-WAVE64:   .set .Lf512.num_vgpr, max(128, amdgpu.max_num_vgpr)
-; GFX11WGP-WAVE32:  .set .Lf512.num_vgpr, max(256, amdgpu.max_num_vgpr)
-; GFX11WGP-WAVE64:  .set .Lf512.num_vgpr, max(256, amdgpu.max_num_vgpr)
-; GFX11CU-WAVE32:   .set .Lf512.num_vgpr, max(192, amdgpu.max_num_vgpr)
-; GFX11CU-WAVE64:   .set .Lf512.num_vgpr, max(192, amdgpu.max_num_vgpr)
+; GFX9:             .set .Lf512.num_vgpr, min(128, max(128, amdgpu.max_num_vgpr))
+; GFX90A:           .set .Lf512.num_vgpr, min(128, max(128, amdgpu.max_num_vgpr))
+; GFX90A:           .set .Lf512.num_agpr, min(128, max(128, amdgpu.max_num_agpr))
+; GFX10WGP-WAVE32:  .set .Lf512.num_vgpr, min(256, max(256, amdgpu.max_num_vgpr))
+; GFX10WGP-WAVE64:  .set .Lf512.num_vgpr, min(256, max(256, amdgpu.max_num_vgpr))
+; GFX10CU-WAVE32:   .set .Lf512.num_vgpr, min(128, max(128, amdgpu.max_num_vgpr))
+; GFX10CU-WAVE64:   .set .Lf512.num_vgpr, min(128, max(128, amdgpu.max_num_vgpr))
+; GFX11WGP-WAVE32:  .set .Lf512.num_vgpr, min(256, max(256, amdgpu.max_num_vgpr))
+; GFX11WGP-WAVE64:  .set .Lf512.num_vgpr, min(256, max(256, amdgpu.max_num_vgpr))
+; GFX11CU-WAVE32:   .set .Lf512.num_vgpr, min(192, max(192, amdgpu.max_num_vgpr))
+; GFX11CU-WAVE64:   .set .Lf512.num_vgpr, min(192, max(192, amdgpu.max_num_vgpr))
----------------
JanekvO wrote:

I'm not sure if this is the patch that should resolve this nor whether this is the place to resolve this but: the symbolic MCExprs in these are very much superfluous given that the constants in these MCExprs are clamped to just 1 (known) value anyways (i.e., the value of `amdgpu.max_num_vgpr` doesn't matter in any of these). Perhaps we should detect these somewhere and make sure to emit the clamped constant value instead of the MCExpr itself (detect at generation of the AMDGPU MCExpr? detect at AMDGPUMCResourceInfo's emit of the min? dunno)

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


More information about the llvm-commits mailing list