Debian Codegraph @

llvm/test/CodeGen/SPIRV/transcoding/OpenCL/convert_functions.ll

raw
1 ; This test checks that functions with `convert_` prefix are translated as
2 ; OpenCL builtins only in case they match the specification. Otherwise, we
3 ; expect such functions to be translated to SPIR-V FunctionCall.
4
5 ; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
6 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}
7
8 ; CHECK-SPIRV: OpName %[[#Func:]] "_Z18convert_float_func"
9 ; CHECK-SPIRV: OpName %[[#Func1:]] "_Z20convert_uint_satfunc"
10 ; CHECK-SPIRV: OpName %[[#Func2:]] "_Z21convert_float_rtzfunc"
11 ; CHECK-SPIRV-DAG: %[[#VoidTy:]] = OpTypeVoid
12 ; CHECK-SPIRV-DAG: %[[#CharTy:]] = OpTypeInt 8
13 ; CHECK-SPIRV-DAG: %[[#FloatTy:]] = OpTypeFloat 32
14
15 ; CHECK-SPIRV: %[[#Func]] = OpFunction %[[#VoidTy]] None %[[#]]
16 ; CHECK-SPIRV: %[[#ConvertId1:]] = OpUConvert %[[#CharTy]] %[[#]]
17 ; CHECK-SPIRV: %[[#ConvertId2:]] = OpConvertSToF %[[#FloatTy]] %[[#]]
18 ; CHECK-SPIRV: %[[#]] = OpFunctionCall %[[#VoidTy]] %[[#Func]] %[[#ConvertId2]]
19 ; CHECK-SPIRV: %[[#]] = OpFunctionCall %[[#VoidTy]] %[[#Func1]] %[[#]]
20 ; CHECK-SPIRV: %[[#]] = OpFunctionCall %[[#VoidTy]] %[[#Func2]] %[[#ConvertId2]]
21 ; CHECK-SPIRV-NOT: OpFConvert
22 ; CHECK-SPIRV-NOT: OpConvertUToF
23
24 define dso_local spir_func void @_Z18convert_float_func(float noundef %x) {
25 entry:
26 %x.addr = alloca float, align 4
27 store float %x, ptr %x.addr, align 4
28 ret void
29 }
30
31 define dso_local spir_func void @_Z20convert_uint_satfunc(i32 noundef %x) {
32 entry:
33 ret void
34 }
35
36 define dso_local spir_func void @_Z21convert_float_rtzfunc(float noundef %x) {
37 entry:
38 ret void
39 }
40
41 define dso_local spir_func void @convert_int_bf16(i32 noundef %x) {
42 entry:
43 %x.addr = alloca i32, align 4
44 store i32 %x, ptr %x.addr, align 4
45 %0 = load i32, ptr %x.addr, align 4
46 call spir_func signext i8 @_Z16convert_char_rtei(i32 noundef %0)
47 %call = call spir_func float @_Z13convert_floati(i32 noundef %0)
48 call spir_func void @_Z18convert_float_func(float noundef %call)
49 call spir_func void @_Z20convert_uint_satfunc(i32 noundef %0)
50 call spir_func void @_Z21convert_float_rtzfunc(float noundef %call)
51 ret void
52 }
53
54 declare spir_func signext i8 @_Z16convert_char_rtei(i32 noundef)
55
56 declare spir_func float @_Z13convert_floati(i32 noundef)