[llvm] AMDGPU: Add regression test for multiple frame index lowering (PR #140784)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue May 20 12:35:40 PDT 2025


================
@@ -424,4 +424,115 @@ vector.body.i.i.i.i:                              ; preds = %.shuffle.then.i.i.i
   ret void
 }
 
+; Check that we do not produce a verifier error after prolog
+; epilog. alloca1 and alloca2 will lower to literals.
+
+; GCN-LABEL: {{^}}s_multiple_frame_indexes_literal_offsets:
+; GCN: s_load_dword [[ARG0:s[0-9]+]]
+; GCN: s_movk_i32 [[ALLOCA1:s[0-9]+]], 0x44
+; GCN: s_cmp_eq_u32 [[ARG0]], 0
+; GCN: s_cselect_b32 [[SELECT:s[0-9]+]], [[ALLOCA1]], 0x48
+; GCN: s_mov_b32 [[ALLOCA0:s[0-9]+]], 0
+; GCN: ; use [[SELECT]], [[ALLOCA0]]
+define amdgpu_kernel void @s_multiple_frame_indexes_literal_offsets(i32 inreg %arg0) #0 {
+  %alloca0 = alloca [17 x i32], align 8, addrspace(5)
+  %alloca1 = alloca i32, align 4, addrspace(5)
+  %alloca2 = alloca i32, align 4, addrspace(5)
+  %cmp = icmp eq i32 %arg0, 0
+  %select = select i1 %cmp, ptr addrspace(5) %alloca1, ptr addrspace(5) %alloca2
+  call void asm sideeffect "; use $0, $1","s,s"(ptr addrspace(5) %select, ptr addrspace(5) %alloca0)
+  ret void
+}
+
+; %alloca1 or alloca2 will lower to an inline constant, and one will
+; %be a literal, so we could fold both indexes into the instruction.
----------------
arsenm wrote:

```suggestion
; be a literal, so we could fold both indexes into the instruction.
```

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


More information about the llvm-commits mailing list