File: math_native_builtins.ll

package info (click to toggle)
intel-graphics-compiler 1.0.17791.18-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 102,312 kB
  • sloc: cpp: 935,343; lisp: 286,143; ansic: 16,196; python: 3,279; yacc: 2,487; lex: 1,642; pascal: 300; sh: 174; makefile: 27
file content (239 lines) | stat: -rw-r--r-- 10,595 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
;=========================== begin_copyright_notice ============================
;
; Copyright (C) 2023 Intel Corporation
;
; SPDX-License-Identifier: MIT
;
;============================ end_copyright_notice =============================

; RUN: %opt %use_old_pass_manager% -GenXTranslateSPIRVBuiltins -vc-spirv-builtins-bif-path=%VC_SPIRV_OCL_BIF% -march=genx64 -mcpu=Gen9 -S < %s | FileCheck %s --check-prefixes=CHECK

target datalayout = "e-p:64:64-i64:64-n8:16:32"
; COM: datalayout should stay the same
; CHECK: target datalayout = "e-p:64:64-i64:64-n8:16:32"

declare spir_func i32 @_Z20__spirv_ocl_popcounti(i32)
declare spir_func double @_Z16__spirv_ocl_sqrtd(double);
declare spir_func i32 @_Z15__spirv_ocl_ctzi(i32)
declare spir_func i64 @_Z15__spirv_ocl_clzl(i64)
declare spir_func <7 x i32> @_Z15__spirv_ocl_ctzDv7_i(<7 x i32>)
declare spir_func <7 x i64> @_Z15__spirv_ocl_clzDv7_l(<7 x i64>)
declare spir_func <7 x float> @_Z22__spirv_ocl_native_cosDv7_f(<7 x float>)
declare spir_func <7 x float> @_Z25__spirv_ocl_native_divideDv7_fS_(<7 x float>, <7 x float>)
declare spir_func <7 x float> @_Z22__spirv_ocl_native_expDv7_f(<7 x float>)
declare spir_func <7 x float> @_Z23__spirv_ocl_native_exp2Dv7_f(<7 x float>)
declare spir_func <7 x float> @_Z24__spirv_ocl_native_exp10Dv7_f(<7 x float>)
declare spir_func <7 x float> @_Z22__spirv_ocl_native_logDv7_f(<7 x float>)
declare spir_func <7 x float> @_Z23__spirv_ocl_native_log2Dv7_f(<7 x float>)
declare spir_func <7 x float> @_Z24__spirv_ocl_native_log10Dv7_f(<7 x float>)
declare spir_func <7 x float> @_Z23__spirv_ocl_native_powrDv7_fS_(<7 x float>, <7 x float>)
declare spir_func <7 x float> @_Z24__spirv_ocl_native_recipDv7_f(<7 x float>)
declare spir_func <7 x float> @_Z23__spirv_ocl_native_rsqrtDv7_f(<7 x float>)
declare spir_func <7 x float> @_Z22__spirv_ocl_native_sinDv7_f(<7 x float>)
declare spir_func <7 x float> @_Z23__spirv_ocl_native_sqrtDv7_f(<7 x float>)
declare spir_func <7 x float> @_Z22__spirv_ocl_native_tanDv7_f(<7 x float>)
declare spir_func <7 x double> @_Z16__spirv_ocl_fminDv7_dS_(<7 x double>, <7 x double>)
declare spir_func float @_Z15__spirv_ocl_madfff(float, float, float)
declare spir_func <16 x float> @_Z15__spirv_ocl_madDv16_fS_S_(<16 x float>, <16 x float>, <16 x float>)
declare spir_func <7 x double> @_Z15__spirv_ocl_fmaDv7_dS_S_(<7 x double>, <7 x double>, <7 x double>)
declare spir_func <7 x double> @_Z15__spirv_ocl_fmaxDv7_dS_S_(<7 x double>, <7 x double>)
declare spir_func <16 x double> @_Z16__spirv_ocl_fabsDv16_d(<16 x double>)
declare spir_func <7 x double> @_Z15__spirv_ocl_copysignDv7_dS_S_(<7 x double>, <7 x double>)

