blob: e3a1c009607d1f6b8c90f51b1cb5968c7559dbcf [file] [log] [blame]
Tom Stellard49f8bfd2015-01-06 18:00:21 +00001; RUN: llc < %s -march=amdgcn -mcpu=SI -verify-machineinstrs | FileCheck %s
Marek Olsak75170772015-01-27 17:27:15 +00002; RUN: llc < %s -march=amdgcn -mcpu=tonga -verify-machineinstrs | FileCheck %s
Tom Stellard2f7cdda2013-08-06 23:08:28 +00003
4; This test checks that no VGPR to SGPR copies are created by the register
5; allocator.
Matt Arsenault325cca32016-01-23 05:42:43 +00006
Tom Stellard79243d92014-10-01 17:15:17 +00007; CHECK-LABEL: {{^}}phi1:
Tom Stellard3ae58872014-11-21 22:00:13 +00008; CHECK: s_buffer_load_dword [[DST:s[0-9]]], {{s\[[0-9]+:[0-9]+\]}}, 0x0
Tom Stellard326d6ec2014-11-05 14:50:53 +00009; CHECK: v_mov_b32_e32 v{{[0-9]}}, [[DST]]
Matt Arsenault325cca32016-01-23 05:42:43 +000010define void @phi1(<16 x i8> addrspace(2)* inreg %arg, <16 x i8> addrspace(2)* inreg %arg1, <32 x i8> addrspace(2)* inreg %arg2, i32 inreg %arg3, <2 x i32> %arg4, <2 x i32> %arg5, <2 x i32> %arg6, <3 x i32> %arg7, <2 x i32> %arg8, <2 x i32> %arg9, <2 x i32> %arg10, float %arg11, float %arg12, float %arg13, float %arg14, float %arg15, float %arg16, float %arg17, float %arg18, float %arg19) #0 {
Tom Stellard2f7cdda2013-08-06 23:08:28 +000011main_body:
Matt Arsenault325cca32016-01-23 05:42:43 +000012 %tmp = getelementptr <16 x i8>, <16 x i8> addrspace(2)* %arg, i32 0
13 %tmp20 = load <16 x i8>, <16 x i8> addrspace(2)* %tmp, !tbaa !0
14 %tmp21 = call float @llvm.SI.load.const(<16 x i8> %tmp20, i32 0)
15 %tmp22 = call float @llvm.SI.load.const(<16 x i8> %tmp20, i32 16)
16 %tmp23 = call float @llvm.SI.load.const(<16 x i8> %tmp20, i32 32)
17 %tmp24 = fptosi float %tmp22 to i32
18 %tmp25 = icmp ne i32 %tmp24, 0
19 br i1 %tmp25, label %ENDIF, label %ELSE
Tom Stellard2f7cdda2013-08-06 23:08:28 +000020
21ELSE: ; preds = %main_body
Matt Arsenault325cca32016-01-23 05:42:43 +000022 %tmp26 = fsub float -0.000000e+00, %tmp21
Tom Stellard2f7cdda2013-08-06 23:08:28 +000023 br label %ENDIF
24
Matt Arsenault325cca32016-01-23 05:42:43 +000025ENDIF: ; preds = %ELSE, %main_body
26 %temp.0 = phi float [ %tmp26, %ELSE ], [ %tmp21, %main_body ]
27 %tmp27 = fadd float %temp.0, %tmp23
28 call void @llvm.SI.export(i32 15, i32 1, i32 1, i32 0, i32 0, float %tmp27, float %tmp27, float 0.000000e+00, float 1.000000e+00)
Tom Stellard2f7cdda2013-08-06 23:08:28 +000029 ret void
30}
31
Tom Stellard15e48112013-08-22 20:21:02 +000032; Make sure this program doesn't crash
Tom Stellard79243d92014-10-01 17:15:17 +000033; CHECK-LABEL: {{^}}phi2:
Matt Arsenault325cca32016-01-23 05:42:43 +000034define void @phi2(<16 x i8> addrspace(2)* inreg %arg, <16 x i8> addrspace(2)* inreg %arg1, <32 x i8> addrspace(2)* inreg %arg2, i32 inreg %arg3, <2 x i32> %arg4, <2 x i32> %arg5, <2 x i32> %arg6, <3 x i32> %arg7, <2 x i32> %arg8, <2 x i32> %arg9, <2 x i32> %arg10, float %arg11, float %arg12, float %arg13, float %arg14, float %arg15, float %arg16, float %arg17, float %arg18, float %arg19) #0 {
Tom Stellard15e48112013-08-22 20:21:02 +000035main_body:
Matt Arsenault325cca32016-01-23 05:42:43 +000036 %tmp = getelementptr <16 x i8>, <16 x i8> addrspace(2)* %arg, i32 0
37 %tmp20 = load <16 x i8>, <16 x i8> addrspace(2)* %tmp, !tbaa !0
38 %tmp21 = call float @llvm.SI.load.const(<16 x i8> %tmp20, i32 16)
39 %tmp22 = call float @llvm.SI.load.const(<16 x i8> %tmp20, i32 32)
40 %tmp23 = call float @llvm.SI.load.const(<16 x i8> %tmp20, i32 36)
41 %tmp24 = call float @llvm.SI.load.const(<16 x i8> %tmp20, i32 40)
42 %tmp25 = call float @llvm.SI.load.const(<16 x i8> %tmp20, i32 48)
43 %tmp26 = call float @llvm.SI.load.const(<16 x i8> %tmp20, i32 52)
44 %tmp27 = call float @llvm.SI.load.const(<16 x i8> %tmp20, i32 56)
45 %tmp28 = call float @llvm.SI.load.const(<16 x i8> %tmp20, i32 64)
46 %tmp29 = call float @llvm.SI.load.const(<16 x i8> %tmp20, i32 68)
47 %tmp30 = call float @llvm.SI.load.const(<16 x i8> %tmp20, i32 72)
48 %tmp31 = call float @llvm.SI.load.const(<16 x i8> %tmp20, i32 76)
49 %tmp32 = call float @llvm.SI.load.const(<16 x i8> %tmp20, i32 80)
50 %tmp33 = call float @llvm.SI.load.const(<16 x i8> %tmp20, i32 84)
51 %tmp34 = call float @llvm.SI.load.const(<16 x i8> %tmp20, i32 88)
52 %tmp35 = call float @llvm.SI.load.const(<16 x i8> %tmp20, i32 92)
53 %tmp36 = getelementptr <32 x i8>, <32 x i8> addrspace(2)* %arg2, i32 0
54 %tmp37 = load <32 x i8>, <32 x i8> addrspace(2)* %tmp36, !tbaa !0
55 %tmp38 = getelementptr <16 x i8>, <16 x i8> addrspace(2)* %arg1, i32 0
56 %tmp39 = load <16 x i8>, <16 x i8> addrspace(2)* %tmp38, !tbaa !0
57 %tmp40 = call float @llvm.SI.fs.interp(i32 0, i32 0, i32 %arg3, <2 x i32> %arg5)
58 %tmp41 = call float @llvm.SI.fs.interp(i32 1, i32 0, i32 %arg3, <2 x i32> %arg5)
59 %tmp42 = call float @llvm.SI.fs.interp(i32 0, i32 1, i32 %arg3, <2 x i32> %arg5)
60 %tmp43 = call float @llvm.SI.fs.interp(i32 1, i32 1, i32 %arg3, <2 x i32> %arg5)
61 %tmp44 = call float @llvm.SI.fs.interp(i32 2, i32 1, i32 %arg3, <2 x i32> %arg5)
62 %tmp45 = bitcast float %tmp40 to i32
63 %tmp46 = bitcast float %tmp41 to i32
64 %tmp47 = insertelement <2 x i32> undef, i32 %tmp45, i32 0
65 %tmp48 = insertelement <2 x i32> %tmp47, i32 %tmp46, i32 1
66 %tmp49 = call <4 x float> @llvm.SI.sample.v2i32(<2 x i32> %tmp48, <32 x i8> %tmp37, <16 x i8> %tmp39, i32 2)
67 %tmp50 = extractelement <4 x float> %tmp49, i32 2
68 %tmp51 = call float @fabs(float %tmp50)
69 %tmp52 = fmul float %tmp42, %tmp42
70 %tmp53 = fmul float %tmp43, %tmp43
71 %tmp54 = fadd float %tmp53, %tmp52
72 %tmp55 = fmul float %tmp44, %tmp44
73 %tmp56 = fadd float %tmp54, %tmp55
74 %tmp57 = call float @llvm.amdgcn.rsq.f32(float %tmp56)
75 %tmp58 = fmul float %tmp42, %tmp57
76 %tmp59 = fmul float %tmp43, %tmp57
77 %tmp60 = fmul float %tmp44, %tmp57
78 %tmp61 = fmul float %tmp58, %tmp22
79 %tmp62 = fmul float %tmp59, %tmp23
80 %tmp63 = fadd float %tmp62, %tmp61
81 %tmp64 = fmul float %tmp60, %tmp24
82 %tmp65 = fadd float %tmp63, %tmp64
83 %tmp66 = fsub float -0.000000e+00, %tmp25
84 %tmp67 = fmul float %tmp65, %tmp51
85 %tmp68 = fadd float %tmp67, %tmp66
86 %tmp69 = fmul float %tmp26, %tmp68
87 %tmp70 = fmul float %tmp27, %tmp68
88 %tmp71 = call float @fabs(float %tmp69)
89 %tmp72 = fcmp olt float 0x3EE4F8B580000000, %tmp71
90 %tmp73 = sext i1 %tmp72 to i32
91 %tmp74 = bitcast i32 %tmp73 to float
92 %tmp75 = bitcast float %tmp74 to i32
93 %tmp76 = icmp ne i32 %tmp75, 0
94 br i1 %tmp76, label %IF, label %ENDIF
Tom Stellard15e48112013-08-22 20:21:02 +000095
96IF: ; preds = %main_body
Matt Arsenault325cca32016-01-23 05:42:43 +000097 %tmp77 = fsub float -0.000000e+00, %tmp69
Matt Arsenault8aa56782016-01-23 05:42:49 +000098 %tmp78 = call float @llvm.exp2.f32(float %tmp77)
Matt Arsenault325cca32016-01-23 05:42:43 +000099 %tmp79 = fsub float -0.000000e+00, %tmp78
100 %tmp80 = fadd float 1.000000e+00, %tmp79
101 %tmp81 = fdiv float 1.000000e+00, %tmp69
102 %tmp82 = fmul float %tmp80, %tmp81
103 %tmp83 = fmul float %tmp31, %tmp82
Tom Stellard15e48112013-08-22 20:21:02 +0000104 br label %ENDIF
105
Matt Arsenault325cca32016-01-23 05:42:43 +0000106ENDIF: ; preds = %IF, %main_body
107 %temp4.0 = phi float [ %tmp83, %IF ], [ %tmp31, %main_body ]
108 %tmp84 = call float @fabs(float %tmp70)
109 %tmp85 = fcmp olt float 0x3EE4F8B580000000, %tmp84
110 %tmp86 = sext i1 %tmp85 to i32
111 %tmp87 = bitcast i32 %tmp86 to float
112 %tmp88 = bitcast float %tmp87 to i32
113 %tmp89 = icmp ne i32 %tmp88, 0
114 br i1 %tmp89, label %IF25, label %ENDIF24
Tom Stellard15e48112013-08-22 20:21:02 +0000115
116IF25: ; preds = %ENDIF
Matt Arsenault325cca32016-01-23 05:42:43 +0000117 %tmp90 = fsub float -0.000000e+00, %tmp70
Matt Arsenault8aa56782016-01-23 05:42:49 +0000118 %tmp91 = call float @llvm.exp2.f32(float %tmp90)
Matt Arsenault325cca32016-01-23 05:42:43 +0000119 %tmp92 = fsub float -0.000000e+00, %tmp91
120 %tmp93 = fadd float 1.000000e+00, %tmp92
121 %tmp94 = fdiv float 1.000000e+00, %tmp70
122 %tmp95 = fmul float %tmp93, %tmp94
123 %tmp96 = fmul float %tmp35, %tmp95
Tom Stellard15e48112013-08-22 20:21:02 +0000124 br label %ENDIF24
125
Matt Arsenault325cca32016-01-23 05:42:43 +0000126ENDIF24: ; preds = %IF25, %ENDIF
127 %temp8.0 = phi float [ %tmp96, %IF25 ], [ %tmp35, %ENDIF ]
128 %tmp97 = fmul float %tmp28, %temp4.0
129 %tmp98 = fmul float %tmp29, %temp4.0
130 %tmp99 = fmul float %tmp30, %temp4.0
131 %tmp100 = fmul float %tmp32, %temp8.0
132 %tmp101 = fadd float %tmp100, %tmp97
133 %tmp102 = fmul float %tmp33, %temp8.0
134 %tmp103 = fadd float %tmp102, %tmp98
135 %tmp104 = fmul float %tmp34, %temp8.0
136 %tmp105 = fadd float %tmp104, %tmp99
137 %tmp106 = call float @llvm.pow.f32(float %tmp51, float %tmp21)
138 %tmp107 = fsub float -0.000000e+00, %tmp101
139 %tmp108 = fmul float %tmp107, %tmp106
140 %tmp109 = fsub float -0.000000e+00, %tmp103
141 %tmp110 = fmul float %tmp109, %tmp106
142 %tmp111 = fsub float -0.000000e+00, %tmp105
143 %tmp112 = fmul float %tmp111, %tmp106
144 %tmp113 = call i32 @llvm.SI.packf16(float %tmp108, float %tmp110)
145 %tmp114 = bitcast i32 %tmp113 to float
146 %tmp115 = call i32 @llvm.SI.packf16(float %tmp112, float 1.000000e+00)
147 %tmp116 = bitcast i32 %tmp115 to float
148 call void @llvm.SI.export(i32 15, i32 1, i32 1, i32 0, i32 1, float %tmp114, float %tmp116, float %tmp114, float %tmp116)
Tom Stellard15e48112013-08-22 20:21:02 +0000149 ret void
150}
151
Tom Stellard2f7cdda2013-08-06 23:08:28 +0000152; We just want ot make sure the program doesn't crash
Tom Stellard79243d92014-10-01 17:15:17 +0000153; CHECK-LABEL: {{^}}loop:
Matt Arsenault325cca32016-01-23 05:42:43 +0000154define void @loop(<16 x i8> addrspace(2)* inreg %arg, <16 x i8> addrspace(2)* inreg %arg1, <32 x i8> addrspace(2)* inreg %arg2, i32 inreg %arg3, <2 x i32> %arg4, <2 x i32> %arg5, <2 x i32> %arg6, <3 x i32> %arg7, <2 x i32> %arg8, <2 x i32> %arg9, <2 x i32> %arg10, float %arg11, float %arg12, float %arg13, float %arg14, float %arg15, float %arg16, float %arg17, float %arg18, float %arg19) #0 {
Tom Stellard2f7cdda2013-08-06 23:08:28 +0000155main_body:
Matt Arsenault325cca32016-01-23 05:42:43 +0000156 %tmp = getelementptr <16 x i8>, <16 x i8> addrspace(2)* %arg, i32 0
157 %tmp20 = load <16 x i8>, <16 x i8> addrspace(2)* %tmp, !tbaa !0
158 %tmp21 = call float @llvm.SI.load.const(<16 x i8> %tmp20, i32 0)
159 %tmp22 = call float @llvm.SI.load.const(<16 x i8> %tmp20, i32 4)
160 %tmp23 = call float @llvm.SI.load.const(<16 x i8> %tmp20, i32 8)
161 %tmp24 = call float @llvm.SI.load.const(<16 x i8> %tmp20, i32 12)
162 %tmp25 = fptosi float %tmp24 to i32
163 %tmp26 = bitcast i32 %tmp25 to float
164 %tmp27 = bitcast float %tmp26 to i32
Tom Stellard2f7cdda2013-08-06 23:08:28 +0000165 br label %LOOP
166
167LOOP: ; preds = %ENDIF, %main_body
Matt Arsenault325cca32016-01-23 05:42:43 +0000168 %temp4.0 = phi float [ %tmp21, %main_body ], [ %temp5.0, %ENDIF ]
169 %temp5.0 = phi float [ %tmp22, %main_body ], [ %temp6.0, %ENDIF ]
170 %temp6.0 = phi float [ %tmp23, %main_body ], [ %temp4.0, %ENDIF ]
171 %temp8.0 = phi float [ 0.000000e+00, %main_body ], [ %tmp36, %ENDIF ]
172 %tmp28 = bitcast float %temp8.0 to i32
173 %tmp29 = icmp sge i32 %tmp28, %tmp27
174 %tmp30 = sext i1 %tmp29 to i32
175 %tmp31 = bitcast i32 %tmp30 to float
176 %tmp32 = bitcast float %tmp31 to i32
177 %tmp33 = icmp ne i32 %tmp32, 0
178 br i1 %tmp33, label %IF, label %ENDIF
Tom Stellard2f7cdda2013-08-06 23:08:28 +0000179
180IF: ; preds = %LOOP
181 call void @llvm.SI.export(i32 15, i32 1, i32 1, i32 0, i32 0, float %temp4.0, float %temp5.0, float %temp6.0, float 1.000000e+00)
182 ret void
183
184ENDIF: ; preds = %LOOP
Matt Arsenault325cca32016-01-23 05:42:43 +0000185 %tmp34 = bitcast float %temp8.0 to i32
186 %tmp35 = add i32 %tmp34, 1
187 %tmp36 = bitcast i32 %tmp35 to float
Tom Stellard2f7cdda2013-08-06 23:08:28 +0000188 br label %LOOP
189}
190
191; Function Attrs: nounwind readnone
192declare float @llvm.SI.load.const(<16 x i8>, i32) #1
193
194; Function Attrs: readonly
195declare float @fabs(float) #2
196
197declare void @llvm.SI.export(i32, i32, i32, i32, i32, float, float, float, float)
198
Tom Stellard15e48112013-08-22 20:21:02 +0000199; Function Attrs: nounwind readnone
200declare float @llvm.SI.fs.interp(i32, i32, i32, <2 x i32>) #1
201
202; Function Attrs: nounwind readnone
203declare <4 x float> @llvm.SI.sample.v2i32(<2 x i32>, <32 x i8>, <16 x i8>, i32) #1
204
205; Function Attrs: readnone
Matt Arsenaultbef34e22016-01-22 21:30:34 +0000206declare float @llvm.amdgcn.rsq.f32(float) #3
Tom Stellard15e48112013-08-22 20:21:02 +0000207
Matt Arsenault8aa56782016-01-23 05:42:49 +0000208declare float @llvm.exp2.f32(float) #1
Tom Stellard15e48112013-08-22 20:21:02 +0000209
Matt Arsenault325cca32016-01-23 05:42:43 +0000210; Function Attrs: nounwind readnone
211declare float @llvm.pow.f32(float, float) #1
Tom Stellard15e48112013-08-22 20:21:02 +0000212
213; Function Attrs: nounwind readnone
214declare i32 @llvm.SI.packf16(float, float) #1
Tom Stellard519ae392013-11-15 18:26:45 +0000215
216; This checks for a bug in the FixSGPRCopies pass where VReg96
217; registers were being identified as an SGPR regclass which was causing
218; an assertion failure.
219
Tom Stellard79243d92014-10-01 17:15:17 +0000220; CHECK-LABEL: {{^}}sample_v3:
Tom Stellard326d6ec2014-11-05 14:50:53 +0000221; CHECK: image_sample
222; CHECK: image_sample
223; CHECK: exp
224; CHECK: s_endpgm
Matt Arsenault325cca32016-01-23 05:42:43 +0000225define void @sample_v3([17 x <16 x i8>] addrspace(2)* byval %arg, [32 x <16 x i8>] addrspace(2)* byval %arg1, [16 x <32 x i8>] addrspace(2)* byval %arg2, float inreg %arg3, i32 inreg %arg4, <2 x i32> %arg5, <2 x i32> %arg6, <2 x i32> %arg7, <3 x i32> %arg8, <2 x i32> %arg9, <2 x i32> %arg10, <2 x i32> %arg11, float %arg12, float %arg13, float %arg14, float %arg15, float %arg16, float %arg17, float %arg18, float %arg19, float %arg20) #0 {
Tom Stellard519ae392013-11-15 18:26:45 +0000226entry:
Matt Arsenault325cca32016-01-23 05:42:43 +0000227 %tmp = getelementptr [17 x <16 x i8>], [17 x <16 x i8>] addrspace(2)* %arg, i64 0, i32 0
228 %tmp21 = load <16 x i8>, <16 x i8> addrspace(2)* %tmp, !tbaa !0
229 %tmp22 = call float @llvm.SI.load.const(<16 x i8> %tmp21, i32 16)
230 %tmp23 = getelementptr [16 x <32 x i8>], [16 x <32 x i8>] addrspace(2)* %arg2, i64 0, i32 0
231 %tmp24 = load <32 x i8>, <32 x i8> addrspace(2)* %tmp23, !tbaa !0
232 %tmp25 = getelementptr [32 x <16 x i8>], [32 x <16 x i8>] addrspace(2)* %arg1, i64 0, i32 0
233 %tmp26 = load <16 x i8>, <16 x i8> addrspace(2)* %tmp25, !tbaa !0
234 %tmp27 = fcmp oeq float %tmp22, 0.000000e+00
235 br i1 %tmp27, label %if, label %else
Tom Stellard519ae392013-11-15 18:26:45 +0000236
Matt Arsenault325cca32016-01-23 05:42:43 +0000237if: ; preds = %entry
238 %val.if = call <4 x float> @llvm.SI.sample.v2i32(<2 x i32> zeroinitializer, <32 x i8> %tmp24, <16 x i8> %tmp26, i32 2)
Tom Stellard519ae392013-11-15 18:26:45 +0000239 %val.if.0 = extractelement <4 x float> %val.if, i32 0
240 %val.if.1 = extractelement <4 x float> %val.if, i32 1
241 %val.if.2 = extractelement <4 x float> %val.if, i32 2
242 br label %endif
243
Matt Arsenault325cca32016-01-23 05:42:43 +0000244else: ; preds = %entry
245 %val.else = call <4 x float> @llvm.SI.sample.v2i32(<2 x i32> <i32 1, i32 0>, <32 x i8> %tmp24, <16 x i8> %tmp26, i32 2)
Tom Stellard519ae392013-11-15 18:26:45 +0000246 %val.else.0 = extractelement <4 x float> %val.else, i32 0
247 %val.else.1 = extractelement <4 x float> %val.else, i32 1
248 %val.else.2 = extractelement <4 x float> %val.else, i32 2
249 br label %endif
250
Matt Arsenault325cca32016-01-23 05:42:43 +0000251endif: ; preds = %else, %if
252 %val.0 = phi float [ %val.if.0, %if ], [ %val.else.0, %else ]
253 %val.1 = phi float [ %val.if.1, %if ], [ %val.else.1, %else ]
254 %val.2 = phi float [ %val.if.2, %if ], [ %val.else.2, %else ]
255 call void @llvm.SI.export(i32 15, i32 1, i32 1, i32 0, i32 1, float %val.0, float %val.1, float %val.2, float 0.000000e+00)
Tom Stellard519ae392013-11-15 18:26:45 +0000256 ret void
257}
258
Tom Stellard79243d92014-10-01 17:15:17 +0000259; CHECK-LABEL: {{^}}copy1:
Tom Stellard326d6ec2014-11-05 14:50:53 +0000260; CHECK: buffer_load_dword
261; CHECK: v_add
262; CHECK: s_endpgm
Tom Stellard13de5452013-11-18 18:50:15 +0000263define void @copy1(float addrspace(1)* %out, float addrspace(1)* %in0) {
264entry:
Matt Arsenault325cca32016-01-23 05:42:43 +0000265 %tmp = load float, float addrspace(1)* %in0
266 %tmp1 = fcmp oeq float %tmp, 0.000000e+00
267 br i1 %tmp1, label %if0, label %endif
Tom Stellard13de5452013-11-18 18:50:15 +0000268
Matt Arsenault325cca32016-01-23 05:42:43 +0000269if0: ; preds = %entry
270 %tmp2 = bitcast float %tmp to i32
271 %tmp3 = fcmp olt float %tmp, 0.000000e+00
272 br i1 %tmp3, label %if1, label %endif
Tom Stellard13de5452013-11-18 18:50:15 +0000273
Matt Arsenault325cca32016-01-23 05:42:43 +0000274if1: ; preds = %if0
275 %tmp4 = add i32 %tmp2, 1
Tom Stellard13de5452013-11-18 18:50:15 +0000276 br label %endif
277
Matt Arsenault325cca32016-01-23 05:42:43 +0000278endif: ; preds = %if1, %if0, %entry
279 %tmp5 = phi i32 [ 0, %entry ], [ %tmp2, %if0 ], [ %tmp4, %if1 ]
280 %tmp6 = bitcast i32 %tmp5 to float
281 store float %tmp6, float addrspace(1)* %out
Tom Stellard13de5452013-11-18 18:50:15 +0000282 ret void
283}
Tom Stellardf3407872013-11-18 18:50:20 +0000284
285; This test is just checking that we don't crash / assertion fail.
Tom Stellard79243d92014-10-01 17:15:17 +0000286; CHECK-LABEL: {{^}}copy2:
Tom Stellard326d6ec2014-11-05 14:50:53 +0000287; CHECK: s_endpgm
Matt Arsenault325cca32016-01-23 05:42:43 +0000288define void @copy2([17 x <16 x i8>] addrspace(2)* byval %arg, [32 x <16 x i8>] addrspace(2)* byval %arg1, [16 x <32 x i8>] addrspace(2)* byval %arg2, float inreg %arg3, i32 inreg %arg4, <2 x i32> %arg5, <2 x i32> %arg6, <2 x i32> %arg7, <3 x i32> %arg8, <2 x i32> %arg9, <2 x i32> %arg10, <2 x i32> %arg11, float %arg12, float %arg13, float %arg14, float %arg15, float %arg16, float %arg17, float %arg18, float %arg19, float %arg20) #0 {
Tom Stellardf3407872013-11-18 18:50:20 +0000289entry:
290 br label %LOOP68
291
Matt Arsenault325cca32016-01-23 05:42:43 +0000292LOOP68: ; preds = %ENDIF69, %entry
Tom Stellardf3407872013-11-18 18:50:20 +0000293 %temp4.7 = phi float [ 0.000000e+00, %entry ], [ %v, %ENDIF69 ]
294 %t = phi i32 [ 20, %entry ], [ %x, %ENDIF69 ]
295 %g = icmp eq i32 0, %t
296 %l = bitcast float %temp4.7 to i32
297 br i1 %g, label %IF70, label %ENDIF69
298
Matt Arsenault325cca32016-01-23 05:42:43 +0000299IF70: ; preds = %LOOP68
Tom Stellardf3407872013-11-18 18:50:20 +0000300 %q = icmp ne i32 %l, 13
301 %temp.8 = select i1 %q, float 1.000000e+00, float 0.000000e+00
302 call void @llvm.SI.export(i32 15, i32 1, i32 1, i32 0, i32 0, float %temp.8, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00)
303 ret void
304
Matt Arsenault325cca32016-01-23 05:42:43 +0000305ENDIF69: ; preds = %LOOP68
Tom Stellardf3407872013-11-18 18:50:20 +0000306 %u = add i32 %l, %t
307 %v = bitcast i32 %u to float
308 %x = add i32 %t, -1
309 br label %LOOP68
310}
311
Tom Stellardf0a21072014-11-18 20:39:39 +0000312; This test checks that image_sample resource descriptors aren't loaded into
313; vgprs. The verifier will fail if this happens.
314; CHECK-LABEL:{{^}}sample_rsrc:
315; CHECK: image_sample
316; CHECK: image_sample
317; CHECK: s_endpgm
318define void @sample_rsrc([6 x <16 x i8>] addrspace(2)* byval %arg, [17 x <16 x i8>] addrspace(2)* byval %arg1, [16 x <4 x i32>] addrspace(2)* byval %arg2, [32 x <8 x i32>] addrspace(2)* byval %arg3, float inreg %arg4, i32 inreg %arg5, <2 x i32> %arg6, <2 x i32> %arg7, <2 x i32> %arg8, <3 x i32> %arg9, <2 x i32> %arg10, <2 x i32> %arg11, <2 x i32> %arg12, float %arg13, float %arg14, float %arg15, float %arg16, float %arg17, float %arg18, i32 %arg19, float %arg20, float %arg21) #0 {
319bb:
David Blaikie79e6c742015-02-27 19:29:02 +0000320 %tmp = getelementptr [17 x <16 x i8>], [17 x <16 x i8>] addrspace(2)* %arg1, i32 0, i32 0
Matt Arsenault325cca32016-01-23 05:42:43 +0000321 %tmp22 = load <16 x i8>, <16 x i8> addrspace(2)* %tmp, !tbaa !2
Tom Stellardf0a21072014-11-18 20:39:39 +0000322 %tmp23 = call float @llvm.SI.load.const(<16 x i8> %tmp22, i32 16)
David Blaikie79e6c742015-02-27 19:29:02 +0000323 %tmp25 = getelementptr [32 x <8 x i32>], [32 x <8 x i32>] addrspace(2)* %arg3, i32 0, i32 0
Matt Arsenault325cca32016-01-23 05:42:43 +0000324 %tmp26 = load <8 x i32>, <8 x i32> addrspace(2)* %tmp25, !tbaa !2
David Blaikie79e6c742015-02-27 19:29:02 +0000325 %tmp27 = getelementptr [16 x <4 x i32>], [16 x <4 x i32>] addrspace(2)* %arg2, i32 0, i32 0
Matt Arsenault325cca32016-01-23 05:42:43 +0000326 %tmp28 = load <4 x i32>, <4 x i32> addrspace(2)* %tmp27, !tbaa !2
Tom Stellardf0a21072014-11-18 20:39:39 +0000327 %tmp29 = call float @llvm.SI.fs.interp(i32 0, i32 0, i32 %arg5, <2 x i32> %arg7)
328 %tmp30 = call float @llvm.SI.fs.interp(i32 1, i32 0, i32 %arg5, <2 x i32> %arg7)
329 %tmp31 = bitcast float %tmp23 to i32
330 %tmp36 = icmp ne i32 %tmp31, 0
331 br i1 %tmp36, label %bb38, label %bb80
332
333bb38: ; preds = %bb
334 %tmp52 = bitcast float %tmp29 to i32
335 %tmp53 = bitcast float %tmp30 to i32
336 %tmp54 = insertelement <2 x i32> undef, i32 %tmp52, i32 0
337 %tmp55 = insertelement <2 x i32> %tmp54, i32 %tmp53, i32 1
338 %tmp56 = bitcast <8 x i32> %tmp26 to <32 x i8>
339 %tmp57 = bitcast <4 x i32> %tmp28 to <16 x i8>
340 %tmp58 = call <4 x float> @llvm.SI.sample.v2i32(<2 x i32> %tmp55, <32 x i8> %tmp56, <16 x i8> %tmp57, i32 2)
341 br label %bb71
342
343bb80: ; preds = %bb
344 %tmp81 = bitcast float %tmp29 to i32
345 %tmp82 = bitcast float %tmp30 to i32
346 %tmp82.2 = add i32 %tmp82, 1
347 %tmp83 = insertelement <2 x i32> undef, i32 %tmp81, i32 0
348 %tmp84 = insertelement <2 x i32> %tmp83, i32 %tmp82.2, i32 1
349 %tmp85 = bitcast <8 x i32> %tmp26 to <32 x i8>
350 %tmp86 = bitcast <4 x i32> %tmp28 to <16 x i8>
351 %tmp87 = call <4 x float> @llvm.SI.sample.v2i32(<2 x i32> %tmp84, <32 x i8> %tmp85, <16 x i8> %tmp86, i32 2)
352 br label %bb71
353
354bb71: ; preds = %bb80, %bb38
355 %tmp72 = phi <4 x float> [ %tmp58, %bb38 ], [ %tmp87, %bb80 ]
356 %tmp88 = extractelement <4 x float> %tmp72, i32 0
357 call void @llvm.SI.export(i32 15, i32 1, i32 1, i32 0, i32 1, float %tmp88, float %tmp88, float %tmp88, float %tmp88)
358 ret void
359}
360
361attributes #0 = { "ShaderType"="0" "unsafe-fp-math"="true" }
362attributes #1 = { nounwind readnone }
Matt Arsenault325cca32016-01-23 05:42:43 +0000363attributes #2 = { readonly }
364attributes #3 = { readnone }
365
366!0 = !{!1, !1, i64 0, i32 1}
367!1 = !{!"const", null}
368!2 = !{!1, !1, i64 0}