xref: /llvm-project/llvm/test/CodeGen/SPIRV/transcoding/relationals_float.ll (revision 0a443f13b49b3f392461a0bb60b0146cfc4607c7)
1; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
2; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}
3
4;; This test checks following SYCL relational builtins with float and float2
5;; types:
6;;   isfinite, isinf, isnan, isnormal, signbit, isequal, isnotequal, isgreater
7;;   isgreaterequal, isless, islessequal, islessgreater, isordered, isunordered
8
9; CHECK-SPIRV: %[[#BoolTypeID:]] = OpTypeBool
10; CHECK-SPIRV: %[[#BoolVectorTypeID:]] = OpTypeVector %[[#BoolTypeID]] 2
11
12; CHECK-SPIRV: OpIsFinite %[[#BoolTypeID]]
13; CHECK-SPIRV: OpIsInf %[[#BoolTypeID]]
14; CHECK-SPIRV: OpIsNan %[[#BoolTypeID]]
15; CHECK-SPIRV: OpIsNormal %[[#BoolTypeID]]
16; CHECK-SPIRV: OpSignBitSet %[[#BoolTypeID]]
17; CHECK-SPIRV: OpFOrdEqual %[[#BoolTypeID]]
18; CHECK-SPIRV: OpFUnordNotEqual %[[#BoolTypeID]]
19; CHECK-SPIRV: OpFOrdGreaterThan %[[#BoolTypeID]]
20; CHECK-SPIRV: OpFOrdGreaterThanEqual %[[#BoolTypeID]]
21; CHECK-SPIRV: OpFOrdLessThan %[[#BoolTypeID]]
22; CHECK-SPIRV: OpFOrdLessThanEqual %[[#BoolTypeID]]
23; CHECK-SPIRV: OpFOrdNotEqual %[[#BoolTypeID]]
24; CHECK-SPIRV: OpOrdered %[[#BoolTypeID]]
25; CHECK-SPIRV: OpUnordered %[[#BoolTypeID]]
26
27; CHECK-SPIRV: OpIsFinite %[[#BoolVectorTypeID]]
28; CHECK-SPIRV: OpIsInf %[[#BoolVectorTypeID]]
29; CHECK-SPIRV: OpIsNan %[[#BoolVectorTypeID]]
30; CHECK-SPIRV: OpIsNormal %[[#BoolVectorTypeID]]
31; CHECK-SPIRV: OpSignBitSet %[[#BoolVectorTypeID]]
32; CHECK-SPIRV: OpFOrdEqual %[[#BoolVectorTypeID]]
33; CHECK-SPIRV: OpFUnordNotEqual %[[#BoolVectorTypeID]]
34; CHECK-SPIRV: OpFOrdGreaterThan %[[#BoolVectorTypeID]]
35; CHECK-SPIRV: OpFOrdGreaterThanEqual %[[#BoolVectorTypeID]]
36; CHECK-SPIRV: OpFOrdLessThan %[[#BoolVectorTypeID]]
37; CHECK-SPIRV: OpFOrdLessThanEqual %[[#BoolVectorTypeID]]
38; CHECK-SPIRV: OpFOrdNotEqual %[[#BoolVectorTypeID]]
39; CHECK-SPIRV: OpOrdered %[[#BoolVectorTypeID]]
40; CHECK-SPIRV: OpUnordered %[[#BoolVectorTypeID]]
41
42define dso_local spir_func void @test_scalar(i32 addrspace(4)* nocapture writeonly %out, float %f) local_unnamed_addr {
43entry:
44  %call = tail call spir_func i32 @_Z8isfinitef(float %f)
45  %call1 = tail call spir_func i32 @_Z5isinff(float %f)
46  %add = add nsw i32 %call1, %call
47  %call2 = tail call spir_func i32 @_Z5isnanf(float %f)
48  %add3 = add nsw i32 %add, %call2
49  %call4 = tail call spir_func i32 @_Z8isnormalf(float %f)
50  %add5 = add nsw i32 %add3, %call4
51  %call6 = tail call spir_func i32 @_Z7signbitf(float %f)
52  %add7 = add nsw i32 %add5, %call6
53  %call8 = tail call spir_func i32 @_Z7isequalff(float %f, float %f)
54  %add9 = add nsw i32 %add7, %call8
55  %call10 = tail call spir_func i32 @_Z10isnotequalff(float %f, float %f)
56  %add11 = add nsw i32 %add9, %call10
57  %call12 = tail call spir_func i32 @_Z9isgreaterff(float %f, float %f)
58  %add13 = add nsw i32 %add11, %call12
59  %call14 = tail call spir_func i32 @_Z14isgreaterequalff(float %f, float %f)
60  %add15 = add nsw i32 %add13, %call14
61  %call16 = tail call spir_func i32 @_Z6islessff(float %f, float %f)
62  %add17 = add nsw i32 %add15, %call16
63  %call18 = tail call spir_func i32 @_Z11islessequalff(float %f, float %f)
64  %add19 = add nsw i32 %add17, %call18
65  %call20 = tail call spir_func i32 @_Z13islessgreaterff(float %f, float %f)
66  %add21 = add nsw i32 %add19, %call20
67  %call22 = tail call spir_func i32 @_Z9isorderedff(float %f, float %f)
68  %add23 = add nsw i32 %add21, %call22
69  %call24 = tail call spir_func i32 @_Z11isunorderedff(float %f, float %f)
70  %add25 = add nsw i32 %add23, %call24
71  store i32 %add25, i32 addrspace(4)* %out, align 4
72  ret void
73}
74
75declare spir_func i32 @_Z8isfinitef(float) local_unnamed_addr
76
77declare spir_func i32 @_Z5isinff(float) local_unnamed_addr
78
79declare spir_func i32 @_Z5isnanf(float) local_unnamed_addr
80
81declare spir_func i32 @_Z8isnormalf(float) local_unnamed_addr
82
83declare spir_func i32 @_Z7signbitf(float) local_unnamed_addr
84
85declare spir_func i32 @_Z7isequalff(float, float) local_unnamed_addr
86
87declare spir_func i32 @_Z10isnotequalff(float, float) local_unnamed_addr
88
89declare spir_func i32 @_Z9isgreaterff(float, float) local_unnamed_addr
90
91declare spir_func i32 @_Z14isgreaterequalff(float, float) local_unnamed_addr
92
93declare spir_func i32 @_Z6islessff(float, float) local_unnamed_addr
94
95declare spir_func i32 @_Z11islessequalff(float, float) local_unnamed_addr
96
97declare spir_func i32 @_Z13islessgreaterff(float, float) local_unnamed_addr
98
99declare spir_func i32 @_Z9isorderedff(float, float) local_unnamed_addr
100
101declare spir_func i32 @_Z11isunorderedff(float, float) local_unnamed_addr
102
103define dso_local spir_func void @test_vector(<2 x i32> addrspace(4)* nocapture writeonly %out, <2 x float> %f) local_unnamed_addr {
104entry:
105  %call = tail call spir_func <2 x i32> @_Z8isfiniteDv2_f(<2 x float> %f)
106  %call1 = tail call spir_func <2 x i32> @_Z5isinfDv2_f(<2 x float> %f)
107  %add = add <2 x i32> %call1, %call
108  %call2 = tail call spir_func <2 x i32> @_Z5isnanDv2_f(<2 x float> %f)
109  %add3 = add <2 x i32> %add, %call2
110  %call4 = tail call spir_func <2 x i32> @_Z8isnormalDv2_f(<2 x float> %f)
111  %add5 = add <2 x i32> %add3, %call4
112  %call6 = tail call spir_func <2 x i32> @_Z7signbitDv2_f(<2 x float> %f)
113  %add7 = add <2 x i32> %add5, %call6
114  %call8 = tail call spir_func <2 x i32> @_Z7isequalDv2_fS_(<2 x float> %f, <2 x float> %f)
115  %add9 = add <2 x i32> %add7, %call8
116  %call10 = tail call spir_func <2 x i32> @_Z10isnotequalDv2_fS_(<2 x float> %f, <2 x float> %f)
117  %add11 = add <2 x i32> %add9, %call10
118  %call12 = tail call spir_func <2 x i32> @_Z9isgreaterDv2_fS_(<2 x float> %f, <2 x float> %f)
119  %add13 = add <2 x i32> %add11, %call12
120  %call14 = tail call spir_func <2 x i32> @_Z14isgreaterequalDv2_fS_(<2 x float> %f, <2 x float> %f)
121  %add15 = add <2 x i32> %add13, %call14
122  %call16 = tail call spir_func <2 x i32> @_Z6islessDv2_fS_(<2 x float> %f, <2 x float> %f)
123  %add17 = add <2 x i32> %add15, %call16
124  %call18 = tail call spir_func <2 x i32> @_Z11islessequalDv2_fS_(<2 x float> %f, <2 x float> %f)
125  %add19 = add <2 x i32> %add17, %call18
126  %call20 = tail call spir_func <2 x i32> @_Z13islessgreaterDv2_fS_(<2 x float> %f, <2 x float> %f)
127  %add21 = add <2 x i32> %add19, %call20
128  %call22 = tail call spir_func <2 x i32> @_Z9isorderedDv2_fS_(<2 x float> %f, <2 x float> %f)
129  %add23 = add <2 x i32> %add21, %call22
130  %call24 = tail call spir_func <2 x i32> @_Z11isunorderedDv2_fS_(<2 x float> %f, <2 x float> %f)
131  %add25 = add <2 x i32> %add23, %call24
132  store <2 x i32> %add25, <2 x i32> addrspace(4)* %out, align 8
133  ret void
134}
135
136declare spir_func <2 x i32> @_Z8isfiniteDv2_f(<2 x float>) local_unnamed_addr
137
138declare spir_func <2 x i32> @_Z5isinfDv2_f(<2 x float>) local_unnamed_addr
139
140declare spir_func <2 x i32> @_Z5isnanDv2_f(<2 x float>) local_unnamed_addr
141
142declare spir_func <2 x i32> @_Z8isnormalDv2_f(<2 x float>) local_unnamed_addr
143
144declare spir_func <2 x i32> @_Z7signbitDv2_f(<2 x float>) local_unnamed_addr
145
146declare spir_func <2 x i32> @_Z7isequalDv2_fS_(<2 x float>, <2 x float>) local_unnamed_addr
147
148declare spir_func <2 x i32> @_Z10isnotequalDv2_fS_(<2 x float>, <2 x float>) local_unnamed_addr
149
150declare spir_func <2 x i32> @_Z9isgreaterDv2_fS_(<2 x float>, <2 x float>) local_unnamed_addr
151
152declare spir_func <2 x i32> @_Z14isgreaterequalDv2_fS_(<2 x float>, <2 x float>) local_unnamed_addr
153
154declare spir_func <2 x i32> @_Z6islessDv2_fS_(<2 x float>, <2 x float>) local_unnamed_addr
155
156declare spir_func <2 x i32> @_Z11islessequalDv2_fS_(<2 x float>, <2 x float>) local_unnamed_addr
157
158declare spir_func <2 x i32> @_Z13islessgreaterDv2_fS_(<2 x float>, <2 x float>) local_unnamed_addr
159
160declare spir_func <2 x i32> @_Z9isorderedDv2_fS_(<2 x float>, <2 x float>) local_unnamed_addr
161
162declare spir_func <2 x i32> @_Z11isunorderedDv2_fS_(<2 x float>, <2 x float>) local_unnamed_addr
163