define spir_func i32 @popcount(i32 %arg) {
; CHECK-LABEL: @popcount
; CHECK: %res = call i32 @llvm.ctpop.i32(i32 %arg)
  %res = call spir_func i32 @_Z20__spirv_ocl_popcounti(i32 %arg)
  ret i32 %res
}

define spir_func double @sqrtd(double %arg) {
; CHECK-LABEL: @sqrtd
; CHECK: %res = call double @llvm.sqrt.f64(double %arg)
  %res = call spir_func double @_Z16__spirv_ocl_sqrtd(double %arg)
  ret double %res
}

define spir_func i32 @ctz_scalar(i32 %arg) {
; CHECK-LABEL: @ctz_scalar
; CHECK: %res = call i32 @llvm.cttz.i32(i32 %arg, i1 false)
  %res = call spir_func i32 @_Z15__spirv_ocl_ctzi(i32 %arg)
  ret i32 %res
}

define spir_func i64 @clz_scalar(i64 %arg) {
; CHECK-LABEL: @clz_scalar
; CHECK: %res = call i64 @llvm.ctlz.i64(i64 %arg, i1 false)
  %res = call spir_func i64 @_Z15__spirv_ocl_clzl(i64 %arg)
  ret i64 %res
}

define spir_func <7 x i32> @ctz_vector(<7 x i32> %arg) {
; CHECK-LABEL: @ctz_vector
; CHECK: %res = call <7 x i32> @llvm.cttz.v7i32(<7 x i32> %arg, i1 false)
  %res = call spir_func <7 x i32> @_Z15__spirv_ocl_ctzDv7_i(<7 x i32> %arg)
  ret <7 x i32> %res
}

define spir_func <7 x i64> @clz_vector(<7 x i64> %arg) {
; CHECK-LABEL: @clz_vector
; CHECK: %res = call <7 x i64> @llvm.ctlz.v7i64(<7 x i64> %arg, i1 false)
  %res = call spir_func <7 x i64> @_Z15__spirv_ocl_clzDv7_l(<7 x i64> %arg)
  ret <7 x i64> %res
}

define spir_func <7 x float> @cos(<7 x float> %src) {
  ; CHECK-LABEL: @cos
  ; CHECK: %res = call afn <7 x float> @llvm.cos.v7f32(<7 x float> %src)
  %res = call <7 x float> @_Z22__spirv_ocl_native_cosDv7_f(<7 x float> %src)
  ret <7 x float> %res
}

define spir_func <7 x float> @divide(<7 x float> %l, <7 x float> %r) {
  ; CHECK-LABEL: @divide
  ; CHECK: %res = fdiv arcp <7 x float> %l, %r
  %res = call <7 x float> @_Z25__spirv_ocl_native_divideDv7_fS_(<7 x float> %l, <7 x float> %r)
  ret <7 x float> %res
}

define spir_func <7 x float> @exp(<7 x float> %src) {
  ; CHECK-LABEL: @exp
  ; CHECK: [[MUL:%[^ ]+]] = fmul <7 x float> %src, <float 0x3FF7154760000000
  ; CHECK: %res = call afn <7 x float> @llvm.exp2.v7f32(<7 x float> [[MUL]])
  %res = call <7 x float> @_Z22__spirv_ocl_native_expDv7_f(<7 x float> %src)
  ret <7 x float> %res
}

define spir_func <7 x float> @exp2(<7 x float> %src) {
  ; CHECK-LABEL: @exp2
  ; CHECK: %res = call afn <7 x float> @llvm.exp2.v7f32(<7 x float> %src)
  %res = call <7 x float> @_Z23__spirv_ocl_native_exp2Dv7_f(<7 x float> %src)
  ret <7 x float> %res
}

