Debian Codegraph @

IGC/ocloc_tests/SPIRV-extensions/SPV_INTEL_mini_floats/FP8/ClampConvertHF16ToHF8.ll

raw
1 ;=========================== begin_copyright_notice ============================
2 ;
3 ; Copyright (C) 2024 Intel Corporation
4 ;
5 ; SPDX-License-Identifier: MIT
6 ;
7 ;============================ end_copyright_notice =============================
8
9 ; REQUIRES: llvm-spirv, cri-supported
10 ; RUN: llvm-as %s -o %t.bc
11 ; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_fp_conversions,+SPV_EXT_float8 -o %t.spv
12
13 ; Test IGC compilation
14 ; RUN: ocloc compile -spirv_input -file %t.spv -device cri -options "-igc_opts 'DumpVISAASMToConsole=1'" 2>&1 | FileCheck %s
15
16 ; Test if conversion opcodes are present in spirv disassembly
17 ; RUN: llvm-spirv --to-text %t.spv -o %t.spt
18 ; RUN: cat %t.spt | FileCheck %s -check-prefix=CHECK-SPV
19 ; CHECK-SPV: ClampConvertFToFINTEL
20
21
22 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024"
23 target triple = "spir64-unknown-unknown"
24 declare spir_func i64 @_Z33__spirv_BuiltInGlobalInvocationIdi(i32)
25
26 ; CHECK-LABEL: .kernel "Test_ClampConvertFP16ToE4M3"
27 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT:[A-z0-9]*]](0,0)<1> [[IN:[A-z0-9]*]](0,0)<1;1,0>
28 ; CHECK-DAG: .decl [[IN]] v_type=G type=hf num_elts=32
29 ; CHECK-DAG: .decl [[OUT]] v_type=G type=b num_elts=32
30 declare spir_func signext i8 @_Z43__builtin_spirv_ClampConvertFP16ToE4M3INTELDh(half)
31 define spir_kernel void @Test_ClampConvertFP16ToE4M3(half addrspace(1)* %inbuf, i8 addrspace(1)* %outbuf) {
32 entry:
33 %call = call spir_func i64 @_Z33__spirv_BuiltInGlobalInvocationIdi(i32 0)
34 %arrayidx = getelementptr inbounds half, half addrspace(1)* %inbuf, i64 %call
35 %loaded = load half, half addrspace(1)* %arrayidx, align 2
36 %call1 = call spir_func signext i8 @_Z43__builtin_spirv_ClampConvertFP16ToE4M3INTELDh(half %loaded)
37 %arrayidx3 = getelementptr inbounds i8, i8 addrspace(1)* %outbuf, i64 %call
38 store i8 %call1, i8 addrspace(1)* %arrayidx3, align 1
39 ret void
40 }
41
42 ; CHECK-LABEL: .kernel "Test2_ClampConvertFP16ToE4M3"
43 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT:[A-z0-9]*]](0,0)<1> [[IN:[A-z0-9]*]](0,0)<1;1,0>
44 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](0,32)<1> [[IN]](1,0)<1;1,0>
45 ; CHECK-DAG: .decl [[IN]] v_type=G type=hf num_elts=64
46 ; CHECK-DAG: .decl [[OUT]] v_type=G type=b num_elts=64
47 declare spir_func <2 x i8> @_Z43__builtin_spirv_ClampConvertFP16ToE4M3INTELDv2_Dh(<2 x half>)
48 define spir_kernel void @Test2_ClampConvertFP16ToE4M3(<2 x half> addrspace(1)* %inbuf, <2 x i8> addrspace(1)* %outbuf) {
49 entry:
50 %call = call spir_func i64 @_Z33__spirv_BuiltInGlobalInvocationIdi(i32 0)
51 %arrayidx = getelementptr inbounds <2 x half>, <2 x half> addrspace(1)* %inbuf, i64 %call
52 %loaded = load <2 x half>, <2 x half> addrspace(1)* %arrayidx, align 4
53 %call1 = call spir_func <2 x i8> @_Z43__builtin_spirv_ClampConvertFP16ToE4M3INTELDv2_Dh(<2 x half> %loaded)
54 %arrayidx3 = getelementptr inbounds <2 x i8>, <2 x i8> addrspace(1)* %outbuf, i64 %call
55 store <2 x i8> %call1, <2 x i8> addrspace(1)* %arrayidx3, align 2
56 ret void
57 }
58
59 ; CHECK-LABEL: .kernel "Test3_ClampConvertFP16ToE4M3"
60 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT:[A-z0-9]*]](0,0)<1> [[IN:[A-z0-9]*]](0,0)<1;1,0>
61 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](0,32)<1> [[IN]](1,0)<1;1,0>
62 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](1,0)<1> [[IN]](2,0)<1;1,0>
63 ; CHECK-DAG: .decl [[IN]] v_type=G type=hf num_elts=96
64 ; CHECK-DAG: .decl [[OUT]] v_type=G type=b num_elts=96
65 declare spir_func <3 x i8> @_Z43__builtin_spirv_ClampConvertFP16ToE4M3INTELDv3_Dh(<3 x half>)
66 define spir_kernel void @Test3_ClampConvertFP16ToE4M3(<3 x half> addrspace(1)* %inbuf, <3 x i8> addrspace(1)* %outbuf) {
67 entry:
68 %call = call spir_func i64 @_Z33__spirv_BuiltInGlobalInvocationIdi(i32 0)
69 %arrayidx = getelementptr inbounds <3 x half>, <3 x half> addrspace(1)* %inbuf, i64 %call
70 %inputLoaded = load <3 x half>, <3 x half> addrspace(1)* %arrayidx, align 8
71 %call1 = call spir_func <3 x i8> @_Z43__builtin_spirv_ClampConvertFP16ToE4M3INTELDv3_Dh(<3 x half> %inputLoaded)
72 %arrayidx3 = getelementptr inbounds <3 x i8>, <3 x i8> addrspace(1)* %outbuf, i64 %call
73 store <3 x i8> %call1, <3 x i8> addrspace(1)* %arrayidx3, align 4
74 ret void
75 }
76
77 ; CHECK-LABEL: .kernel "Test4_ClampConvertFP16ToE4M3"
78 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT:[A-z0-9]*]](0,0)<1> [[IN:[A-z0-9]*]](0,0)<1;1,0>
79 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](0,32)<1> [[IN]](1,0)<1;1,0>
80 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](1,0)<1> [[IN]](2,0)<1;1,0>
81 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](1,32)<1> [[IN]](3,0)<1;1,0>
82 ; CHECK-DAG: .decl [[IN]] v_type=G type=hf num_elts=128
83 ; CHECK-DAG: .decl [[OUT]] v_type=G type=b num_elts=128
84 declare spir_func <4 x i8> @_Z43__builtin_spirv_ClampConvertFP16ToE4M3INTELDv4_Dh(<4 x half>)
85 define spir_kernel void @Test4_ClampConvertFP16ToE4M3(<4 x half> addrspace(1)* %inbuf, <4 x i8> addrspace(1)* %outbuf) {
86 entry:
87 %call = call spir_func i64 @_Z33__spirv_BuiltInGlobalInvocationIdi(i32 0)
88 %arrayidx = getelementptr inbounds <4 x half>, <4 x half> addrspace(1)* %inbuf, i64 %call
89 %loaded = load <4 x half>, <4 x half> addrspace(1)* %arrayidx, align 8
90 %call1 = call spir_func <4 x i8> @_Z43__builtin_spirv_ClampConvertFP16ToE4M3INTELDv4_Dh(<4 x half> %loaded)
91 %arrayidx3 = getelementptr inbounds <4 x i8>, <4 x i8> addrspace(1)* %outbuf, i64 %call
92 store <4 x i8> %call1, <4 x i8> addrspace(1)* %arrayidx3, align 4
93 ret void
94 }
95
96 ; CHECK-LABEL: .kernel "Test8_ClampConvertFP16ToE4M3"
97 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT:[A-z0-9]*]](0,0)<1> [[IN:[A-z0-9]*]](0,0)<1;1,0>
98 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](0,32)<1> [[IN]](1,0)<1;1,0>
99 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](1,0)<1> [[IN]](2,0)<1;1,0>
100 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](1,32)<1> [[IN]](3,0)<1;1,0>
101 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](2,0)<1> [[IN]](4,0)<1;1,0>
102 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](2,32)<1> [[IN]](5,0)<1;1,0>
103 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](3,0)<1> [[IN]](6,0)<1;1,0>
104 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](3,32)<1> [[IN]](7,0)<1;1,0>
105 ; CHECK-DAG: .decl [[IN]] v_type=G type=hf num_elts=256
106 ; CHECK-DAG: .decl [[OUT]] v_type=G type=b num_elts=256
107 declare spir_func <8 x i8> @_Z43__builtin_spirv_ClampConvertFP16ToE4M3INTELDv8_Dh(<8 x half>)
108 define spir_kernel void @Test8_ClampConvertFP16ToE4M3(<8 x half> addrspace(1)* %inbuf, <8 x i8> addrspace(1)* %outbuf) {
109 entry:
110 %call = call spir_func i64 @_Z33__spirv_BuiltInGlobalInvocationIdi(i32 0)
111 %arrayidx = getelementptr inbounds <8 x half>, <8 x half> addrspace(1)* %inbuf, i64 %call
112 %loaded = load <8 x half>, <8 x half> addrspace(1)* %arrayidx, align 16
113 %call1 = call spir_func <8 x i8> @_Z43__builtin_spirv_ClampConvertFP16ToE4M3INTELDv8_Dh(<8 x half> %loaded)
114 %arrayidx3 = getelementptr inbounds <8 x i8>, <8 x i8> addrspace(1)* %outbuf, i64 %call
115 store <8 x i8> %call1, <8 x i8> addrspace(1)* %arrayidx3, align 8
116 ret void
117 }
118
119 ; CHECK-LABEL: .kernel "Test16_ClampConvertFP16ToE4M3"
120 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT:[A-z0-9]*]](0,0)<1> [[IN:[A-z0-9]*]](0,0)<1;1,0>
121 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](0,32)<1> [[IN]](1,0)<1;1,0>
122 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](1,0)<1> [[IN]](2,0)<1;1,0>
123 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](1,32)<1> [[IN]](3,0)<1;1,0>
124 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](2,0)<1> [[IN]](4,0)<1;1,0>
125 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](2,32)<1> [[IN]](5,0)<1;1,0>
126 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](3,0)<1> [[IN]](6,0)<1;1,0>
127 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](3,32)<1> [[IN]](7,0)<1;1,0>
128 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](4,0)<1> [[IN]](8,0)<1;1,0>
129 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](4,32)<1> [[IN]](9,0)<1;1,0>
130 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](5,0)<1> [[IN]](10,0)<1;1,0>
131 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](5,32)<1> [[IN]](11,0)<1;1,0>
132 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](6,0)<1> [[IN]](12,0)<1;1,0>
133 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](6,32)<1> [[IN]](13,0)<1;1,0>
134 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](7,0)<1> [[IN]](14,0)<1;1,0>
135 ; CHECK-DAG: fcvt.sat (M1_NM, 32) [[OUT]](7,32)<1> [[IN]](15,0)<1;1,0>
136 ; CHECK-DAG: .decl [[IN]] v_type=G type=hf num_elts=512
137 ; CHECK-DAG: .decl [[OUT]] v_type=G type=b num_elts=512
138 declare spir_func <16 x i8> @_Z43__builtin_spirv_ClampConvertFP16ToE4M3INTELDv16_Dh(<16 x half>)
139 define spir_kernel void @Test16_ClampConvertFP16ToE4M3(<16 x half> addrspace(1)* %inbuf, <16 x i8> addrspace(1)* %outbuf) {
140 entry:
141 %call = call spir_func i64 @_Z33__spirv_BuiltInGlobalInvocationIdi(i32 0)
142 %arrayidx = getelementptr inbounds <16 x half>, <16 x half> addrspace(1)* %inbuf, i64 %call
143 %loaded = load <16 x half>, <16 x half> addrspace(1)* %arrayidx, align 32
144 %call1 = call spir_func <16 x i8> @_Z43__builtin_spirv_ClampConvertFP16ToE4M3INTELDv16_Dh(<16 x half> %loaded)
145 %arrayidx3 = getelementptr inbounds <16 x i8>, <16 x i8> addrspace(1)* %outbuf, i64 %call
146 store <16 x i8> %call1, <16 x i8> addrspace(1)* %arrayidx3, align 16
147 ret void
148 }