Debian Codegraph @

llvm/test/CodeGen/SPIRV/uitofp-with-bool.ll

raw
1 ; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPV
2
3 ;; The IR was generated from the following source:
4 ;; void __kernel K(global float* A, int B) {
5 ;; bool Cmp = B > 0;
6 ;; A[0] = Cmp;
7 ;; }
8 ;; Command line:
9 ;; clang -x cl -cl-std=CL2.0 -target spir64 -emit-llvm -S -c test.cl
10
11
12 ; SPV-DAG: %[[#int_32:]] = OpTypeInt 32 0
13 ; SPV-DAG: %[[#int_8:]] = OpTypeInt 8 0
14 ; SPV-DAG: %[[#int_16:]] = OpTypeInt 16 0
15 ; SPV-DAG: %[[#int_64:]] = OpTypeInt 64 0
16 ; SPV-DAG: %[[#zero_32:]] = OpConstantNull %[[#int_32]]
17 ; SPV-DAG: %[[#one_32:]] = OpConstant %[[#int_32]] 1
18 ; SPV-DAG: %[[#zero_8:]] = OpConstantNull %[[#int_8]]
19 ; SPV-DAG: %[[#mone_8:]] = OpConstant %[[#int_8]] 255
20 ; SPV-DAG: %[[#zero_16:]] = OpConstantNull %[[#int_16]]
21 ; SPV-DAG: %[[#mone_16:]] = OpConstant %[[#int_16]] 65535
22 ; SPV-DAG: %[[#mone_32:]] = OpConstant %[[#int_32]] 4294967295
23 ; SPV-DAG: %[[#zero_64:]] = OpConstantNull %[[#int_64]]
24 ; SPV-DAG: %[[#mone_64:]] = OpConstant %[[#int_64]] 18446744073709551615
25 ; SPV-DAG: %[[#one_8:]] = OpConstant %[[#int_8]] 1
26 ; SPV-DAG: %[[#one_16:]] = OpConstant %[[#int_16]] 1
27 ; SPV-DAG: %[[#one_64:]] = OpConstant %[[#int_64]] 1
28 ; SPV-DAG: %[[#void:]] = OpTypeVoid
29 ; SPV-DAG: %[[#float:]] = OpTypeFloat 32
30 ; SPV-DAG: %[[#bool:]] = OpTypeBool
31 ; SPV-DAG: %[[#vec_8:]] = OpTypeVector %[[#int_8]] 2
32 ; SPV-DAG: %[[#vec_1:]] = OpTypeVector %[[#bool]] 2
33 ; SPV-DAG: %[[#vec_16:]] = OpTypeVector %[[#int_16]] 2
34 ; SPV-DAG: %[[#vec_32:]] = OpTypeVector %[[#int_32]] 2
35 ; SPV-DAG: %[[#vec_64:]] = OpTypeVector %[[#int_64]] 2
36 ; SPV-DAG: %[[#vec_float:]] = OpTypeVector %[[#float]] 2
37 ; SPV-DAG: %[[#zeros_8:]] = OpConstantNull %[[#vec_8]]
38 ; SPV-DAG: %[[#mones_8:]] = OpConstantComposite %[[#vec_8]] %[[#mone_8]] %[[#mone_8]]
39 ; SPV-DAG: %[[#zeros_16:]] = OpConstantNull %[[#vec_16]]
40 ; SPV-DAG: %[[#mones_16:]] = OpConstantComposite %[[#vec_16]] %[[#mone_16]] %[[#mone_16]]
41 ; SPV-DAG: %[[#zeros_32:]] = OpConstantNull %[[#vec_32]]
42 ; SPV-DAG: %[[#mones_32:]] = OpConstantComposite %[[#vec_32]] %[[#mone_32]] %[[#mone_32]]
43 ; SPV-DAG: %[[#zeros_64:]] = OpConstantNull %[[#vec_64]]
44 ; SPV-DAG: %[[#mones_64:]] = OpConstantComposite %[[#vec_64]] %[[#mone_64]] %[[#mone_64]]
45 ; SPV-DAG: %[[#ones_8:]] = OpConstantComposite %[[#vec_8]] %[[#one_8]] %[[#one_8]]
46 ; SPV-DAG: %[[#ones_16:]] = OpConstantComposite %[[#vec_16]] %[[#one_16]] %[[#one_16]]
47 ; SPV-DAG: %[[#ones_32:]] = OpConstantComposite %[[#vec_32]] %[[#one_32]] %[[#one_32]]
48 ; SPV-DAG: %[[#ones_64:]] = OpConstantComposite %[[#vec_64]] %[[#one_64]] %[[#one_64]]
49 ; SPV-DAG: %[[#pointer:]] = OpTypePointer CrossWorkgroup %[[#float]]
50
51 @G_s1 = global i8 0
52 @G_s2 = global i16 0
53 @G_s3 = global i32 0
54 @G_s4 = global i64 0
55 @G_s5 = global <2 x i8> zeroinitializer
56 @G_s6 = global <2 x i16> zeroinitializer
57 @G_s7 = global <2 x i32> zeroinitializer
58 @G_s8 = global <2 x i64> zeroinitializer
59 @G_z1 = global i8 0
60 @G_z2 = global i16 0
61 @G_z3 = global i32 0
62 @G_z4 = global i64 0
63 @G_z5 = global <2 x i8> zeroinitializer
64 @G_z6 = global <2 x i16> zeroinitializer
65 @G_z7 = global <2 x i32> zeroinitializer
66 @G_z8 = global <2 x i64> zeroinitializer
67 @G_ufp1 = global float 0.0
68 @G_ufp2 = global <2 x float> zeroinitializer
69 @G_sfp1 = global float 0.0
70 @G_sfp2 = global <2 x float> zeroinitializer
71
72 ; SPV-DAG: OpFunction
73 ; SPV-DAG: %[[#A:]] = OpFunctionParameter %[[#pointer]]
74 ; SPV-DAG: %[[#B:]] = OpFunctionParameter %[[#]]
75 ; SPV-DAG: %[[#i1s:]] = OpFunctionParameter %[[#]]
76 ; SPV-DAG: %[[#i1v:]] = OpFunctionParameter %[[#]]
77
78 define dso_local spir_kernel void @K(ptr addrspace(1) nocapture %A, i32 %B, i1 %i1s, <2 x i1> %i1v) local_unnamed_addr {
79 entry:
80
81 ; SPV: %[[#cmp_res:]] = OpSGreaterThan %[[#bool]] %[[#B]] %[[#zero_32]]
82 %cmp = icmp sgt i32 %B, 0
83 ; SPV: %[[#select_res:]] = OpSelect %[[#int_32]] %[[#cmp_res]] %[[#one_32]] %[[#zero_32]]
84 ; SPV: %[[#utof_res:]] = OpConvertUToF %[[#float]] %[[#select_res]]
85 %conv = uitofp i1 %cmp to float
86 ; SPV: OpStore %[[#A]] %[[#utof_res]]
87 store float %conv, ptr addrspace(1) %A, align 4;
88
89 ; SPV: %[[#s1:]] = OpSelect %[[#int_8]] %[[#i1s]] %[[#mone_8]] %[[#zero_8]]
90 %s1 = sext i1 %i1s to i8
91 store i8 %s1, ptr @G_s1
92 ; SPV: %[[#s2:]] = OpSelect %[[#int_16]] %[[#i1s]] %[[#mone_16]] %[[#zero_16]]
93 %s2 = sext i1 %i1s to i16
94 store i16 %s2, ptr @G_s2
95 ; SPV: %[[#s3:]] = OpSelect %[[#int_32]] %[[#i1s]] %[[#mone_32]] %[[#zero_32]]
96 %s3 = sext i1 %i1s to i32
97 store i32 %s3, ptr @G_s3
98 ; SPV: %[[#s4:]] = OpSelect %[[#int_64]] %[[#i1s]] %[[#mone_64]] %[[#zero_64]]
99 %s4 = sext i1 %i1s to i64
100 store i64 %s4, ptr @G_s4
101 ; SPV: %[[#s5:]] = OpSelect %[[#vec_8]] %[[#i1v]] %[[#mones_8]] %[[#zeros_8]]
102 %s5 = sext <2 x i1> %i1v to <2 x i8>
103 store <2 x i8> %s5, ptr @G_s5
104 ; SPV: %[[#s6:]] = OpSelect %[[#vec_16]] %[[#i1v]] %[[#mones_16]] %[[#zeros_16]]
105 %s6 = sext <2 x i1> %i1v to <2 x i16>
106 store <2 x i16> %s6, ptr @G_s6
107 ; SPV: %[[#s7:]] = OpSelect %[[#vec_32]] %[[#i1v]] %[[#mones_32]] %[[#zeros_32]]
108 %s7 = sext <2 x i1> %i1v to <2 x i32>
109 store <2 x i32> %s7, ptr @G_s7
110 ; SPV: %[[#s8:]] = OpSelect %[[#vec_64]] %[[#i1v]] %[[#mones_64]] %[[#zeros_64]]
111 %s8 = sext <2 x i1> %i1v to <2 x i64>
112 store <2 x i64> %s8, ptr @G_s8
113 ; SPV: %[[#z1:]] = OpSelect %[[#int_8]] %[[#i1s]] %[[#one_8]] %[[#zero_8]]
114 %z1 = zext i1 %i1s to i8
115 store i8 %z1, ptr @G_z1
116 ; SPV: %[[#z2:]] = OpSelect %[[#int_16]] %[[#i1s]] %[[#one_16]] %[[#zero_16]]
117 %z2 = zext i1 %i1s to i16
118 store i16 %z2, ptr @G_z2
119 ; SPV: %[[#z3:]] = OpSelect %[[#int_32]] %[[#i1s]] %[[#one_32]] %[[#zero_32]]
120 %z3 = zext i1 %i1s to i32
121 store i32 %z3, ptr @G_z3
122 ; SPV: %[[#z4:]] = OpSelect %[[#int_64]] %[[#i1s]] %[[#one_64]] %[[#zero_64]]
123 %z4 = zext i1 %i1s to i64
124 store i64 %z4, ptr @G_z4
125 ; SPV: %[[#z5:]] = OpSelect %[[#vec_8]] %[[#i1v]] %[[#ones_8]] %[[#zeros_8]]
126 %z5 = zext <2 x i1> %i1v to <2 x i8>
127 store <2 x i8> %z5, ptr @G_z5
128 ; SPV: %[[#z6:]] = OpSelect %[[#vec_16]] %[[#i1v]] %[[#ones_16]] %[[#zeros_16]]
129 %z6 = zext <2 x i1> %i1v to <2 x i16>
130 store <2 x i16> %z6, ptr @G_z6
131 ; SPV: %[[#z7:]] = OpSelect %[[#vec_32]] %[[#i1v]] %[[#ones_32]] %[[#zeros_32]]
132 %z7 = zext <2 x i1> %i1v to <2 x i32>
133 store <2 x i32> %z7, ptr @G_z7
134 ; SPV: %[[#z8:]] = OpSelect %[[#vec_64]] %[[#i1v]] %[[#ones_64]] %[[#zeros_64]]
135 %z8 = zext <2 x i1> %i1v to <2 x i64>
136 store <2 x i64> %z8, ptr @G_z8
137 ; SPV: %[[#ufp1_res:]] = OpSelect %[[#int_32]] %[[#i1s]] %[[#one_32]] %[[#zero_32]]
138 ; SPV: %[[#ufp1:]] = OpConvertUToF %[[#float]] %[[#ufp1_res]]
139 %ufp1 = uitofp i1 %i1s to float
140 store float %ufp1, ptr @G_ufp1
141 ; SPV: %[[#ufp2_res:]] = OpSelect %[[#vec_32]] %[[#i1v]] %[[#ones_32]] %[[#zeros_32]]
142 ; SPV: %[[#ufp2:]] = OpConvertUToF %[[#vec_float]] %[[#ufp2_res]]
143 %ufp2 = uitofp <2 x i1> %i1v to <2 x float>
144 store <2 x float> %ufp2, ptr @G_ufp2
145 ; SPV: %[[#sfp1_res:]] = OpSelect %[[#int_32]] %[[#i1s]] %[[#one_32]] %[[#zero_32]]
146 ; SPV: %[[#sfp1:]] = OpConvertSToF %[[#float]] %[[#sfp1_res]]
147 %sfp1 = sitofp i1 %i1s to float
148 store float %sfp1, ptr @G_sfp1
149 ; SPV: %[[#sfp2_res:]] = OpSelect %[[#vec_32]] %[[#i1v]] %[[#ones_32]] %[[#zeros_32]]
150 ; SPV: %[[#sfp2:]] = OpConvertSToF %[[#vec_float]] %[[#sfp2_res]]
151 %sfp2 = sitofp <2 x i1> %i1v to <2 x float>
152 store <2 x float> %sfp2, ptr @G_sfp2
153 ret void
154 }