define spir_func <7 x float> @exp10(<7 x float> %src) {
  ; CHECK-LABEL: @exp10
  ; CHECK: [[MUL:%[^ ]+]] = fmul <7 x float> %src, <float 0x400A934F00000000,
  ; CHECK: %res = call afn <7 x float> @llvm.exp2.v7f32(<7 x float> [[MUL]])
  %res = call <7 x float> @_Z24__spirv_ocl_native_exp10Dv7_f(<7 x float> %src)
  ret <7 x float> %res
}

define spir_func <7 x float> @log(<7 x float> %src) {
  ; CHECK-LABEL: @log
  ; CHECK: [[LOG:%[^ ]+]] = call afn <7 x float> @llvm.log2.v7f32(<7 x float> %src)
  ; CHECK: %res = fmul <7 x float> [[LOG]], <float 0x3FE62E4300000000
  %res = call <7 x float> @_Z22__spirv_ocl_native_logDv7_f(<7 x float> %src)
  ret <7 x float> %res
}

define spir_func <7 x float> @log2(<7 x float> %src) {
  ; CHECK-LABEL: @log2
  ; CHECK: %res = call afn <7 x float> @llvm.log2.v7f32(<7 x float> %src)
  %res = call <7 x float> @_Z23__spirv_ocl_native_log2Dv7_f(<7 x float> %src)
  ret <7 x float> %res
}

define spir_func <7 x float> @log10(<7 x float> %src) {
  ; CHECK-LABEL: @log10
  ; CHECK: [[LOG:%[^ ]+]] = call afn <7 x float> @llvm.log2.v7f32(<7 x float> %src)
  ; CHECK: %res = fmul <7 x float> [[LOG]], <float 0x3FD3441360000000
  %res = call <7 x float> @_Z24__spirv_ocl_native_log10Dv7_f(<7 x float> %src)
  ret <7 x float> %res
}

define spir_func <7 x float> @powr(<7 x float> %l, <7 x float> %r) {
  ; CHECK-LABEL: @powr
  ; CHECK: %res = call afn <7 x float> @llvm.pow.v7f32(<7 x float> %l, <7 x float> %r)
  %res = call <7 x float> @_Z23__spirv_ocl_native_powrDv7_fS_(<7 x float> %l, <7 x float> %r)
  ret <7 x float> %res
}

define spir_func <7 x float> @recip(<7 x float> %src) {
  ; CHECK-LABEL: @recip
  ; CHECK: %res = fdiv arcp <7 x float> <float 1.000000e+00
  ; CHECK-SAME: %src
  %res = call <7 x float> @_Z24__spirv_ocl_native_recipDv7_f(<7 x float> %src)
  ret <7 x float> %res
}

define spir_func <7 x float> @rsqrt(<7 x float> %src) {
  ; CHECK-LABEL: @rsqrt
  ; CHECK: [[SQRT:%[^ ]+]] = call afn <7 x float> @llvm.sqrt.v7f32(<7 x float> %src)
  ; CHECK: %res = fdiv arcp <7 x float> <float 1.000000e+00
  ; CHECK-SAME: [[SQRT]]
  %res = call <7 x float> @_Z23__spirv_ocl_native_rsqrtDv7_f(<7 x float> %src)
  ret <7 x float> %res
}

define spir_func <7 x float> @sin(<7 x float> %src) {
  ; CHECK-LABEL: @sin
  ; CHECK: %res = call afn <7 x float> @llvm.sin.v7f32(<7 x float> %src)
  %res = call <7 x float> @_Z22__spirv_ocl_native_sinDv7_f(<7 x float> %src)
  ret <7 x float> %res
}

define spir_func <7 x float> @sqrt(<7 x float> %src) {
  ; CHECK-LABEL: @sqrt
  ; CHECK: %res = call afn <7 x float> @llvm.sqrt.v7f32(<7 x float> %src)
  %res = call <7 x float> @_Z23__spirv_ocl_native_sqrtDv7_f(<7 x float> %src)
  ret <7 x float> %res
}

