1 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -verify-machineinstrs -enable-ipra=1 < %s | FileCheck -check-prefix=GCN %s
2 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -verify-machineinstrs -enable-ipra=0 < %s | FileCheck -check-prefix=GCN %s
4 ; This test is to make sure the return address registers, if clobbered in the
5 ; function or the function has calls, are save/restored when IPRA is enabled/disabled.
7 ; TODO: An artificial test with high register pressure would be more reliable in the
8 ; long run as branches on constants could be fragile.
10 %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>, [1 x %struct.ShaderClosure] }
11 %struct.differential = type { float, float }
12 %struct.differential3 = type { <3 x float>, <3 x float> }
13 %struct.ShaderClosure = type { <3 x float>, i32, float, <3 x float>, [10 x float], [8 x i8] }
14 %struct.MicrofacetExtra = type { <3 x float>, <3 x float>, <3 x float>, float, [12 x i8] }
16 ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
17 declare float @llvm.fmuladd.f32(float, float, float) #0
19 ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
20 declare <3 x float> @llvm.fmuladd.v3f32(<3 x float>, <3 x float>, <3 x float>) #0
22 ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
23 declare <4 x float> @llvm.fmuladd.v4f32(<4 x float>, <4 x float>, <4 x float>) #0
25 ; Function Attrs: argmemonly nofree nosync nounwind willreturn
26 declare void @llvm.lifetime.end.p5(i64 immarg, ptr addrspace(5) nocapture) #1
28 ; Function Attrs: norecurse
29 define internal fastcc void @svm_node_closure_bsdf(ptr addrspace(1) %sd, ptr %stack, <4 x i32> %node, ptr %offset, i32 %0, i8 %trunc, float %1, float %2, float %mul80, i1 %cmp412.old, <4 x i32> %3, float %4, i32 %5, i1 %cmp440, i1 %cmp442, i1 %or.cond1306, float %.op, ptr addrspace(1) %arrayidx.i.i2202, ptr addrspace(1) %retval.0.i.i22089, ptr addrspace(1) %retval.1.i221310, i1 %cmp575, ptr addrspace(1) %num_closure_left.i2215, i32 %6, i1 %cmp.i2216, i32 %7, i64 %idx.ext.i2223, i32 %sub5.i2221) #2 {
30 ; GCN-LABEL: {{^}}svm_node_closure_bsdf:
31 ; GCN-NOT: v_writelane_b32
32 ; GCN: s_movk_i32 s26, 0x60
34 ; GCN-NOT: v_readlane_b32
35 ; GCN: s_waitcnt vmcnt(0)
36 ; GCN: s_setpc_b64 s[30:31]
38 %8 = extractelement <4 x i32> %node, i64 0
39 %cmp.i.not = icmp eq i32 undef, 0
40 br i1 undef, label %common.ret.critedge, label %cond.true
42 cond.true: ; preds = %entry
43 %9 = load float, ptr null, align 4
44 %phi.cmp = fcmp oeq float %9, 0.000000e+00
45 br i1 %phi.cmp, label %common.ret, label %cond.true20
47 cond.true20: ; preds = %cond.true
48 %v = zext i8 %trunc to i32
51 NodeBlock: ; preds = %cond.true20
52 %Pivot = icmp slt i32 %v, 44
53 br i1 %Pivot, label %LeafBlock, label %LeafBlock1
55 LeafBlock1: ; preds = %NodeBlock
56 %SwitchLeaf2 = icmp eq i32 %v, 44
57 br i1 %SwitchLeaf2, label %sw.bb, label %NewDefault
59 LeafBlock: ; preds = %NodeBlock
60 %SwitchLeaf = icmp eq i32 %v, 0
61 br i1 %SwitchLeaf, label %if.end.i.i2285, label %NewDefault
63 sw.bb: ; preds = %cond.true20
64 %10 = load float, ptr null, align 4
65 %11 = load float, ptr null, align 4
66 %12 = tail call float @llvm.amdgcn.fmed3.f32(float %1, float 0.000000e+00, float 0.000000e+00)
67 %mul802 = fmul nsz float %1, 0.000000e+00
68 %cmp412.old3 = fcmp nsz ogt float %1, 0.000000e+00
69 br i1 %cmp412.old, label %if.then413, label %common.ret
71 if.then413: ; preds = %sw.bb
72 %13 = load <4 x i32>, ptr addrspace(1) null, align 16
73 %14 = extractelement <4 x i32> %node, i64 0
74 %cmp4404 = fcmp nsz ole float %1, 0.000000e+00
75 %cmp4425 = icmp eq i32 %0, 0
76 %or.cond13066 = select i1 %cmp412.old, i1 false, i1 %cmp412.old
77 br i1 %or.cond1306, label %if.then443, label %if.else568
79 if.then443: ; preds = %if.then413
80 br i1 true, label %if.end511, label %common.ret
82 common.ret.critedge: ; preds = %entry
83 store i32 0, ptr null, align 4
86 NewDefault: ; preds = %LeafBlock1, %LeafBlock
87 %phi.store = phi i32 [0, %LeafBlock], [1, %LeafBlock1]
88 store i32 %phi.store, ptr null, align 4
91 common.ret: ; preds = %if.end.i.i2285, %if.end627.sink.split, %cond.end579, %bsdf_alloc.exit2188, %if.end511, %common.ret.critedge, %if.then443, %sw.bb, %NewDefault, %cond.true
94 if.end511: ; preds = %if.then443
95 br i1 false, label %common.ret, label %if.then519
97 if.then519: ; preds = %if.end511
98 br i1 false, label %bsdf_alloc.exit2188, label %if.then.i2172
100 if.then.i2172: ; preds = %if.then519
101 br i1 false, label %closure_alloc.exit.i2184, label %if.end.i.i2181
103 if.end.i.i2181: ; preds = %if.then.i2172
104 br label %closure_alloc.exit.i2184
106 closure_alloc.exit.i2184: ; preds = %if.end.i.i2181, %if.then.i2172
107 br i1 false, label %bsdf_alloc.exit2188, label %if.end.i2186
109 if.end.i2186: ; preds = %closure_alloc.exit.i2184
110 br label %bsdf_alloc.exit2188
112 bsdf_alloc.exit2188: ; preds = %if.end.i2186, %closure_alloc.exit.i2184, %if.then519
113 br i1 false, label %common.ret, label %if.then534
115 if.then534: ; preds = %bsdf_alloc.exit2188
116 %.op7 = fmul nsz float undef, 0.000000e+00
117 %mul558 = select i1 %cmp440, float 0.000000e+00, float %1
118 %15 = tail call float @llvm.amdgcn.fmed3.f32(float 0.000000e+00, float 0.000000e+00, float 0.000000e+00)
119 store float %mul558, ptr addrspace(1) null, align 4
120 br label %if.end627.sink.split
122 if.else568: ; preds = %if.then413
123 br i1 undef, label %bsdf_alloc.exit2214, label %if.then.i2198
125 if.then.i2198: ; preds = %if.else568
126 br i1 undef, label %closure_alloc.exit.i2210, label %if.end.i.i2207
128 if.end.i.i2207: ; preds = %if.then.i2198
129 %arrayidx.i.i22028 = getelementptr inbounds %struct.ShaderData, ptr addrspace(1) %sd, i64 0, i32 30, i64 undef
130 br label %closure_alloc.exit.i2210
132 closure_alloc.exit.i2210: ; preds = %if.end.i.i2207, %if.then.i2198
133 %retval.0.i.i220899 = phi ptr addrspace(1) [ %arrayidx.i.i2202, %if.end.i.i2207 ], [ null, %if.then.i2198 ]
134 br i1 false, label %bsdf_alloc.exit2214, label %if.end.i2212
136 if.end.i2212: ; preds = %closure_alloc.exit.i2210
137 br label %bsdf_alloc.exit2214
139 bsdf_alloc.exit2214: ; preds = %if.end.i2212, %closure_alloc.exit.i2210, %if.else568
140 %retval.1.i22131010 = phi ptr addrspace(1) [ %arrayidx.i.i2202, %if.end.i2212 ], [ null, %closure_alloc.exit.i2210 ], [ null, %if.else568 ]
141 %cmp57511 = icmp ne ptr addrspace(1) %arrayidx.i.i2202, null
142 br i1 %cmp442, label %cond.true576, label %cond.end579
144 cond.true576: ; preds = %bsdf_alloc.exit2214
145 %num_closure_left.i221512 = getelementptr inbounds %struct.ShaderData, ptr addrspace(1) %sd, i64 0, i32 25
146 %16 = load i32, ptr addrspace(1) %num_closure_left.i2215, align 8
147 %cmp.i221613 = icmp slt i32 %0, 0
148 br i1 %cmp440, label %cond.end579, label %if.end.i2227
150 if.end.i2227: ; preds = %cond.true576
151 %sub5.i222114 = add nuw nsw i32 %0, 0
152 %17 = load i32, ptr addrspace(1) null, align 4294967296
153 %idx.ext.i222315 = sext i32 %0 to i64
154 %add.ptr.i2224 = getelementptr inbounds %struct.ShaderData, ptr addrspace(1) %sd, i64 0, i32 30, i64 %idx.ext.i2223
155 %idx.ext8.i22252724 = zext i32 %0 to i64
156 %add.ptr9.i2226 = getelementptr inbounds %struct.ShaderClosure, ptr addrspace(1) %add.ptr.i2224, i64 %idx.ext8.i22252724
157 br label %cond.end579
159 cond.end579: ; preds = %if.end.i2227, %cond.true576, %bsdf_alloc.exit2214
160 %cond580 = phi ptr addrspace(1) [ null, %bsdf_alloc.exit2214 ], [ %add.ptr9.i2226, %if.end.i2227 ], [ null, %cond.true576 ]
161 %tobool583 = icmp ne ptr addrspace(1) %cond580, null
162 %or.cond1308 = select i1 %cmp442, i1 %tobool583, i1 false
163 br i1 %or.cond1308, label %if.then584, label %common.ret
165 if.then584: ; preds = %cond.end579
166 store ptr addrspace(1) null, ptr addrspace(1) null, align 4294967296
167 br label %if.end627.sink.split
169 if.end627.sink.split: ; preds = %if.then584, %if.then534
170 store i32 0, ptr addrspace(1) null, align 4
173 if.end.i.i2285: ; preds = %cond.true20
174 store i32 0, ptr addrspace(1) null, align 4294967296
178 define internal fastcc void @svm_eval_nodes(ptr addrspace(1) %sd) {
180 ; GCN-LABEL: {{^}}svm_eval_nodes:
181 ; GCN-DAG: v_writelane_b32 [[CSR_VGPR:v[0-9]+]], s30,
182 ; GCN-DAG: v_writelane_b32 [[CSR_VGPR]], s31,
183 ; GCN: s_swappc_b64 s[30:31]
184 ; GCN-DAG: v_readlane_b32 s31, [[CSR_VGPR]],
185 ; GCN-DAG: v_readlane_b32 s30, [[CSR_VGPR]],
186 ; GCN: s_waitcnt vmcnt(0)
187 ; GCN: s_setpc_b64 s[30:31]
188 call fastcc void @svm_node_closure_bsdf(ptr addrspace(1) null, ptr null, <4 x i32> zeroinitializer, ptr null, i32 undef, i8 undef, float undef, float undef, float undef, i1 undef, <4 x i32> undef, float undef, i32 undef, i1 undef, i1 undef, i1 undef, float undef, ptr addrspace(1) undef, ptr addrspace(1) undef, ptr addrspace(1) undef, i1 undef, ptr addrspace(1) undef, i32 undef, i1 undef, i32 undef, i64 undef, i32 undef)
192 define amdgpu_kernel void @kernel_ocl_path_trace_shadow_blocked_dl() {
193 kernel_set_buffer_pointers.exit:
194 ; GCN-LABEL: {{^}}kernel_ocl_path_trace_shadow_blocked_dl:
195 ; GCN: s_swappc_b64 s[30:31]
197 tail call fastcc void @svm_eval_nodes(ptr addrspace(1) null)
201 ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
202 declare float @llvm.fabs.f32(float) #0
204 ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
205 declare float @llvm.maxnum.f32(float, float) #0
207 ; Function Attrs: nounwind readnone speculatable willreturn
208 declare float @llvm.amdgcn.fmed3.f32(float, float, float) #3
210 attributes #0 = { nofree nosync nounwind readnone speculatable willreturn }
211 attributes #1 = { argmemonly nofree nosync nounwind willreturn }
212 attributes #2 = { norecurse }
213 attributes #3 = { nounwind readnone speculatable willreturn }