Debian Codegraph @

llvm-project/llvm/projects/llvm-spirv/test/uitofp-with-bool.ll

raw
1 ; RUN: llvm-as %s -o %t.bc
2 ; RUN: llvm-spirv %t.bc -o %t.spv
3 ; RUN: llvm-spirv %t.spv -o %t.spt --to-text
4 ; RUN: llvm-spirv -r -emit-opaque-pointers -spirv-target-env="SPV-IR" %t.spv -o %t.bc
5 ; RUN: llvm-dis %t.bc -o %t.ll
6 ; RUN: FileCheck %s --input-file %t.spt -check-prefix=SPV
7 ; RUN: FileCheck %s --input-file %t.ll -check-prefix=LLVM
8 ; RUN: spirv-val %t.spv
9
10 ; The IR was generated from the following source:
11 ; void __kernel K(global float* A, int B) {
12 ; bool Cmp = B > 0;
13 ; A[0] = Cmp;
14 ; }
15 ; Command line:
16 ; clang -x cl -cl-std=CL2.0 -target spir64 -emit-llvm -S -c test.cl
17
18
19 ; SPV-DAG: Name [[s1:[0-9]+]] "s1"
20 ; SPV-DAG: Name [[s2:[0-9]+]] "s2"
21 ; SPV-DAG: Name [[s3:[0-9]+]] "s3"
22 ; SPV-DAG: Name [[s4:[0-9]+]] "s4"
23 ; SPV-DAG: Name [[s5:[0-9]+]] "s5"
24 ; SPV-DAG: Name [[s6:[0-9]+]] "s6"
25 ; SPV-DAG: Name [[s7:[0-9]+]] "s7"
26 ; SPV-DAG: Name [[s8:[0-9]+]] "s8"
27 ; SPV-DAG: Name [[z1:[0-9]+]] "z1"
28 ; SPV-DAG: Name [[z2:[0-9]+]] "z2"
29 ; SPV-DAG: Name [[z3:[0-9]+]] "z3"
30 ; SPV-DAG: Name [[z4:[0-9]+]] "z4"
31 ; SPV-DAG: Name [[z5:[0-9]+]] "z5"
32 ; SPV-DAG: Name [[z6:[0-9]+]] "z6"
33 ; SPV-DAG: Name [[z7:[0-9]+]] "z7"
34 ; SPV-DAG: Name [[z8:[0-9]+]] "z8"
35 ; SPV-DAG: Name [[ufp1:[0-9]+]] "ufp1"
36 ; SPV-DAG: Name [[ufp2:[0-9]+]] "ufp2"
37 ; SPV-DAG: Name [[sfp1:[0-9]+]] "sfp1"
38 ; SPV-DAG: Name [[sfp2:[0-9]+]] "sfp2"
39 ; SPV-DAG: TypeInt [[int_32:[0-9]+]] 32 0
40 ; SPV-DAG: TypeInt [[int_8:[0-9]+]] 8 0
41 ; SPV-DAG: TypeInt [[int_16:[0-9]+]] 16 0
42 ; SPV-DAG: TypeInt [[int_64:[0-9]+]] 64 0
43 ; SPV-DAG: Constant [[int_32]] [[zero_32:[0-9]+]] 0
44 ; SPV-DAG: Constant [[int_32]] [[one_32:[0-9]+]] 1
45 ; SPV-DAG: Constant [[int_8]] [[zero_8:[0-9]+]] 0
46 ; SPV-DAG: Constant [[int_8]] [[mone_8:[0-9]+]] 255
47 ; SPV-DAG: Constant [[int_16]] [[zero_16:[0-9]+]] 0
48 ; SPV-DAG: Constant [[int_16]] [[mone_16:[0-9]+]] 65535
49 ; SPV-DAG: Constant [[int_32]] [[mone_32:[0-9]+]] 4294967295
50 ; SPV-DAG: Constant [[int_64]] [[zero_64:[0-9]+]] 0 0
51 ; SPV-DAG: Constant [[int_64]] [[mone_64:[0-9]+]] 4294967295 4294967295
52 ; SPV-DAG: Constant [[int_8]] [[one_8:[0-9]+]] 1
53 ; SPV-DAG: Constant [[int_16]] [[one_16:[0-9]+]] 1
54 ; SPV-DAG: Constant [[int_64]] [[one_64:[0-9]+]] 1 0
55 ; SPV-DAG: TypeVoid [[void:[0-9]+]]
56 ; SPV-DAG: TypeFloat [[float:[0-9]+]] 32
57 ; SPV-DAG: TypeBool [[bool:[0-9]+]]
58 ; SPV-DAG: TypeVector [[vec_8:[0-9]+]] [[int_8]] 2
59 ; SPV-DAG: TypeVector [[vec_1:[0-9]+]] [[bool]] 2
60 ; SPV-DAG: TypeVector [[vec_16:[0-9]+]] [[int_16]] 2
61 ; SPV-DAG: TypeVector [[vec_32:[0-9]+]] [[int_32]] 2
62 ; SPV-DAG: TypeVector [[vec_64:[0-9]+]] [[int_64]] 2
63 ; SPV-DAG: TypeVector [[vec_float:[0-9]+]] [[float]] 2
64 ; SPV-DAG: ConstantNull [[vec_8]] [[zeros_8:[0-9]+]]
65 ; SPV-DAG: ConstantComposite [[vec_8]] [[mones_8:[0-9]+]] [[mone_8]] [[mone_8]]
66 ; SPV-DAG: ConstantNull [[vec_16]] [[zeros_16:[0-9]+]]
67 ; SPV-DAG: ConstantComposite [[vec_16]] [[mones_16:[0-9]+]] [[mone_16]] [[mone_16]]
68 ; SPV-DAG: ConstantNull [[vec_32]] [[zeros_32:[0-9]+]]
69 ; SPV-DAG: ConstantComposite [[vec_32]] [[mones_32:[0-9]+]] [[mone_32]] [[mone_32]]
70 ; SPV-DAG: ConstantNull [[vec_64]] [[zeros_64:[0-9]+]]
71 ; SPV-DAG: ConstantComposite [[vec_64]] [[mones_64:[0-9]+]] [[mone_64]] [[mone_64]]
72 ; SPV-DAG: ConstantComposite [[vec_8]] [[ones_8:[0-9]+]] [[one_8]] [[one_8]]
73 ; SPV-DAG: ConstantComposite [[vec_16]] [[ones_16:[0-9]+]] [[one_16]] [[one_16]]
74 ; SPV-DAG: ConstantComposite [[vec_32]] [[ones_32:[0-9]+]] [[one_32]] [[one_32]]
75 ; SPV-DAG: ConstantComposite [[vec_64]] [[ones_64:[0-9]+]] [[one_64]] [[one_64]]
76
77
78 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
79 target triple = "spir64"
80
81 ; SPV-DAG: Function
82 ; SPV-DAG: FunctionParameter {{[0-9]+}} [[A:[0-9]+]]
83 ; SPV-DAG: FunctionParameter {{[0-9]+}} [[B:[0-9]+]]
84 ; SPV-DAG: FunctionParameter {{[0-9]+}} [[i1s:[0-9]+]]
85 ; SPV-DAG: FunctionParameter {{[0-9]+}} [[i1v:[0-9]+]]
86
87 ; Function Attrs: nofree norecurse nounwind writeonly
88 define dso_local spir_kernel void @K(float addrspace(1)* nocapture %A, i32 %B, i1 %i1s, <2 x i1> %i1v) local_unnamed_addr #0 !kernel_arg_addr_space !2 !kernel_arg_access_qual !3 !kernel_arg_type !4 !kernel_arg_base_type !4 !kernel_arg_type_qual !5 {
89 entry:
90
91
92 ; SPV-DAG: SGreaterThan [[bool]] [[cmp_res:[0-9]+]] [[B]] [[zero_32]]
93 ; LLVM-DAG: %cmp = icmp sgt i32 %B, 0
94 %cmp = icmp sgt i32 %B, 0
95 ; SPV-DAG: Select [[int_32]] [[select_res:[0-9]+]] [[cmp_res]] [[one_32]] [[zero_32]]
96 ; SPV-DAG: ConvertUToF [[float]] [[utof_res:[0-9]+]] [[select_res]]
97 ; LLVM-DAG: %[[sel_res_0:[0-9]+]] = select i1 %cmp, i32 1, i32 0
98 ; LLVM-DAG: %conv = uitofp i32 %[[sel_res_0]] to float
99 %conv = uitofp i1 %cmp to float
100 ; SPV-DAG: Store [[A]] [[utof_res]]
101 ; LLVM-DAG: store float %conv, ptr addrspace(1) %A, align 4
102 store float %conv, float addrspace(1)* %A, align 4;
103
104 ; SPV-DAG: Select [[int_8]] [[s1]] [[i1s]] [[mone_8]] [[zero_8]]
105 ; LLVM-DAG: %s1 = select i1 %i1s, i8 -1, i8 0
106 %s1 = sext i1 %i1s to i8
107 ; SPV-DAG: Select [[int_16]] [[s2]] [[i1s]] [[mone_16]] [[zero_16]]
108 ; LLVM-DAG: %s2 = select i1 %i1s, i16 -1, i16 0
109 %s2 = sext i1 %i1s to i16
110 ; SPV-DAG: Select [[int_32]] [[s3]] [[i1s]] [[mone_32]] [[zero_32]]
111 ; LLVM-DAG: %s3 = select i1 %i1s, i32 -1, i32 0
112 %s3 = sext i1 %i1s to i32
113 ; SPV-DAG: Select [[int_64]] [[s4]] [[i1s]] [[mone_64]] [[zero_64]]
114 ; LLVM-DAG: %s4 = select i1 %i1s, i64 -1, i64 0
115 %s4 = sext i1 %i1s to i64
116 ; SPV-DAG: Select [[vec_8]] [[s5]] [[i1v]] [[mones_8]] [[zeros_8]]
117 ; LLVM-DAG: %s5 = select <2 x i1> %i1v, <2 x i8> <i8 -1, i8 -1>, <2 x i8> zeroinitializer
118 %s5 = sext <2 x i1> %i1v to <2 x i8>
119 ; SPV-DAG: Select [[vec_16]] [[s6]] [[i1v]] [[mones_16]] [[zeros_16]]
120 ; LLVM-DAG: %s6 = select <2 x i1> %i1v, <2 x i16> <i16 -1, i16 -1>, <2 x i16> zeroinitializer
121 %s6 = sext <2 x i1> %i1v to <2 x i16>
122 ; SPV-DAG: Select [[vec_32]] [[s7]] [[i1v]] [[mones_32]] [[zeros_32]]
123 ; LLVM-DAG: %s7 = select <2 x i1> %i1v, <2 x i32> <i32 -1, i32 -1>, <2 x i32> zeroinitializer
124 %s7 = sext <2 x i1> %i1v to <2 x i32>
125 ; SPV-DAG: Select [[vec_64]] [[s8]] [[i1v]] [[mones_64]] [[zeros_64]]
126 ; LLVM-DAG: %s8 = select <2 x i1> %i1v, <2 x i64> <i64 -1, i64 -1>, <2 x i64> zeroinitializer
127 %s8 = sext <2 x i1> %i1v to <2 x i64>
128 ; SPV-DAG: Select [[int_8]] [[z1]] [[i1s]] [[one_8]] [[zero_8]]
129 ; LLVM-DAG: %z1 = select i1 %i1s, i8 1, i8 0
130 %z1 = zext i1 %i1s to i8
131 ; SPV-DAG: Select [[int_16]] [[z2]] [[i1s]] [[one_16]] [[zero_16]]
132 ; LLVM-DAG: %z2 = select i1 %i1s, i16 1, i16 0
133 %z2 = zext i1 %i1s to i16
134 ; SPV-DAG: Select [[int_32]] [[z3]] [[i1s]] [[one_32]] [[zero_32]]
135 ; LLVM-DAG: %z3 = select i1 %i1s, i32 1, i32 0
136 %z3 = zext i1 %i1s to i32
137 ; SPV-DAG: Select [[int_64]] [[z4]] [[i1s]] [[one_64]] [[zero_64]]
138 ; LLVM-DAG: %z4 = select i1 %i1s, i64 1, i64 0
139 %z4 = zext i1 %i1s to i64
140 ; SPV-DAG: Select [[vec_8]] [[z5]] [[i1v]] [[ones_8]] [[zeros_8]]
141 ; LLVM-DAG: %z5 = select <2 x i1> %i1v, <2 x i8> <i8 1, i8 1>, <2 x i8> zeroinitializer
142 %z5 = zext <2 x i1> %i1v to <2 x i8>
143 ; SPV-DAG: Select [[vec_16]] [[z6]] [[i1v]] [[ones_16]] [[zeros_16]]
144 ; LLVM-DAG: %z6 = select <2 x i1> %i1v, <2 x i16> <i16 1, i16 1>, <2 x i16> zeroinitializer
145 %z6 = zext <2 x i1> %i1v to <2 x i16>
146 ; SPV-DAG: Select [[vec_32]] [[z7]] [[i1v]] [[ones_32]] [[zeros_32]]
147 ; LLVM-DAG: %z7 = select <2 x i1> %i1v, <2 x i32> <i32 1, i32 1>, <2 x i32> zeroinitializer
148 %z7 = zext <2 x i1> %i1v to <2 x i32>
149 ; SPV-DAG: Select [[vec_64]] [[z8]] [[i1v]] [[ones_64]] [[zeros_64]]
150 ; LLVM-DAG: %z8 = select <2 x i1> %i1v, <2 x i64> <i64 1, i64 1>, <2 x i64> zeroinitializer
151 %z8 = zext <2 x i1> %i1v to <2 x i64>
152 ; SPV-DAG: Select [[int_32]] [[ufp1_res:[0-9]+]] [[i1s]] [[one_32]] [[zero_32]]
153 ; SPV-DAG: ConvertUToF [[float]] [[ufp1]] [[ufp1_res]]
154 ; LLVM-DAG: %[[ufp1_res_llvm:[0-9]+]] = select i1 %i1s, i32 1, i32 0
155 ; LLVM-DAG: %ufp1 = uitofp i32 %[[ufp1_res_llvm]] to float
156 %ufp1 = uitofp i1 %i1s to float
157 ; SPV-DAG: Select [[vec_32]] [[ufp2_res:[0-9]+]] [[i1v]] [[ones_32]] [[zeros_32]]
158 ; SPV-DAG: ConvertUToF [[vec_float]] [[ufp2]] [[ufp2_res]]
159 ; LLVM-DAG: %[[ufp2_res_llvm:[0-9]+]] = select <2 x i1> %i1v, <2 x i32> <i32 1, i32 1>, <2 x i32> zeroinitializer
160 ; LLVM-DAG: %ufp2 = uitofp <2 x i32> %[[ufp2_res_llvm]] to <2 x float>
161 %ufp2 = uitofp <2 x i1> %i1v to <2 x float>
162 ; SPV-DAG: Select [[int_32]] [[sfp1_res:[0-9]+]] [[i1s]] [[one_32]] [[zero_32]]
163 ; SPV-DAG: ConvertSToF [[float]] [[sfp1]] [[sfp1_res]]
164 ; LLVM-DAG: %[[sfp1_res_llvm:[0-9]+]] = select i1 %i1s, i32 1, i32 0
165 ; LLVM-DAG: %sfp1 = sitofp i32 %[[sfp1_res_llvm:[0-9]+]] to float
166 %sfp1 = sitofp i1 %i1s to float
167 ; SPV-DAG: Select [[vec_32]] [[sfp2_res:[0-9]+]] [[i1v]] [[ones_32]] [[zeros_32]]
168 ; SPV-DAG: ConvertSToF [[vec_float]] [[sfp2]] [[sfp2_res]]
169 ; LLVM-DAG: %[[sfp2_res_llvm:[0-9]+]] = select <2 x i1> %i1v, <2 x i32> <i32 1, i32 1>, <2 x i32> zeroinitializer
170 ; LLVM-DAG: %sfp2 = sitofp <2 x i32> %[[sfp2_res_llvm]] to <2 x float>
171 %sfp2 = sitofp <2 x i1> %i1v to <2 x float>
172 ret void
173 }
174
175
176 attributes #0 = { nofree norecurse nounwind writeonly "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "uniform-work-group-size"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
177
178 !llvm.module.flags = !{!0}
179 !opencl.ocl.version = !{!1}
180 !opencl.spir.version = !{!1}
181
182 !0 = !{i32 1, !"wchar_size", i32 4}
183 !1 = !{i32 2, i32 0}
184 !2 = !{i32 1, i32 0}
185 !3 = !{!"none", !"none"}
186 !4 = !{!"float*", !"int"}
187 !5 = !{!"", !""}