define spir_func <7 x float> @tan(<7 x float> %src) {
  ; CHECK-LABEL: @tan
  ; CHECK-DAG: [[SIN:%[^ ]+]] = call afn <7 x float> @llvm.sin.v7f32(<7 x float> %src)
  ; CHECK-DAG: [[COS:%[^ ]+]] = call afn <7 x float> @llvm.cos.v7f32(<7 x float> %src)
  ; CHECK: %res = fdiv arcp <7 x float> [[SIN]], [[COS]]
  %res = call <7 x float> @_Z22__spirv_ocl_native_tanDv7_f(<7 x float> %src)
  ret <7 x float> %res
}

define spir_func <7 x double> @fmin(<7 x double> %arg1, <7 x double> %arg2) {
; CHECK-LABEL: @fmin
; CHECK: %res = call <7 x double> @llvm.minnum.v7f64(<7 x double> %arg1, <7 x double> %arg2)
  %res = call spir_func <7 x double> @_Z16__spirv_ocl_fminDv7_dS_(<7 x double> %arg1, <7 x double> %arg2)
  ret <7 x double> %res
}

define spir_func float @mad_scalar(float %arg1, float %arg2, float %arg3) {
; CHECK-LABEL: @mad_scalar
; CHECK: %res = call float @llvm.fmuladd.f32(float %arg1, float %arg2, float %arg3)
  %res = call spir_func float @_Z15__spirv_ocl_madfff(float %arg1, float %arg2, float %arg3)
  ret float %res
}

define spir_func <16 x float> @mad_vector(<16 x float> %arg1, <16 x float> %arg2, <16 x float> %arg3) {
; CHECK-LABEL: @mad_vector
; CHECK: %res = call <16 x float> @llvm.fmuladd.v16f32(<16 x float> %arg1, <16 x float> %arg2, <16 x float> %arg3)
  %res = call spir_func <16 x float> @_Z15__spirv_ocl_madDv16_fS_S_(<16 x float> %arg1, <16 x float> %arg2, <16 x float> %arg3)
  ret <16 x float> %res
}

define spir_func <7 x double> @fma_vector(<7 x double> %arg1, <7 x double> %arg2, <7 x double> %arg3) {
; CHECK-LABEL: @fma_vector
; CHECK: %res = call <7 x double> @llvm.fma.v7f64(<7 x double> %arg1, <7 x double> %arg2, <7 x double> %arg3)
  %res = call spir_func <7 x double> @_Z15__spirv_ocl_fmaDv7_dS_S_(<7 x double> %arg1, <7 x double> %arg2, <7 x double> %arg3)
  ret <7 x double> %res
}

define spir_func <7 x double> @fmax_vector(<7 x double> %arg1, <7 x double> %arg2) {
; CHECK-LABEL: @fmax_vector
; CHECK: %res = call <7 x double> @llvm.maxnum.v7f64(<7 x double> %arg1, <7 x double> %arg2)
  %res = call spir_func <7 x double> @_Z15__spirv_ocl_fmaxDv7_dS_S_(<7 x double> %arg1, <7 x double> %arg2)
  ret <7 x double> %res
}

define spir_func <16 x double> @abs_vector(<16 x double> %arg) {
; CHECK-LABEL: @abs_vector
; CHECK: %res = call <16 x double> @llvm.fabs.v16f64(<16 x double> %arg)
  %res = call spir_func <16 x double> @_Z16__spirv_ocl_fabsDv16_d(<16 x double> %arg)
  ret <16 x double> %res
}

define spir_func <7 x double> @copysign_vector(<7 x double> %arg1, <7 x double> %arg2) {
; CHECK-LABEL: @copysign_vector
; CHECK: %res = call <7 x double> @llvm.copysign.v7f64(<7 x double> %arg1, <7 x double> %arg2)
  %res = call spir_func <7 x double> @_Z15__spirv_ocl_copysignDv7_dS_S_(<7 x double> %arg1, <7 x double> %arg2)
  ret <7 x double> %res
}