|
| 1 | +; RUN: llvm-as < %s -o %t.bc |
| 2 | +; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_KHR_cooperative_matrix,+SPV_INTEL_joint_matrix,+SPV_INTEL_bfloat16_conversion -o %t.spv |
| 3 | +; RUN: llvm-spirv %t.spv -to-text -o %t.spt |
| 4 | +; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV |
| 5 | + |
| 6 | +; RUN: llvm-spirv -r %t.spv -o %t.rev.bc |
| 7 | +; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-OCL-IR |
| 8 | + |
| 9 | +; RUN: llvm-spirv -r %t.spv -o %t.rev.bc --spirv-target-env=SPV-IR |
| 10 | +; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-SPV-IR |
| 11 | + |
| 12 | +; RUN: not llvm-spirv %t.bc --spirv-ext=+SPV_KHR_cooperative_matrix,+SPV_INTEL_bfloat16_conversion 2>&1 \ |
| 13 | +; RUN: | FileCheck %s --check-prefix=CHECK-ERROR |
| 14 | + |
| 15 | +; CHECK-ERROR: InvalidInstruction: Can't translate llvm instruction: |
| 16 | +; CHECK-ERROR-NEXT: ConvertFToBF16INTEL |
| 17 | +; CHECK-ERROR-NEXT: Can be used with cooperative matrices only when SPV_INTEL_joint_matrix is enabled |
| 18 | + |
| 19 | +; CHECK-SPIRV-DAG: Capability CooperativeMatrixKHR |
| 20 | +; CHECK-SPIRV-DAG: Capability Bfloat16ConversionINTEL |
| 21 | +; CHECK-SPIRV-DAG: Capability JointMatrixBF16ComponentTypeINTEL |
| 22 | +; CHECK-SPIRV-DAG: Extension "SPV_INTEL_bfloat16_conversion" |
| 23 | +; CHECK-SPIRV-DAG: Extension "SPV_KHR_cooperative_matrix" |
| 24 | +; CHECK-SPIRV-DAG: Extension "SPV_INTEL_joint_matrix" |
| 25 | +; CHECK-SPIRV-DAG: TypeInt [[#ShortTy:]] 16 0 |
| 26 | +; CHECK-SPIRV-DAG: TypeFloat [[#FP32Ty:]] 32 |
| 27 | +; CHECK-SPIRV-DAG: TypeCooperativeMatrixKHR [[#FP32MatTy:]] [[#FP32Ty]] |
| 28 | +; CHECK-SPIRV-DAG: TypeCooperativeMatrixKHR [[#ShortMatTy:]] [[#ShortTy]] |
| 29 | +; CHECK-SPIRV: CompositeConstruct [[#FP32MatTy]] [[#FP32Mat:]] |
| 30 | +; CHECK-SPIRV: ConvertFToBF16INTEL [[#ShortMatTy]] [[#]] [[#FP32Mat]] |
| 31 | +; CHECK-SPIRV: CompositeConstruct [[#ShortMatTy]] [[#ShortMat:]] |
| 32 | +; CHECK-SPIRV: ConvertBF16ToFINTEL [[#FP32MatTy]] [[#]] [[#ShortMat]] |
| 33 | + |
| 34 | +; CHECK-OCL-IR: %[[#FP32Matrix:]] = call spir_func target("spirv.CooperativeMatrixKHR", float, 3, 12, 12, 3) @_Z26__spirv_CompositeConstructf(float 0.000000e+00) |
| 35 | +; CHECK-OCL-IR: call spir_func target("spirv.CooperativeMatrixKHR", i16, 3, 12, 12, 3) @_Z32intel_convert_bfloat16_as_ushortPU3AS145__spirv_CooperativeMatrixKHR__float_3_12_12_3(target("spirv.CooperativeMatrixKHR", float, 3, 12, 12, 3) %[[#FP32Matrix]]) |
| 36 | +; CHECK-OCL-IR: %[[#ShortMatrix:]] = call spir_func target("spirv.CooperativeMatrixKHR", i16, 3, 12, 12, 3) @_Z26__spirv_CompositeConstructs(i16 0) |
| 37 | +; CHECK-OCL-IR: call spir_func target("spirv.CooperativeMatrixKHR", float, 3, 12, 12, 3) @_Z31intel_convert_as_bfloat16_floatPU3AS145__spirv_CooperativeMatrixKHR__short_3_12_12_3(target("spirv.CooperativeMatrixKHR", i16, 3, 12, 12, 3) %[[#ShortMatrix]]) |
| 38 | + |
| 39 | + |
| 40 | +; CHECK-SPV-IR: %[[#FP32Matrix:]] = call spir_func target("spirv.CooperativeMatrixKHR", float, 3, 12, 12, 3) @_Z26__spirv_CompositeConstructf(float 0.000000e+00) |
| 41 | +; CHECK-SPV-IR: call spir_func target("spirv.CooperativeMatrixKHR", i16, 3, 12, 12, 3) @_Z27__spirv_ConvertFToBF16INTELPU3AS145__spirv_CooperativeMatrixKHR__float_3_12_12_3(target("spirv.CooperativeMatrixKHR", float, 3, 12, 12, 3) %[[#FP32Matrix]]) |
| 42 | +; CHECK-SPV-IR: %[[#ShortMatrix:]] = call spir_func target("spirv.CooperativeMatrixKHR", i16, 3, 12, 12, 3) @_Z26__spirv_CompositeConstructs(i16 0) |
| 43 | +; CHECK-SPV-IR: call spir_func target("spirv.CooperativeMatrixKHR", float, 3, 12, 12, 3) @_Z27__spirv_ConvertBF16ToFINTELPU3AS145__spirv_CooperativeMatrixKHR__short_3_12_12_3(target("spirv.CooperativeMatrixKHR", i16, 3, 12, 12, 3) %[[#ShortMatrix]]) |
| 44 | + |
| 45 | + |
| 46 | +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" |
| 47 | +target triple = "spir64-unknown-unknown" |
| 48 | + |
| 49 | +define void @convert_f_to_bf() { |
| 50 | +entry: |
| 51 | + %0 = tail call spir_func noundef target("spirv.CooperativeMatrixKHR", float, 3, 12, 12, 3) @_Z26__spirv_CompositeConstructFloat(float 0.000000e+00) |
| 52 | + %call = call spir_func target("spirv.CooperativeMatrixKHR", i16, 3, 12, 12, 3) @_Z27__spirv_ConvertFToBF16INTEL(target("spirv.CooperativeMatrixKHR", float, 3, 12, 12, 3) %0) |
| 53 | + ret void |
| 54 | +} |
| 55 | + |
| 56 | +define void @convert_bf_to_f() { |
| 57 | +entry: |
| 58 | + %0 = tail call spir_func noundef target("spirv.CooperativeMatrixKHR", i16, 3, 12, 12, 3) @_Z26__spirv_CompositeConstructInt16(i16 0) |
| 59 | + %call = call spir_func target("spirv.CooperativeMatrixKHR", float, 3, 12, 12, 3) @_Z27__spirv_ConvertBF16ToFINTEL(target("spirv.CooperativeMatrixKHR", i16, 3, 12, 12, 3) %0) |
| 60 | + ret void |
| 61 | +} |
| 62 | + |
| 63 | +declare spir_func noundef target("spirv.CooperativeMatrixKHR", float, 3, 12, 12, 3) @_Z26__spirv_CompositeConstructFloat(float noundef) |
| 64 | + |
| 65 | +declare spir_func noundef target("spirv.CooperativeMatrixKHR", i16, 3, 12, 12, 3) @_Z26__spirv_CompositeConstructInt16(i16 noundef) |
| 66 | + |
| 67 | +declare spir_func noundef target("spirv.CooperativeMatrixKHR", i16, 3, 12, 12, 3) @_Z27__spirv_ConvertFToBF16INTEL(target("spirv.CooperativeMatrixKHR", float, 3, 12, 12, 3) noundef) |
| 68 | + |
| 69 | +declare spir_func noundef target("spirv.CooperativeMatrixKHR", float, 3, 12, 12, 3) @_Z27__spirv_ConvertBF16ToFINTEL(target("spirv.CooperativeMatrixKHR", i16, 3, 12, 12, 3) noundef) |
| 70 | + |
| 71 | +!llvm.module.flags = !{!0, !1, !2, !3, !4} |
| 72 | +!llvm.ident = !{!5} |
| 73 | + |
| 74 | +!0 = !{i32 7, !"Dwarf Version", i32 4} |
| 75 | +!1 = !{i32 1, !"wchar_size", i32 4} |
| 76 | +!2 = !{i32 8, !"PIC Level", i32 2} |
| 77 | +!3 = !{i32 7, !"PIE Level", i32 2} |
| 78 | +!4 = !{i32 7, !"uwtable", i32 2} |
| 79 | +!5 = !{!"clang version 17.0.0"} |
0 commit comments