From ca96e7d704afde3e67659dfa2ec0e6f517ce6233 Mon Sep 17 00:00:00 2001 From: "Maksimova, Viktoria" Date: Wed, 13 Nov 2024 05:24:25 -0800 Subject: [PATCH 1/5] Add test checks to test with SPV_KHR_untyped_pointers --- .../array_of_matrices.ll | 7 ++ .../bf16_conversion_instructions.ll | 13 ++++ .../cooperative_matrix_apply.ll | 7 ++ .../cooperative_matrix_checked.ll | 7 ++ .../cooperative_matrix_prefetch.ll | 7 ++ .../SPV_INTEL_joint_matrix/joint_matrix.ll | 7 ++ .../joint_matrix_bfloat16.ll | 7 ++ .../joint_matrix_checked.ll | 7 ++ .../joint_matrix_half.ll | 7 ++ .../access_store.ll | 22 +++++-- .../access_store_untyped.ll | 66 +++++++++++++++++++ .../arithmetic_instructions.ll | 9 +++ .../array_of_matrices.ll | 7 ++ .../conversion_instructions.ll | 9 +++ .../cooperative_matrix.ll | 7 ++ 15 files changed, 184 insertions(+), 5 deletions(-) create mode 100644 test/extensions/KHR/SPV_KHR_cooperative_matrix/access_store_untyped.ll diff --git a/test/extensions/INTEL/SPV_INTEL_joint_matrix/array_of_matrices.ll b/test/extensions/INTEL/SPV_INTEL_joint_matrix/array_of_matrices.ll index 0571af5dd9..cb6a0e586c 100644 --- a/test/extensions/INTEL/SPV_INTEL_joint_matrix/array_of_matrices.ll +++ b/test/extensions/INTEL/SPV_INTEL_joint_matrix/array_of_matrices.ll @@ -9,6 +9,13 @@ ; RUN: llvm-spirv -r %t.spv -o %t.rev.bc ; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM +; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_joint_matrix,+SPV_KHR_untyped_pointers -o %t.spv +; RUN: llvm-spirv %t.spv -to-text -o %t.spt +; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV + +; RUN: llvm-spirv -r %t.spv -o %t.rev.bc +; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM + ; CHECK-SPIRV-DAG: Capability JointMatrixINTEL ; CHECK-SPIRV-DAG: Extension "SPV_INTEL_joint_matrix" ; CHECK-SPIRV: TypeInt [[#Int16Ty:]] 16 0 diff --git a/test/extensions/INTEL/SPV_INTEL_joint_matrix/bf16_conversion_instructions.ll b/test/extensions/INTEL/SPV_INTEL_joint_matrix/bf16_conversion_instructions.ll index 237c05688b..ae853abae8 100644 --- a/test/extensions/INTEL/SPV_INTEL_joint_matrix/bf16_conversion_instructions.ll +++ b/test/extensions/INTEL/SPV_INTEL_joint_matrix/bf16_conversion_instructions.ll @@ -12,6 +12,19 @@ ; RUN: not llvm-spirv %t.bc --spirv-ext=+SPV_KHR_cooperative_matrix,+SPV_INTEL_bfloat16_conversion 2>&1 \ ; RUN: | FileCheck %s --check-prefix=CHECK-ERROR +; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_KHR_cooperative_matrix,+SPV_INTEL_joint_matrix,+SPV_INTEL_bfloat16_conversion,+SPV_KHR_untyped_pointers -o %t.spv +; RUN: llvm-spirv %t.spv -to-text -o %t.spt +; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV + +; RUN: llvm-spirv -r %t.spv -o %t.rev.bc +; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-OCL-IR + +; RUN: llvm-spirv -r %t.spv -o %t.rev.bc --spirv-target-env=SPV-IR +; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-SPV-IR + +; RUN: not llvm-spirv %t.bc --spirv-ext=+SPV_KHR_cooperative_matrix,+SPV_INTEL_bfloat16_conversion,+SPV_KHR_untyped_pointers 2>&1 \ +; RUN: | FileCheck %s --check-prefix=CHECK-ERROR + ; CHECK-ERROR: InvalidInstruction: Can't translate llvm instruction: ; CHECK-ERROR-NEXT: ConvertFToBF16INTEL ; CHECK-ERROR-NEXT: Can be used with cooperative matrices only when SPV_INTEL_joint_matrix is enabled diff --git a/test/extensions/INTEL/SPV_INTEL_joint_matrix/cooperative_matrix_apply.ll b/test/extensions/INTEL/SPV_INTEL_joint_matrix/cooperative_matrix_apply.ll index b0f97b74d7..59451d0c72 100644 --- a/test/extensions/INTEL/SPV_INTEL_joint_matrix/cooperative_matrix_apply.ll +++ b/test/extensions/INTEL/SPV_INTEL_joint_matrix/cooperative_matrix_apply.ll @@ -8,6 +8,13 @@ ; RUN: llvm-spirv -r %t.spv -o %t.rev.bc ; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM +; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_KHR_cooperative_matrix,+SPV_INTEL_joint_matrix,+SPV_KHR_untyped_pointers -o %t.spv +; RUN: llvm-spirv %t.spv -to-text -o %t.spt +; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV + +; RUN: llvm-spirv -r %t.spv -o %t.rev.bc +; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM + ; CHECK-SPIRV-DAG: Capability CooperativeMatrixKHR ; CHECK-SPIRV-DAG: Capability CooperativeMatrixInvocationInstructionsINTEL ; CHECK-SPIRV-DAG: Extension "SPV_INTEL_joint_matrix" diff --git a/test/extensions/INTEL/SPV_INTEL_joint_matrix/cooperative_matrix_checked.ll b/test/extensions/INTEL/SPV_INTEL_joint_matrix/cooperative_matrix_checked.ll index f6e4ba727c..1c43d2f30f 100644 --- a/test/extensions/INTEL/SPV_INTEL_joint_matrix/cooperative_matrix_checked.ll +++ b/test/extensions/INTEL/SPV_INTEL_joint_matrix/cooperative_matrix_checked.ll @@ -8,6 +8,13 @@ ; RUN: llvm-spirv -r %t.spv -o %t.rev.bc ; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM +; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_KHR_cooperative_matrix,+SPV_INTEL_joint_matrix,+SPV_KHR_untyped_pointers -o %t.spv +; RUN: llvm-spirv %t.spv -to-text -o %t.spt +; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV + +; RUN: llvm-spirv -r %t.spv -o %t.rev.bc +; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM + ; CHECK-SPIRV-DAG: Capability CooperativeMatrixKHR ; CHECK-SPIRV-DAG: Capability CooperativeMatrixCheckedInstructionsINTEL ; CHECK-SPIRV-DAG: Extension "SPV_KHR_cooperative_matrix" diff --git a/test/extensions/INTEL/SPV_INTEL_joint_matrix/cooperative_matrix_prefetch.ll b/test/extensions/INTEL/SPV_INTEL_joint_matrix/cooperative_matrix_prefetch.ll index 17f8c3f592..53f6a51a71 100644 --- a/test/extensions/INTEL/SPV_INTEL_joint_matrix/cooperative_matrix_prefetch.ll +++ b/test/extensions/INTEL/SPV_INTEL_joint_matrix/cooperative_matrix_prefetch.ll @@ -8,6 +8,13 @@ ; RUN: llvm-spirv -r %t.spv -o %t.rev.bc ; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM +; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_KHR_cooperative_matrix,+SPV_INTEL_joint_matrix,+SPV_KHR_untyped_pointers -o %t.spv +; RUN: llvm-spirv %t.spv -to-text -o %t.spt +; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV + +; RUN: llvm-spirv -r %t.spv -o %t.rev.bc +; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM + ; CHECK-SPIRV-DAG: Capability CooperativeMatrixKHR ; CHECK-SPIRV-DAG: Capability CooperativeMatrixPrefetchINTEL ; CHECK-SPIRV-DAG: Extension "SPV_KHR_cooperative_matrix" diff --git a/test/extensions/INTEL/SPV_INTEL_joint_matrix/joint_matrix.ll b/test/extensions/INTEL/SPV_INTEL_joint_matrix/joint_matrix.ll index 7c8ec53ebc..066ea5aeb9 100644 --- a/test/extensions/INTEL/SPV_INTEL_joint_matrix/joint_matrix.ll +++ b/test/extensions/INTEL/SPV_INTEL_joint_matrix/joint_matrix.ll @@ -6,6 +6,13 @@ ; RUN: llvm-spirv -r %t.spv -o %t.rev.bc ; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM +; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_joint_matrix,+SPV_KHR_untyped_pointers -o %t.spv +; RUN: llvm-spirv %t.spv -to-text -o %t.spt +; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV + +; RUN: llvm-spirv -r %t.spv -o %t.rev.bc +; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM + ; CHECK-SPIRV-DAG: Capability JointMatrixINTEL ; CHECK-SPIRV-DAG: Extension "SPV_INTEL_joint_matrix" ; CHECK-SPIRV-DAG: TypeInt [[#Int8Ty:]] 8 0 diff --git a/test/extensions/INTEL/SPV_INTEL_joint_matrix/joint_matrix_bfloat16.ll b/test/extensions/INTEL/SPV_INTEL_joint_matrix/joint_matrix_bfloat16.ll index 80c014b689..b7f2404f2e 100644 --- a/test/extensions/INTEL/SPV_INTEL_joint_matrix/joint_matrix_bfloat16.ll +++ b/test/extensions/INTEL/SPV_INTEL_joint_matrix/joint_matrix_bfloat16.ll @@ -9,6 +9,13 @@ ; RUN: llvm-spirv -r %t.spv -o %t.rev.bc ; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM +; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_bfloat16_conversion,+SPV_INTEL_joint_matrix,+SPV_KHR_untyped_pointers -o %t.spv +; RUN: llvm-spirv %t.spv -to-text -o %t.spt +; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV + +; RUN: llvm-spirv -r %t.spv -o %t.rev.bc +; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM + ; CHECK-SPIRV-DAG: TypeInt [[#SHORT:]] 16 ; CHECK-SPIRV-DAG: TypeInt [[#INT:]] 32 ; CHECK-SPIRV-DAG: TypeFloat [[#Float:]] 32 diff --git a/test/extensions/INTEL/SPV_INTEL_joint_matrix/joint_matrix_checked.ll b/test/extensions/INTEL/SPV_INTEL_joint_matrix/joint_matrix_checked.ll index d948844ef4..509b6815f5 100644 --- a/test/extensions/INTEL/SPV_INTEL_joint_matrix/joint_matrix_checked.ll +++ b/test/extensions/INTEL/SPV_INTEL_joint_matrix/joint_matrix_checked.ll @@ -8,6 +8,13 @@ ; RUN: llvm-spirv -r %t.spv -o %t.rev.bc ; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM +; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_joint_matrix,+SPV_KHR_untyped_pointers,+SPV_KHR_untyped_pointers -o %t.spv +; RUN: llvm-spirv %t.spv -to-text -o %t.spt +; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV + +; RUN: llvm-spirv -r %t.spv -o %t.rev.bc +; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM + ; CHECK-SPIRV-DAG: Capability JointMatrixINTEL ; CHECK-SPIRV-DAG: Capability CooperativeMatrixKHR ; CHECK-SPIRV-DAG: Capability CooperativeMatrixCheckedInstructionsINTEL diff --git a/test/extensions/INTEL/SPV_INTEL_joint_matrix/joint_matrix_half.ll b/test/extensions/INTEL/SPV_INTEL_joint_matrix/joint_matrix_half.ll index 6b5c380de5..8eccca433b 100644 --- a/test/extensions/INTEL/SPV_INTEL_joint_matrix/joint_matrix_half.ll +++ b/test/extensions/INTEL/SPV_INTEL_joint_matrix/joint_matrix_half.ll @@ -9,6 +9,13 @@ ; RUN: llvm-spirv -r %t.spv -o %t.rev.bc ; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM +; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_bfloat16_conversion,+SPV_INTEL_joint_matrix,+SPV_KHR_untyped_pointers -o %t.spv +; RUN: llvm-spirv %t.spv -to-text -o %t.spt +; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV + +; RUN: llvm-spirv -r %t.spv -o %t.rev.bc +; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM + ; CHECK-SPIRV-DAG: TypeInt [[#INT:]] 32 ; CHECK-SPIRV-DAG: TypeFloat [[#Half:]] 16 ; CHECK-SPIRV-DAG: TypeFloat [[#Float:]] 32 diff --git a/test/extensions/KHR/SPV_KHR_cooperative_matrix/access_store.ll b/test/extensions/KHR/SPV_KHR_cooperative_matrix/access_store.ll index 62f3f8407c..da7d76e7ca 100644 --- a/test/extensions/KHR/SPV_KHR_cooperative_matrix/access_store.ll +++ b/test/extensions/KHR/SPV_KHR_cooperative_matrix/access_store.ll @@ -1,10 +1,19 @@ ; RUN: llvm-as < %s -o %t.bc ; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_KHR_cooperative_matrix -o %t.spv +; RUN: spirv-val %t.spv ; RUN: llvm-spirv %t.spv -to-text -o %t.spt -; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV +; RUN: FileCheck < %t.spt %s --check-prefixes=CHECK-SPIRV,CHECK-SPIRV-TYPED-PTR ; RUN: llvm-spirv -r %t.spv -o %t.rev.bc -; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM +; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefixes=CHECK-LLVM,CHECK-LLVM-TYPED-PTR + +; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_KHR_cooperative_matrix,+SPV_KHR_untyped_pointers -o %t.spv +; RUN: spirv-val %t.spv +; RUN: llvm-spirv %t.spv -to-text -o %t.spt +; RUN: FileCheck < %t.spt %s --check-prefixes=CHECK-SPIRV,CHECK-SPIRV-UNTYPED-PTR + +; RUN: llvm-spirv -r %t.spv -o %t.rev.bc +; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefixes=CHECK-LLVM,CHECK-LLVM-UNTYPED-PTR ; CHECK-SPIRV: TypeInt [[#TypeInt:]] 32 0 ; CHECK-SPIRV-DAG: Constant [[#TypeInt]] [[#Const0:]] 0 @@ -15,18 +24,21 @@ ; CHECK-SPIRV: TypeCooperativeMatrixKHR [[#TypeMatrix:]] [[#TypeInt]] [[#Const3]] [[#Const12]] [[#Const12]] [[#Const0]] ; CHECK-SPIRV: TypePointer [[#TypeMatrixPtr:]] 7 [[#TypeMatrix]] -; CHECK-SPIRV: TypePointer [[#TypeIntPtr:]] 7 [[#TypeInt]] +; CHECK-SPIRV-TYPED-PTR: TypePointer [[#TypeIntPtr:]] 7 [[#TypeInt]] +; CHECK-SPIRV-UNTYPED-PTR: TypeUntypedPointerKHR [[#TypePtr:]] 7 ; CHECK-SPIRV: Variable [[#TypeMatrixPtr]] [[#VarMatrixPtr:]] 7 ; CHECK-SPIRV: CompositeConstruct [[#TypeMatrix]] [[#Composite:]] [[#Const0]] ; CHECK-SPIRV: Store [[#VarMatrixPtr]] [[#Composite]] -; CHECK-SPIRV: AccessChain [[#TypeIntPtr]] [[#Res:]] [[#VarMatrixPtr]] [[#Const1]] +; CHECK-SPIRV-TYPED-PTR: AccessChain [[#TypeIntPtr]] [[#Res:]] [[#VarMatrixPtr]] [[#Const1]] +; CHECK-SPIRV-UNTYPED-PTR: UntypedAccessChainKHR [[#TypePtr]] [[#Res:]] [[#TypeMatrix]] [[#VarMatrixPtr]] [[#Const1]] ; CHECK-SPIRV: Store [[#Res]] [[#Const42]] ; CHECK-LLVM: %0 = alloca target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 0) ; CHECK-LLVM: %Obj = call spir_func target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 0) @_Z26__spirv_CompositeConstructi(i32 0) ; CHECK-LLVM: store target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 0) %Obj, ptr %0 -; CHECK-LLVM: %call = call spir_func ptr @_Z19__spirv_AccessChainPPU3AS144__spirv_CooperativeMatrixKHR__uint_3_12_12_0i(ptr %0, i32 1) +; CHECK-LLVM-TYPED-PTR: %call = call spir_func ptr @_Z19__spirv_AccessChainPPU3AS144__spirv_CooperativeMatrixKHR__uint_3_12_12_0i(ptr %0, i32 1) +; CHECK-LLVM-UNTYPED-PTR: %call = call spir_func ptr @_Z29__spirv_UntypedAccessChainKHRPPU3AS144__spirv_CooperativeMatrixKHR__uint_3_12_12_0i(ptr %0, i32 1) ; CHECK-LLVM: store i32 42, ptr %call target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" diff --git a/test/extensions/KHR/SPV_KHR_cooperative_matrix/access_store_untyped.ll b/test/extensions/KHR/SPV_KHR_cooperative_matrix/access_store_untyped.ll new file mode 100644 index 0000000000..f070ad80be --- /dev/null +++ b/test/extensions/KHR/SPV_KHR_cooperative_matrix/access_store_untyped.ll @@ -0,0 +1,66 @@ +; RUN: llvm-as < %s -o %t.bc +; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_KHR_cooperative_matrix,+SPV_KHR_untyped_pointers -o %t.spv +; RUN: spirv-val %t.spv +; RUN: llvm-spirv %t.spv -to-text -o %t.spt +; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV + +; RUN: llvm-spirv -r %t.spv -o %t.rev.bc +; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM + +; CHECK-SPIRV: TypeInt [[#TypeInt:]] 32 0 +; CHECK-SPIRV-DAG: Constant [[#TypeInt]] [[#Const0:]] 0 +; CHECK-SPIRV-DAG: Constant [[#TypeInt]] [[#Const1:]] 1 {{$}} +; CHECK-SPIRV-DAG: Constant [[#TypeInt]] [[#Const3:]] 3 +; CHECK-SPIRV-DAG: Constant [[#TypeInt]] [[#Const12:]] 12 +; CHECK-SPIRV-DAG: Constant [[#TypeInt]] [[#Const42:]] 42 + +; CHECK-SPIRV: TypeCooperativeMatrixKHR [[#TypeMatrix:]] [[#TypeInt]] [[#Const3]] [[#Const12]] [[#Const12]] [[#Const0]] +; CHECK-SPIRV: TypePointer [[#TypeMatrixPtr:]] 7 [[#TypeMatrix]] +; CHECK-SPIRV: TypeUntypedPointerKHR [[#TypePtr:]] 7 + +; CHECK-SPIRV: Variable [[#TypeMatrixPtr]] [[#VarMatrixPtr:]] 7 +; CHECK-SPIRV: CompositeConstruct [[#TypeMatrix]] [[#Composite:]] [[#Const0]] +; CHECK-SPIRV: Store [[#VarMatrixPtr]] [[#Composite]] +; CHECK-SPIRV: UntypedAccessChainKHR [[#TypePtr]] [[#Res:]] [[#TypeMatrix]] [[#VarMatrixPtr]] [[#Const1]] +; CHECK-SPIRV: Store [[#Res]] [[#Const42]] + +; CHECK-LLVM: %0 = alloca target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 0) +; CHECK-LLVM: %Obj = call spir_func target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 0) @_Z26__spirv_CompositeConstructi(i32 0) +; CHECK-LLVM: store target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 0) %Obj, ptr %0 +; CHECK-LLVM: %call = call spir_func ptr @_Z29__spirv_UntypedAccessChainKHRPPU3AS144__spirv_CooperativeMatrixKHR__uint_3_12_12_0i(ptr %0, i32 1) +; CHECK-LLVM: store i32 42, ptr %call + +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "spir64-unknown-unknown" + +; Function Attrs: mustprogress uwtable +define dso_local void @_Z3fooi(i32 noundef %idx) local_unnamed_addr #0 { +entry: + %0 = alloca target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 0), align 8 + %Obj = tail call spir_func noundef target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 0) @_Z26__spirv_CompositeConstruct(i32 noundef 0) #4 + store target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 0) %Obj, ptr %0, align 8 + %call = call noundef ptr @_Z29__spirv_UntypedAccessChainKHRP6Matrixii(ptr %0, i32 noundef 1) + call void @_Z13__spirv_StorePii(ptr noundef %call, i32 noundef 42) + ret void +} + +declare dso_local spir_func noundef target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 0) @_Z26__spirv_CompositeConstruct(i32 noundef) local_unnamed_addr #2 + +declare noundef ptr @_Z29__spirv_UntypedAccessChainKHRP6Matrixii(ptr noundef, i32 noundef) local_unnamed_addr #2 + +declare void @_Z13__spirv_StorePii(ptr noundef, i32 noundef) local_unnamed_addr #2 + +attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) } +attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #3 = { nounwind } + +!llvm.module.flags = !{!0, !1, !2, !3, !4} +!llvm.ident = !{!5} + +!0 = !{i32 7, !"Dwarf Version", i32 4} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 8, !"PIC Level", i32 2} +!3 = !{i32 7, !"PIE Level", i32 2} +!4 = !{i32 7, !"uwtable", i32 2} +!5 = !{!"clang version 16.0.0 (https://github.com/llvm/llvm-project.git 08d094a0e457360ad8b94b017d2dc277e697ca76)"} diff --git a/test/extensions/KHR/SPV_KHR_cooperative_matrix/arithmetic_instructions.ll b/test/extensions/KHR/SPV_KHR_cooperative_matrix/arithmetic_instructions.ll index cac16270c6..38d712bcfa 100644 --- a/test/extensions/KHR/SPV_KHR_cooperative_matrix/arithmetic_instructions.ll +++ b/test/extensions/KHR/SPV_KHR_cooperative_matrix/arithmetic_instructions.ll @@ -1,8 +1,17 @@ ; RUN: llvm-as < %s -o %t.bc ; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_KHR_cooperative_matrix -o %t.spv +; RUN: spirv-val %t.spv ; RUN: llvm-spirv %t.spv -to-text -o %t.spt ; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV + +; RUN: llvm-spirv -r --spirv-target-env=SPV-IR %t.spv -o %t.rev.bc +; RUN: llvm-dis %t.rev.bc +; RUN: FileCheck < %t.rev.ll %s --check-prefix=CHECK-LLVM + +; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_KHR_cooperative_matrix,+SPV_KHR_untyped_pointers -o %t.spv ; RUN: spirv-val %t.spv +; RUN: llvm-spirv %t.spv -to-text -o %t.spt +; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV ; RUN: llvm-spirv -r --spirv-target-env=SPV-IR %t.spv -o %t.rev.bc ; RUN: llvm-dis %t.rev.bc diff --git a/test/extensions/KHR/SPV_KHR_cooperative_matrix/array_of_matrices.ll b/test/extensions/KHR/SPV_KHR_cooperative_matrix/array_of_matrices.ll index 28979b4eb1..7df3d61f6e 100644 --- a/test/extensions/KHR/SPV_KHR_cooperative_matrix/array_of_matrices.ll +++ b/test/extensions/KHR/SPV_KHR_cooperative_matrix/array_of_matrices.ll @@ -10,6 +10,13 @@ ; RUN: llvm-spirv -r %t.spv -o %t.rev.bc ; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM +; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_KHR_cooperative_matrix,+SPV_KHR_untyped_pointers -o %t.spv +; RUN: llvm-spirv %t.spv -to-text -o %t.spt +; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV + +; RUN: llvm-spirv -r --spirv-target-env=SPV-IR %t.spv -o %t.rev.bc +; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM + ; CHECK-SPIRV-DAG: Capability CooperativeMatrixKHR ; CHECK-SPIRV-DAG: Extension "SPV_KHR_cooperative_matrix" ; CHECK-SPIRV: TypeInt [[#Int16Ty:]] 16 0 diff --git a/test/extensions/KHR/SPV_KHR_cooperative_matrix/conversion_instructions.ll b/test/extensions/KHR/SPV_KHR_cooperative_matrix/conversion_instructions.ll index 39f103abd0..9130ac91a5 100644 --- a/test/extensions/KHR/SPV_KHR_cooperative_matrix/conversion_instructions.ll +++ b/test/extensions/KHR/SPV_KHR_cooperative_matrix/conversion_instructions.ll @@ -8,6 +8,15 @@ ; RUN: llvm-dis %t.rev.bc ; RUN: FileCheck < %t.rev.ll %s --check-prefix=CHECK-LLVM +; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_KHR_cooperative_matrix,+SPV_KHR_untyped_pointers -o %t.spv +; RUN: spirv-val %t.spv +; RUN: llvm-spirv %t.spv -to-text -o %t.spt +; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV + +; RUN: llvm-spirv -r --spirv-target-env=SPV-IR %t.spv -o %t.rev.bc +; RUN: llvm-dis %t.rev.bc +; RUN: FileCheck < %t.rev.ll %s --check-prefix=CHECK-LLVM + ; CHECK-SPIRV: TypeInt [[#TypeInt32:]] 32 0 ; CHECK-SPIRV: TypeInt [[#TypeInt16:]] 16 0 ; CHECK-SPIRV: TypeInt [[#TypeInt8:]] 8 0 diff --git a/test/extensions/KHR/SPV_KHR_cooperative_matrix/cooperative_matrix.ll b/test/extensions/KHR/SPV_KHR_cooperative_matrix/cooperative_matrix.ll index cb12dc52aa..280dc4edb5 100644 --- a/test/extensions/KHR/SPV_KHR_cooperative_matrix/cooperative_matrix.ll +++ b/test/extensions/KHR/SPV_KHR_cooperative_matrix/cooperative_matrix.ll @@ -8,6 +8,13 @@ ; RUN: llvm-spirv -r %t.spv -o %t.rev.bc ; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM +; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_KHR_cooperative_matrix,+SPV_KHR_untyped_pointers -o %t.spv +; RUN: llvm-spirv %t.spv -to-text -o %t.spt +; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV + +; RUN: llvm-spirv -r %t.spv -o %t.rev.bc +; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM + ; CHECK-SPIRV-DAG: Capability CooperativeMatrixKHR ; CHECK-SPIRV-DAG: Extension "SPV_KHR_cooperative_matrix" ; CHECK-SPIRV-DAG: TypeInt [[#Int8Ty:]] 8 0 From ac544c918b1bb5664c73bdddb35fed329b2283f6 Mon Sep 17 00:00:00 2001 From: "Maksimova, Viktoria" Date: Wed, 13 Nov 2024 05:56:16 -0800 Subject: [PATCH 2/5] Fix for access chain --- lib/SPIRV/SPIRVReader.cpp | 11 +++++++++-- lib/SPIRV/SPIRVWriter.cpp | 20 ++++++++++++++++++++ lib/SPIRV/libSPIRV/SPIRVInstruction.h | 10 ++++++++++ lib/SPIRV/libSPIRV/SPIRVOpCode.h | 7 +++++++ 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/lib/SPIRV/SPIRVReader.cpp b/lib/SPIRV/SPIRVReader.cpp index fbecdf8e5c..de8acf144f 100644 --- a/lib/SPIRV/SPIRVReader.cpp +++ b/lib/SPIRV/SPIRVReader.cpp @@ -2216,8 +2216,10 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F, auto *AC = static_cast(BV); auto *Base = transValue(AC->getBase(), F, BB); SPIRVType *BaseSPVTy = AC->getBaseType(); - if (BaseSPVTy->isTypePointer() && - BaseSPVTy->getPointerElementType()->isTypeCooperativeMatrixKHR()) { + if ((BaseSPVTy->isTypePointer() && + BaseSPVTy->getPointerElementType()->isTypeCooperativeMatrixKHR()) || + (isUntypedAccessChainOpCode(OC) && + BaseSPVTy->isTypeCooperativeMatrixKHR())) { return mapValue(BV, transSPIRVBuiltinFromInst(AC, BB)); } Type *BaseTy = @@ -3426,6 +3428,11 @@ Instruction *SPIRVToLLVM::transBuiltinFromInst(const std::string &FuncName, BasicBlock *BB) { std::string MangledName; auto Ops = BI->getOperands(); + if (isUntypedAccessChainOpCode(BI->getOpCode())) { + auto *AC = static_cast(BI); + if (AC->getBaseType()->isTypeCooperativeMatrixKHR()) + Ops.erase(Ops.begin()); + } Type *RetTy = BI->hasType() ? transType(BI->getType()) : Type::getVoidTy(*Context); transOCLBuiltinFromInstPreproc(BI, RetTy, Ops); diff --git a/lib/SPIRV/SPIRVWriter.cpp b/lib/SPIRV/SPIRVWriter.cpp index caf9f2366b..37a1f52f65 100644 --- a/lib/SPIRV/SPIRVWriter.cpp +++ b/lib/SPIRV/SPIRVWriter.cpp @@ -6821,8 +6821,28 @@ LLVMToSPIRVBase::transBuiltinToInstWithoutDecoration(Op OC, CallInst *CI, SPRetTy = transType(F->getParamStructRetType(0)); Args.erase(Args.begin()); } + if (RetTy->isPointerTy() && + BM->isAllowedToUseExtension(ExtensionID::SPV_KHR_untyped_pointers)) { + if (OC == OpAccessChain) + OC = OpUntypedAccessChainKHR; + else if (OC == OpInBoundsAccessChain) + OC = OpUntypedInBoundsAccessChainKHR; + else if (OC == OpPtrAccessChain) + OC = OpUntypedPtrAccessChainKHR; + else if (OC == OpInBoundsPtrAccessChain) + OC = OpUntypedInBoundsPtrAccessChainKHR; + } auto *SPI = SPIRVInstTemplateBase::create(OC); std::vector SPArgs; + if (isUntypedAccessChainOpCode(OC)) { + // Untyped access chain instructions have an additional argument BaseTy. + Type *Ty = Scavenger->getScavengedType(Args[0]); + SPIRVType *PtrTy = nullptr; + if (auto *TPT = dyn_cast(Ty)) { + PtrTy = transType(TPT->getElementType()); + SPArgs.push_back(PtrTy->getId()); + } + } for (size_t I = 0, E = Args.size(); I != E; ++I) { if (Args[I]->getType()->isPointerTy()) { Value *Pointee = Args[I]->stripPointerCasts(); diff --git a/lib/SPIRV/libSPIRV/SPIRVInstruction.h b/lib/SPIRV/libSPIRV/SPIRVInstruction.h index d29193aefc..ccb6346463 100644 --- a/lib/SPIRV/libSPIRV/SPIRVInstruction.h +++ b/lib/SPIRV/libSPIRV/SPIRVInstruction.h @@ -1747,6 +1747,16 @@ class SPIRVAccessChainBase : public SPIRVInstTemplateBase { OpCode == OpUntypedPtrAccessChainKHR || OpCode == OpUntypedInBoundsPtrAccessChainKHR; } + SPIRVCapVec getRequiredCapability() const override { + if (isUntyped()) + return getVec(CapabilityUntypedPointersKHR); + return {}; + } + std::optional getRequiredExtension() const override { + if (isUntyped()) + return ExtensionID::SPV_KHR_untyped_pointers; + return {}; + } }; template diff --git a/lib/SPIRV/libSPIRV/SPIRVOpCode.h b/lib/SPIRV/libSPIRV/SPIRVOpCode.h index 3541a94bf5..8e0ff61903 100644 --- a/lib/SPIRV/libSPIRV/SPIRVOpCode.h +++ b/lib/SPIRV/libSPIRV/SPIRVOpCode.h @@ -150,6 +150,13 @@ inline bool isAccessChainOpCode(Op OpCode) { return OpCode == OpAccessChain || OpCode == OpInBoundsAccessChain; } +inline bool isUntypedAccessChainOpCode(Op OpCode) { + return OpCode == OpUntypedAccessChainKHR || + OpCode == OpUntypedInBoundsAccessChainKHR || + OpCode == OpUntypedPtrAccessChainKHR || + OpCode == OpUntypedInBoundsPtrAccessChainKHR; +} + inline bool hasExecScope(Op OpCode) { unsigned OC = OpCode; return (OpGroupWaitEvents <= OC && OC <= OpGroupSMax) || From 5e06ef38001e53841d8d5641dbaf2bce3c355594 Mon Sep 17 00:00:00 2001 From: "Maksimova, Viktoria" Date: Wed, 13 Nov 2024 05:58:11 -0800 Subject: [PATCH 3/5] Fixes for pointer mangling --- lib/SPIRV/SPIRVReader.cpp | 50 +++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/lib/SPIRV/SPIRVReader.cpp b/lib/SPIRV/SPIRVReader.cpp index de8acf144f..25b8eba609 100644 --- a/lib/SPIRV/SPIRVReader.cpp +++ b/lib/SPIRV/SPIRVReader.cpp @@ -3428,7 +3428,8 @@ Instruction *SPIRVToLLVM::transBuiltinFromInst(const std::string &FuncName, BasicBlock *BB) { std::string MangledName; auto Ops = BI->getOperands(); - if (isUntypedAccessChainOpCode(BI->getOpCode())) { + Op OC = BI->getOpCode(); + if (isUntypedAccessChainOpCode(OC)) { auto *AC = static_cast(BI); if (AC->getBaseType()->isTypeCooperativeMatrixKHR()) Ops.erase(Ops.begin()); @@ -3439,17 +3440,53 @@ Instruction *SPIRVToLLVM::transBuiltinFromInst(const std::string &FuncName, std::vector ArgTys = transTypeVector(SPIRVInstruction::getOperandTypes(Ops), true); - // Special handling for "truly" untyped pointers to preserve correct - // builtin mangling of atomic operations. auto Ptr = findFirstPtrType(ArgTys); if (Ptr < ArgTys.size() && BI->getValueType(Ops[Ptr]->getId())->isTypeUntypedPointerKHR()) { - if (isAtomicOpCodeUntypedPtrSupported(BI->getOpCode())) { + // Special handling for "truly" untyped pointers to preserve correct + // builtin mangling of atomic and matrix operations. + if (isAtomicOpCodeUntypedPtrSupported(OC)) { auto *AI = static_cast(BI); ArgTys[Ptr] = TypedPointerType::get( transType(AI->getSemanticType()), SPIRSPIRVAddrSpaceMap::rmap( BI->getValueType(Ops[Ptr]->getId())->getPointerStorageClass())); + } else if (OC == spv::OpCooperativeMatrixStoreKHR || + OC == spv::internal::OpJointMatrixStoreINTEL || + OC == spv::internal::OpCooperativeMatrixStoreCheckedINTEL || + OC == spv::internal::OpJointMatrixLoadINTEL || + OC == spv::OpCompositeConstruct || + OC == spv::internal::OpCooperativeMatrixApplyFunctionINTEL) { + // It will work but it'd be strange + auto *Val = transValue(Ops[Ptr], BB->getParent(), BB); + Val = Val->stripPointerCasts(); + if (auto *GEP = dyn_cast(Val)) + ArgTys[Ptr] = TypedPointerType::get( + GEP->getSourceElementType(), + SPIRSPIRVAddrSpaceMap::rmap( + BI->getValueType(Ops[Ptr]->getId())->getPointerStorageClass())); + else if (auto *AI = dyn_cast(Val)) + ArgTys[Ptr] = TypedPointerType::get( + AI->getAllocatedType(), + SPIRSPIRVAddrSpaceMap::rmap( + BI->getValueType(Ops[Ptr]->getId())->getPointerStorageClass())); + else if (isa(Val) && RetTy) { + // Pointer could be a function parameter. Assume that the type of the + // pointer is the same as the return type. + Type *Ty = nullptr; + // it return type is array type, assign its element type to Ty + if (RetTy->isArrayTy()) + Ty = RetTy->getArrayElementType(); + else if (RetTy->isVectorTy()) + Ty = cast(RetTy)->getElementType(); + else + Ty = RetTy; + + ArgTys[Ptr] = TypedPointerType::get( + Ty, + SPIRSPIRVAddrSpaceMap::rmap( + BI->getValueType(Ops[Ptr]->getId())->getPointerStorageClass())); + } } } @@ -3463,7 +3500,7 @@ Instruction *SPIRVToLLVM::transBuiltinFromInst(const std::string &FuncName, mangleOpenClBuiltin(FuncName, ArgTys, MangledName); else MangledName = - getSPIRVFriendlyIRFunctionName(FuncName, BI->getOpCode(), ArgTys, Ops); + getSPIRVFriendlyIRFunctionName(FuncName, OC, ArgTys, Ops); opaquifyTypedPointers(ArgTys); @@ -3486,14 +3523,13 @@ Instruction *SPIRVToLLVM::transBuiltinFromInst(const std::string &FuncName, Func->setCallingConv(CallingConv::SPIR_FUNC); if (isFuncNoUnwind()) Func->addFnAttr(Attribute::NoUnwind); - auto OC = BI->getOpCode(); if (isGroupOpCode(OC) || isGroupNonUniformOpcode(OC) || isIntelSubgroupOpCode(OC) || isSplitBarrierINTELOpCode(OC) || OC == OpControlBarrier) Func->addFnAttr(Attribute::Convergent); } CallInst *Call; - if (BI->getOpCode() == OpCooperativeMatrixLengthKHR && + if (OC == OpCooperativeMatrixLengthKHR && Ops[0]->getOpCode() == OpTypeCooperativeMatrixKHR) { // OpCooperativeMatrixLengthKHR needs special handling as its operand is // a Type instead of a Value. From 99bd71622ea679ecd752437ca08186722d3e4f01 Mon Sep 17 00:00:00 2001 From: "Maksimova, Viktoria" Date: Wed, 13 Nov 2024 06:52:41 -0800 Subject: [PATCH 4/5] fix mangling --- lib/SPIRV/SPIRVReader.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/SPIRV/SPIRVReader.cpp b/lib/SPIRV/SPIRVReader.cpp index 25b8eba609..fed404f280 100644 --- a/lib/SPIRV/SPIRVReader.cpp +++ b/lib/SPIRV/SPIRVReader.cpp @@ -3443,8 +3443,8 @@ Instruction *SPIRVToLLVM::transBuiltinFromInst(const std::string &FuncName, auto Ptr = findFirstPtrType(ArgTys); if (Ptr < ArgTys.size() && BI->getValueType(Ops[Ptr]->getId())->isTypeUntypedPointerKHR()) { - // Special handling for "truly" untyped pointers to preserve correct - // builtin mangling of atomic and matrix operations. + // Special handling for "truly" untyped pointers to preserve correct + // builtin mangling of atomic and matrix operations. if (isAtomicOpCodeUntypedPtrSupported(OC)) { auto *AI = static_cast(BI); ArgTys[Ptr] = TypedPointerType::get( @@ -3499,8 +3499,7 @@ Instruction *SPIRVToLLVM::transBuiltinFromInst(const std::string &FuncName, if (BM->getDesiredBIsRepresentation() != BIsRepresentation::SPIRVFriendlyIR) mangleOpenClBuiltin(FuncName, ArgTys, MangledName); else - MangledName = - getSPIRVFriendlyIRFunctionName(FuncName, OC, ArgTys, Ops); + MangledName = getSPIRVFriendlyIRFunctionName(FuncName, OC, ArgTys, Ops); opaquifyTypedPointers(ArgTys); From b0e8c87ee0503cc85081552f363367ddcd5fdc89 Mon Sep 17 00:00:00 2001 From: "Maksimova, Viktoria" Date: Tue, 26 Nov 2024 05:48:19 -0800 Subject: [PATCH 5/5] fix check for return type --- lib/SPIRV/SPIRVReader.cpp | 3 +-- .../KHR/SPV_KHR_cooperative_matrix/cooperative_matrix.ll | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/SPIRV/SPIRVReader.cpp b/lib/SPIRV/SPIRVReader.cpp index fed404f280..fde17938e7 100644 --- a/lib/SPIRV/SPIRVReader.cpp +++ b/lib/SPIRV/SPIRVReader.cpp @@ -3457,7 +3457,6 @@ Instruction *SPIRVToLLVM::transBuiltinFromInst(const std::string &FuncName, OC == spv::internal::OpJointMatrixLoadINTEL || OC == spv::OpCompositeConstruct || OC == spv::internal::OpCooperativeMatrixApplyFunctionINTEL) { - // It will work but it'd be strange auto *Val = transValue(Ops[Ptr], BB->getParent(), BB); Val = Val->stripPointerCasts(); if (auto *GEP = dyn_cast(Val)) @@ -3470,7 +3469,7 @@ Instruction *SPIRVToLLVM::transBuiltinFromInst(const std::string &FuncName, AI->getAllocatedType(), SPIRSPIRVAddrSpaceMap::rmap( BI->getValueType(Ops[Ptr]->getId())->getPointerStorageClass())); - else if (isa(Val) && RetTy) { + else if (isa(Val) && !RetTy->isVoidTy()) { // Pointer could be a function parameter. Assume that the type of the // pointer is the same as the return type. Type *Ty = nullptr; diff --git a/test/extensions/KHR/SPV_KHR_cooperative_matrix/cooperative_matrix.ll b/test/extensions/KHR/SPV_KHR_cooperative_matrix/cooperative_matrix.ll index 280dc4edb5..71d7139ee7 100644 --- a/test/extensions/KHR/SPV_KHR_cooperative_matrix/cooperative_matrix.ll +++ b/test/extensions/KHR/SPV_KHR_cooperative_matrix/cooperative_matrix.ll @@ -43,6 +43,7 @@ ; CHECK-LLVM: call spir_func target("spirv.CooperativeMatrixKHR", i8, 2, 48, 12, 1) @_Z86__spirv_CooperativeMatrixLoadKHR_RPU3AS144__spirv_CooperativeMatrixKHR__char_2_48_12_1PU3AS4cil ; CHECK-LLVM: call spir_func target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 2) @_Z34__spirv_CooperativeMatrixMulAddKHRPU3AS144__spirv_CooperativeMatrixKHR__char_0_12_48_0PU3AS144__spirv_CooperativeMatrixKHR__char_2_48_12_1PU3AS144__spirv_CooperativeMatrixKHR__uint_3_12_12_2i(target("spirv.CooperativeMatrixKHR", i8, 0, 12, 48, 0) %{{.*}}, target("spirv.CooperativeMatrixKHR", i8, 2, 48, 12, 1) %{{.*}}, target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 2) ; CHECK-LLVM: call spir_func void @_Z33__spirv_CooperativeMatrixStoreKHRPU3AS4iPU3AS144__spirv_CooperativeMatrixKHR__uint_3_12_12_2ili(ptr addrspace(4) %call.ascast.i.i, target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 2) +; CHECK-LLVM: call spir_func void @_Z33__spirv_CooperativeMatrixStoreKHRPU3AS1cPU3AS144__spirv_CooperativeMatrixKHR__uint_3_12_12_2ili(ptr addrspace(1) %_arg_accC, target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 2) ; ModuleID = 'test-matrix-opaque.bc' source_filename = "matrix-int8-test.cpp" @@ -139,6 +140,13 @@ _ZZZ15matrix_multiplyIiaLm24ELm96ELm24ELm96ELm24ELm24EEvR10big_matrixIT_XT5_EXT6 ret void } +define weak_odr dso_local spir_func void @matrix_store(ptr addrspace(1) noundef align 4 %_arg_accC, i64 noundef %_arg_N) local_unnamed_addr #0 { + %sub_c.sroa.0.i = alloca target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 2), align 8 + %sub_c.sroa.0.i.0 = load target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 2), ptr %sub_c.sroa.0.i, align 8 + tail call spir_func void @_Z33__spirv_CooperativeMatrixStoreKHR_2(ptr addrspace(1) noundef %_arg_accC, target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 2) noundef %sub_c.sroa.0.i.0, i32 noundef 0, i64 noundef %_arg_N, i32 noundef 1) #4 + ret void +} + ; Function Attrs: convergent declare dso_local spir_func noundef target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 2) @_Z26__spirv_CompositeConstruct(i32 noundef) local_unnamed_addr #2 @@ -156,6 +164,7 @@ declare dso_local spir_func noundef target("spirv.CooperativeMatrixKHR", i32, 3, ; Function Attrs: convergent declare dso_local spir_func void @_Z33__spirv_CooperativeMatrixStoreKHR(ptr addrspace(4) noundef, target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 2) noundef, i32 noundef, i64 noundef, i32 noundef) local_unnamed_addr #2 +declare dso_local spir_func void @_Z33__spirv_CooperativeMatrixStoreKHR_2(ptr addrspace(1) noundef, target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 2) noundef, i32 noundef, i64 noundef, i32 noundef) local_unnamed_addr #2 ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3