1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes='amdgpu-attributor' %s -o - | FileCheck %s
4 %struct.ShaderClosure = type { <3 x float>, i32, float, <3 x float>, [10 x float], [8 x i8] }
5 %struct.ShaderData = type { <3 x float>, <3 x float>, <3 x float>, <3 x float>, i32, i32, i32, i32, i32, float, float, i32, i32, float, float, %struct.differential3, %struct.differential3, %struct.differential, %struct.differential, <3 x float>, <3 x float>, <3 x float>, %struct.differential3, i32, i32, i32, float, <3 x float>, <3 x float>, <3 x float>, [64 x %struct.ShaderClosure] }
6 %struct.differential = type { float, float }
7 %struct.differential3 = type { <3 x float>, <3 x float> }
9 define internal fastcc void @foo(ptr %kg) {
10 ; CHECK-LABEL: define internal fastcc void @foo(
11 ; CHECK-SAME: ptr [[KG:%.*]]) #[[ATTR0:[0-9]+]] {
12 ; CHECK-NEXT: [[ENTRY:.*:]]
13 ; CHECK-NEXT: [[CLOSURE_I25_I:%.*]] = getelementptr i8, ptr [[KG]], i64 336
14 ; CHECK-NEXT: [[NUM_CLOSURE_I26_I:%.*]] = getelementptr i8, ptr [[KG]], i64 276
15 ; CHECK-NEXT: br label %[[WHILE_COND:.*]]
16 ; CHECK: [[WHILE_COND]]:
17 ; CHECK-NEXT: [[TMP0:%.*]] = addrspacecast ptr [[KG]] to ptr addrspace(5)
18 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(5) [[TMP0]], align 4
19 ; CHECK-NEXT: [[IDXPROM_I:%.*]] = zext i32 [[TMP1]] to i64
20 ; CHECK-NEXT: switch i32 0, label %[[SW_BB92:.*]] [
21 ; CHECK-NEXT: i32 1, label %[[SW_BB92]]
22 ; CHECK-NEXT: i32 0, label %[[SUBD_TRIANGLE_PATCH_EXIT_I_I35:.*]]
24 ; CHECK: [[SUBD_TRIANGLE_PATCH_EXIT_I_I35]]:
25 ; CHECK-NEXT: [[ARRAYIDX_I27_I:%.*]] = getelementptr float, ptr [[KG]], i64 [[IDXPROM_I]]
26 ; CHECK-NEXT: [[TMP2:%.*]] = addrspacecast ptr [[ARRAYIDX_I27_I]] to ptr addrspace(5)
27 ; CHECK-NEXT: store float 0.000000e+00, ptr addrspace(5) [[TMP2]], align 4
28 ; CHECK-NEXT: br label %[[WHILE_COND]]
30 ; CHECK-NEXT: [[INSERT:%.*]] = insertelement <3 x i32> zeroinitializer, i32 [[TMP1]], i64 0
31 ; CHECK-NEXT: [[SPLAT_SPLATINSERT_I:%.*]] = bitcast <3 x i32> [[INSERT]] to <3 x float>
32 ; CHECK-NEXT: [[SHFL:%.*]] = shufflevector <3 x float> [[SPLAT_SPLATINSERT_I]], <3 x float> zeroinitializer, <4 x i32> zeroinitializer
33 ; CHECK-NEXT: [[TMP3:%.*]] = addrspacecast ptr [[NUM_CLOSURE_I26_I]] to ptr addrspace(5)
34 ; CHECK-NEXT: [[LOAD:%.*]] = load i32, ptr addrspace(5) [[TMP3]], align 4
35 ; CHECK-NEXT: [[IDXPROM_I27_I:%.*]] = sext i32 [[LOAD]] to i64
36 ; CHECK-NEXT: [[ARRAYIDX_I28_I:%.*]] = getelementptr [64 x %struct.ShaderClosure], ptr [[CLOSURE_I25_I]], i64 0, i64 [[IDXPROM_I27_I]]
37 ; CHECK-NEXT: [[TMP4:%.*]] = addrspacecast ptr [[ARRAYIDX_I28_I]] to ptr addrspace(5)
38 ; CHECK-NEXT: store <4 x float> [[SHFL]], ptr addrspace(5) [[TMP4]], align 16
39 ; CHECK-NEXT: [[INC_I30_I:%.*]] = or i32 [[LOAD]], 1
40 ; CHECK-NEXT: [[TMP5:%.*]] = addrspacecast ptr [[NUM_CLOSURE_I26_I]] to ptr addrspace(5)
41 ; CHECK-NEXT: store i32 [[INC_I30_I]], ptr addrspace(5) [[TMP5]], align 4
42 ; CHECK-NEXT: br label %[[WHILE_COND]]
45 %closure.i25.i = getelementptr i8, ptr %kg, i64 336
46 %num_closure.i26.i = getelementptr i8, ptr %kg, i64 276
50 %load = load i32, ptr %kg, align 4
51 %idxprom.i = zext i32 %load to i64
52 switch i32 0, label %sw.bb92 [
54 i32 0, label %subd_triangle_patch.exit.i.i35
57 subd_triangle_patch.exit.i.i35:
58 %arrayidx.i27.i = getelementptr float, ptr %kg, i64 %idxprom.i
59 store float 0.000000e+00, ptr %arrayidx.i27.i, align 4
63 %insert = insertelement <3 x i32> zeroinitializer, i32 %load, i64 0
64 %splat.splatinsert.i = bitcast <3 x i32> %insert to <3 x float>
65 %shfl = shufflevector <3 x float> %splat.splatinsert.i, <3 x float> zeroinitializer, <4 x i32> zeroinitializer
66 %load.1 = load i32, ptr %num_closure.i26.i, align 4
67 %idxprom.i27.i = sext i32 %load.1 to i64
68 %arrayidx.i28.i = getelementptr [64 x %struct.ShaderClosure], ptr %closure.i25.i, i64 0, i64 %idxprom.i27.i
69 store <4 x float> %shfl, ptr %arrayidx.i28.i, align 16
70 %inc.i30.i = or i32 %load.1, 1
71 store i32 %inc.i30.i, ptr %num_closure.i26.i, align 4
75 define amdgpu_kernel void @kernel() #0 {
76 ; CHECK-LABEL: define amdgpu_kernel void @kernel(
77 ; CHECK-SAME: ) #[[ATTR1:[0-9]+]] {
78 ; CHECK-NEXT: [[ENTRY:.*:]]
79 ; CHECK-NEXT: [[SD:%.*]] = alloca [[STRUCT_SHADERDATA:%.*]], align 16, addrspace(5)
80 ; CHECK-NEXT: [[KGLOBALS_ASCAST1:%.*]] = addrspacecast ptr addrspace(5) [[SD]] to ptr
81 ; CHECK-NEXT: [[NUM_CLOSURE_I_I:%.*]] = getelementptr i8, ptr addrspace(5) [[SD]], i32 276
82 ; CHECK-NEXT: store <2 x i32> zeroinitializer, ptr addrspace(5) [[NUM_CLOSURE_I_I]], align 4
83 ; CHECK-NEXT: call fastcc void @foo(ptr [[KGLOBALS_ASCAST1]])
84 ; CHECK-NEXT: ret void
87 %sd = alloca %struct.ShaderData, align 16, addrspace(5)
88 %kglobals.ascast1 = addrspacecast ptr addrspace(5) %sd to ptr
89 %num_closure.i.i = getelementptr i8, ptr addrspace(5) %sd, i32 276
90 store <2 x i32> zeroinitializer, ptr addrspace(5) %num_closure.i.i, align 4
91 call fastcc void @foo(ptr %kglobals.ascast1)
95 attributes #0 = { norecurse }