| 1 |
;=========================== begin_copyright_notice ============================ |
| 2 |
; |
| 3 |
; Copyright (C) 2025 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 -o %t.spv --spirv-ext=+SPV_INTEL_float4,+SPV_INTEL_int4 |
| 12 |
; RUN: ocloc compile -spirv_input -file %t.spv -device cri -options "-igc_opts 'ForceOCLSIMDWidth=32,DumpVISAASMToConsole=1,AddVISADumpDeclarationsToEnd=1'" | FileCheck %s |
| 13 |
|
| 14 |
; Test if conversion opcodes are present in spirv disassembly |
| 15 |
; RUN: llvm-spirv --to-text %t.spv -o %t.spt |
| 16 |
; RUN: cat %t.spt | FileCheck %s -check-prefix=CHECK-SPV |
| 17 |
; CHECK-SPV: FConvert |
| 18 |
|
| 19 |
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" |
| 20 |
target triple = "spir64-unknown-unknown" |
| 21 |
|
| 22 |
declare spir_func i64 @_Z33__spirv_BuiltInGlobalInvocationIdi(i32) |
| 23 |
|
| 24 |
define spir_kernel void @FP16_to_E2M1_scalar(half addrspace(1)* %input, <2 x i4> addrspace(1)* %output) { |
| 25 |
; CHECK-LABEL: .kernel "FP16_to_E2M1_scalar" |
| 26 |
; CHECK-DAG: dnscl.hftoe2m1.mode0.rne (M1, 32) [[DST:[A-z0-9]*]].0 [[INPUT0:[A-z0-9]*]].0 [[INPUT1:[A-z0-9]*]].0 %null.0 |
| 27 |
; CHECK-DAG: mov (M1, 32) [[INPUT1]](0,0)<1> 0x0:ud |
| 28 |
; CHECK-DAG: // .decl [[INPUT0]] v_type=G type=ud num_elts=32 |
| 29 |
; CHECK-DAG: // .decl [[INPUT1]] v_type=G type=ud num_elts=32 |
| 30 |
; CHECK-DAG: // .decl [[DST]] v_type=G type=ud num_elts=32 |
| 31 |
%gid = call spir_func i64 @_Z33__spirv_BuiltInGlobalInvocationIdi(i32 0) |
| 32 |
%inputAddr = getelementptr half, half addrspace(1)* %input, i64 %gid |
| 33 |
%outputAddr = getelementptr <2 x i4>, <2 x i4> addrspace(1)* %output, i64 %gid |
| 34 |
|
| 35 |
%inputVal = load half, half addrspace(1)* %inputAddr, align 2 |
| 36 |
%conv = call i4 @_Z38__builtin_spirv_ConvertFP16ToE2M1INTELDh(half %inputVal) |
| 37 |
%v1 = insertelement <2 x i4> undef, i4 %conv, i32 0 |
| 38 |
%v2 = insertelement <2 x i4> %v1, i4 0, i32 1 |
| 39 |
|
| 40 |
store <2 x i4> %v2, <2 x i4> addrspace(1)* %outputAddr, align 1 |
| 41 |
ret void |
| 42 |
} |
| 43 |
declare dso_local spir_func i4 @_Z38__builtin_spirv_ConvertFP16ToE2M1INTELDh(half) |
| 44 |
|
| 45 |
define spir_kernel void @FP16_to_E2M1_vector2(<2 x half> addrspace(1)* %input, <2 x i4> addrspace(1)* %output) { |
| 46 |
; CHECK-LABEL: .kernel "FP16_to_E2M1_vector2" |
| 47 |
; CHECK-DAG: dnscl.hftoe2m1.mode0.rne (M1, 32) [[DST:[A-z0-9]*]].0 [[INPUT0:[A-z0-9]*]].0 [[INPUT1:[A-z0-9]*]].0 %null.0 |
| 48 |
; CHECK-DAG: mov (M1, 32) [[INPUT1]](0,0)<1> 0x0:ud |
| 49 |
; CHECK-DAG: // .decl [[INPUT0]] v_type=G type=ud num_elts=32 |
| 50 |
; CHECK-DAG: // .decl [[INPUT1]] v_type=G type=ud num_elts=32 |
| 51 |
; CHECK-DAG: // .decl [[DST]] v_type=G type=ud num_elts=32 |
| 52 |
%gid = call spir_func i64 @_Z33__spirv_BuiltInGlobalInvocationIdi(i32 0) |
| 53 |
%inputAddr = getelementptr <2 x half>, <2 x half> addrspace(1)* %input, i64 %gid |
| 54 |
%outputAddr = getelementptr <2 x i4>, <2 x i4> addrspace(1)* %output, i64 %gid |
| 55 |
|
| 56 |
%inputVal = load <2 x half>, <2 x half> addrspace(1)* %inputAddr, align 4 |
| 57 |
%conv = call <2 x i4> @_Z38__builtin_spirv_ConvertFP16ToE2M1INTELDv2_Dh(<2 x half> %inputVal) |
| 58 |
|
| 59 |
store <2 x i4> %conv, <2 x i4> addrspace(1)* %outputAddr, align 1 |
| 60 |
ret void |
| 61 |
} |
| 62 |
declare dso_local spir_func <2 x i4> @_Z38__builtin_spirv_ConvertFP16ToE2M1INTELDv2_Dh(<2 x half>) |
| 63 |
|
| 64 |
define spir_kernel void @FP16_to_E2M1_vector3(<3 x half> addrspace(1)* %input, <4 x i4> addrspace(1)* %output) { |
| 65 |
; CHECK-LABEL: .kernel "FP16_to_E2M1_vector3" |
| 66 |
; CHECK: dnscl.hftoe2m1.mode0.rne (M1, 32) [[DST:[A-z0-9]*]].0 [[INPUT0:[A-z0-9]*]].0 [[INPUT1:[A-z0-9]*]].0 %null.0 |
| 67 |
; CHECK-NOT: dnscl.hftoe2m1 |
| 68 |
; CHECK-DAG: // .decl [[INPUT0]] v_type=G type=ud num_elts=32 |
| 69 |
; CHECK-DAG: // .decl [[INPUT1]] v_type=G type=ud num_elts=32 |
| 70 |
; CHECK-DAG: // .decl [[DST]] v_type=G type=ud num_elts=32 |
| 71 |
%gid = call spir_func i64 @_Z33__spirv_BuiltInGlobalInvocationIdi(i32 0) |
| 72 |
%inputAddr = getelementptr <3 x half>, <3 x half> addrspace(1)* %input, i64 %gid |
| 73 |
%outputAddr = getelementptr <4 x i4>, <4 x i4> addrspace(1)* %output, i64 %gid |
| 74 |
|
| 75 |
%inputVal = load <3 x half>, <3 x half> addrspace(1)* %inputAddr, align 8 |
| 76 |
%conv = call <3 x i4> @_Z38__builtin_spirv_ConvertFP16ToE2M1INTELDv3_Dh(<3 x half> %inputVal) |
| 77 |
%conv4 = shufflevector <3 x i4> %conv, <3 x i4> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 undef> |
| 78 |
|
| 79 |
store <4 x i4> %conv4, <4 x i4> addrspace(1)* %outputAddr, align 2 |
| 80 |
ret void |
| 81 |
} |
| 82 |
declare dso_local spir_func <3 x i4> @_Z38__builtin_spirv_ConvertFP16ToE2M1INTELDv3_Dh(<3 x half>) |
| 83 |
|
| 84 |
define spir_kernel void @FP16_to_E2M1_vector4(<4 x half> addrspace(1)* %input, <4 x i4> addrspace(1)* %output) { |
| 85 |
; CHECK-LABEL: .kernel "FP16_to_E2M1_vector4" |
| 86 |
; CHECK: dnscl.hftoe2m1.mode0.rne (M1, 32) [[DST:[A-z0-9]*]].0 [[INPUT:[A-z0-9]*]].0 [[INPUT]].128 %null.0 |
| 87 |
; CHECK-NOT: dnscl.hftoe2m1 |
| 88 |
; CHECK-DAG: // .decl [[INPUT]] v_type=G type=ud num_elts=64 |
| 89 |
; CHECK-DAG: // .decl [[DST]] v_type=G type=ud num_elts=32 |
| 90 |
%gid = call spir_func i64 @_Z33__spirv_BuiltInGlobalInvocationIdi(i32 0) |
| 91 |
%inputAddr = getelementptr <4 x half>, <4 x half> addrspace(1)* %input, i64 %gid |
| 92 |
%outputAddr = getelementptr <4 x i4>, <4 x i4> addrspace(1)* %output, i64 %gid |
| 93 |
|
| 94 |
%inputVal = load <4 x half>, <4 x half> addrspace(1)* %inputAddr, align 8 |
| 95 |
%conv = call <4 x i4> @_Z38__builtin_spirv_ConvertFP16ToE2M1INTELDv4_Dh(<4 x half> %inputVal) |
| 96 |
|
| 97 |
store <4 x i4> %conv, <4 x i4> addrspace(1)* %outputAddr, align 2 |
| 98 |
ret void |
| 99 |
} |
| 100 |
declare dso_local spir_func <4 x i4> @_Z38__builtin_spirv_ConvertFP16ToE2M1INTELDv4_Dh(<4 x half>) |
| 101 |
|
| 102 |
define spir_kernel void @FP16_to_E2M1_vector8(<8 x half> addrspace(1)* %input, <8 x i4> addrspace(1)* %output) { |
| 103 |
; CHECK-LABEL: .kernel "FP16_to_E2M1_vector8" |
| 104 |
; CHECK: dnscl.hftoe2m1.mode0.rne (M1, 32) [[DST0:[A-z0-9]*]].0 [[INPUT:[A-z0-9]*]].0 [[INPUT]].256 %null.0 |
| 105 |
; CHECK: dnscl.hftoe2m1.mode2.rne (M1, 32) [[DST1:[A-z0-9]*]].0 [[INPUT]].128 [[INPUT]].384 %null.0 |
| 106 |
; CHECK-NOT: dnscl.hftoe2m1 |
| 107 |
; CHECK-DAG: // .decl [[INPUT]] v_type=G type=ud num_elts=128 |
| 108 |
; CHECK-DAG: // .decl [[DST0]] v_type=G type=ud num_elts=32 |
| 109 |
; CHECK-DAG: // .decl [[DST1]] v_type=G type=ud num_elts=32 |
| 110 |
%gid = call spir_func i64 @_Z33__spirv_BuiltInGlobalInvocationIdi(i32 0) |
| 111 |
%inputAddr = getelementptr <8 x half>, <8 x half> addrspace(1)* %input, i64 %gid |
| 112 |
%outputAddr = getelementptr <8 x i4>, <8 x i4> addrspace(1)* %output, i64 %gid |
| 113 |
|
| 114 |
%inputVal = load <8 x half>, <8 x half> addrspace(1)* %inputAddr, align 16 |
| 115 |
%conv = call <8 x i4> @_Z38__builtin_spirv_ConvertFP16ToE2M1INTELDv8_Dh(<8 x half> %inputVal) |
| 116 |
|
| 117 |
store <8 x i4> %conv, <8 x i4> addrspace(1)* %outputAddr, align 4 |
| 118 |
ret void |
| 119 |
} |
| 120 |
declare dso_local spir_func <8 x i4> @_Z38__builtin_spirv_ConvertFP16ToE2M1INTELDv8_Dh(<8 x half>) |
| 121 |
|
| 122 |
define spir_kernel void @FP16_to_E2M1_vector16(<16 x half> addrspace(1)* %input, <16 x i4> addrspace(1)* %output) { |
| 123 |
; CHECK-LABEL: .kernel "FP16_to_E2M1_vector16" |
| 124 |
; CHECK: dnscl.hftoe2m1.mode0.rne (M1, 32) [[DST0:[A-z0-9]*]].0 [[INPUT:[A-z0-9]*]].0 [[INPUT]].256 %null.0 |
| 125 |
; CHECK: dnscl.hftoe2m1.mode2.rne (M1, 32) [[DST1:[A-z0-9]*]].0 [[INPUT]].128 [[INPUT]].384 %null.0 |
| 126 |
; CHECK: dnscl.hftoe2m1.mode0.rne (M1, 32) [[DST2:[A-z0-9]*]].0 [[INPUT]].512 [[INPUT]].768 %null.0 |
| 127 |
; CHECK: dnscl.hftoe2m1.mode2.rne (M1, 32) [[DST3:[A-z0-9]*]].0 [[INPUT]].640 [[INPUT]].896 %null.0 |
| 128 |
; CHECK-NOT: dnscl.hftoe2m1 |
| 129 |
; CHECK-DAG: // .decl [[INPUT]] v_type=G type=ud num_elts=256 |
| 130 |
; CHECK-DAG: // .decl [[DST0]] v_type=G type=ud num_elts=32 |
| 131 |
; CHECK-DAG: // .decl [[DST1]] v_type=G type=ud num_elts=32 |
| 132 |
; CHECK-DAG: // .decl [[DST2]] v_type=G type=ud num_elts=32 |
| 133 |
; CHECK-DAG: // .decl [[DST3]] v_type=G type=ud num_elts=32 |
| 134 |
%gid = call spir_func i64 @_Z33__spirv_BuiltInGlobalInvocationIdi(i32 0) |
| 135 |
%inputAddr = getelementptr <16 x half>, <16 x half> addrspace(1)* %input, i64 %gid |
| 136 |
%outputAddr = getelementptr <16 x i4>, <16 x i4> addrspace(1)* %output, i64 %gid |
| 137 |
|
| 138 |
%inputVal = load <16 x half>, <16 x half> addrspace(1)* %inputAddr, align 32 |
| 139 |
%conv = call <16 x i4> @_Z38__builtin_spirv_ConvertFP16ToE2M1INTELDv16_Dh(<16 x half> %inputVal) |
| 140 |
|
| 141 |
store <16 x i4> %conv, <16 x i4> addrspace(1)* %outputAddr, align 8 |
| 142 |
ret void |
| 143 |
} |
| 144 |
declare dso_local spir_func <16 x i4> @_Z38__builtin_spirv_ConvertFP16ToE2M1INTELDv16_Dh(<16 x half>) |