blob: fd56d956bf31c1f20f88620dc5e409da3b0638e5 [file] [log] [blame]
Tom Stellard49f8bfd2015-01-06 18:00:21 +00001; RUN: llc -march=amdgcn -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
Marek Olsak75170772015-01-27 17:27:15 +00002; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
Tom Stellard20ee94f2013-08-14 22:22:09 +00003
4; This test just checks that the compiler doesn't crash.
Matt Arsenault2acc7a42014-06-11 19:31:13 +00005
6declare void @llvm.SI.export(i32, i32, i32, i32, i32, float, float, float, float)
7
Tom Stellard79243d92014-10-01 17:15:17 +00008; FUNC-LABEL: {{^}}v32i8_to_v8i32:
Tom Stellard326d6ec2014-11-05 14:50:53 +00009; SI: s_endpgm
Tom Stellard20ee94f2013-08-14 22:22:09 +000010define void @v32i8_to_v8i32(<32 x i8> addrspace(2)* inreg) #0 {
11entry:
David Blaikiea79ac142015-02-27 21:17:42 +000012 %1 = load <32 x i8>, <32 x i8> addrspace(2)* %0
Tom Stellard20ee94f2013-08-14 22:22:09 +000013 %2 = bitcast <32 x i8> %1 to <8 x i32>
14 %3 = extractelement <8 x i32> %2, i32 1
15 %4 = icmp ne i32 %3, 0
16 %5 = select i1 %4, float 0.0, float 1.0
17 call void @llvm.SI.export(i32 15, i32 1, i32 1, i32 0, i32 1, float %5, float %5, float %5, float %5)
18 ret void
19}
20
Tom Stellard79243d92014-10-01 17:15:17 +000021; FUNC-LABEL: {{^}}i8ptr_v16i8ptr:
Tom Stellard326d6ec2014-11-05 14:50:53 +000022; SI: s_endpgm
Tom Stellard6c7a7e82014-02-13 23:34:12 +000023define void @i8ptr_v16i8ptr(<16 x i8> addrspace(1)* %out, i8 addrspace(1)* %in) {
24entry:
25 %0 = bitcast i8 addrspace(1)* %in to <16 x i8> addrspace(1)*
David Blaikiea79ac142015-02-27 21:17:42 +000026 %1 = load <16 x i8>, <16 x i8> addrspace(1)* %0
Tom Stellard6c7a7e82014-02-13 23:34:12 +000027 store <16 x i8> %1, <16 x i8> addrspace(1)* %out
28 ret void
29}
Matt Arsenault064c2062014-06-11 17:40:32 +000030
31define void @f32_to_v2i16(<2 x i16> addrspace(1)* %out, float addrspace(1)* %in) nounwind {
David Blaikiea79ac142015-02-27 21:17:42 +000032 %load = load float, float addrspace(1)* %in, align 4
Matt Arsenault064c2062014-06-11 17:40:32 +000033 %bc = bitcast float %load to <2 x i16>
34 store <2 x i16> %bc, <2 x i16> addrspace(1)* %out, align 4
35 ret void
36}
37
38define void @v2i16_to_f32(float addrspace(1)* %out, <2 x i16> addrspace(1)* %in) nounwind {
David Blaikiea79ac142015-02-27 21:17:42 +000039 %load = load <2 x i16>, <2 x i16> addrspace(1)* %in, align 4
Matt Arsenault064c2062014-06-11 17:40:32 +000040 %bc = bitcast <2 x i16> %load to float
41 store float %bc, float addrspace(1)* %out, align 4
42 ret void
43}
Matt Arsenault364a6742014-06-11 17:50:44 +000044
45define void @v4i8_to_i32(i32 addrspace(1)* %out, <4 x i8> addrspace(1)* %in) nounwind {
David Blaikiea79ac142015-02-27 21:17:42 +000046 %load = load <4 x i8>, <4 x i8> addrspace(1)* %in, align 4
Matt Arsenault364a6742014-06-11 17:50:44 +000047 %bc = bitcast <4 x i8> %load to i32
48 store i32 %bc, i32 addrspace(1)* %out, align 4
49 ret void
50}
51
52define void @i32_to_v4i8(<4 x i8> addrspace(1)* %out, i32 addrspace(1)* %in) nounwind {
David Blaikiea79ac142015-02-27 21:17:42 +000053 %load = load i32, i32 addrspace(1)* %in, align 4
Matt Arsenault364a6742014-06-11 17:50:44 +000054 %bc = bitcast i32 %load to <4 x i8>
55 store <4 x i8> %bc, <4 x i8> addrspace(1)* %out, align 4
56 ret void
57}
Matt Arsenault2acc7a42014-06-11 19:31:13 +000058
Tom Stellard79243d92014-10-01 17:15:17 +000059; FUNC-LABEL: {{^}}bitcast_v2i32_to_f64:
Tom Stellard326d6ec2014-11-05 14:50:53 +000060; SI: s_endpgm
Matt Arsenault2acc7a42014-06-11 19:31:13 +000061define void @bitcast_v2i32_to_f64(double addrspace(1)* %out, <2 x i32> addrspace(1)* %in) {
David Blaikiea79ac142015-02-27 21:17:42 +000062 %val = load <2 x i32>, <2 x i32> addrspace(1)* %in, align 8
Matt Arsenault2acc7a42014-06-11 19:31:13 +000063 %add = add <2 x i32> %val, <i32 4, i32 9>
64 %bc = bitcast <2 x i32> %add to double
65 store double %bc, double addrspace(1)* %out, align 8
66 ret void
67}
68
Tom Stellard79243d92014-10-01 17:15:17 +000069; FUNC-LABEL: {{^}}bitcast_f64_to_v2i32:
Tom Stellard326d6ec2014-11-05 14:50:53 +000070; SI: s_endpgm
Matt Arsenault2acc7a42014-06-11 19:31:13 +000071define void @bitcast_f64_to_v2i32(<2 x i32> addrspace(1)* %out, double addrspace(1)* %in) {
David Blaikiea79ac142015-02-27 21:17:42 +000072 %val = load double, double addrspace(1)* %in, align 8
Matt Arsenault2acc7a42014-06-11 19:31:13 +000073 %add = fadd double %val, 4.0
74 %bc = bitcast double %add to <2 x i32>
75 store <2 x i32> %bc, <2 x i32> addrspace(1)* %out, align 8
76 ret void
77}
78
79attributes #0 = { "ShaderType"="0" }