|
| 1 | +; The test checks, that users of the call to joint_matrix_layout_to_spv matrix |
| 2 | +; are replaced with the layout constant. |
| 3 | + |
| 4 | +; RUN: opt -passes=sycl-joint-matrix-transform < %s -S | FileCheck %s |
| 5 | + |
| 6 | +; ModuleID = 'test.bc' |
| 7 | +source_filename = "test.cpp" |
| 8 | +target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1" |
| 9 | +target triple = "spir64-unknown-unknown" |
| 10 | + |
| 11 | +$joint_matrix_layout_to_spv = comdat any |
| 12 | + |
| 13 | +; CHECK: define weak_odr dso_local spir_kernel void @test |
| 14 | +; CHECK-NEXT: entry: |
| 15 | +; CHECK-NEXT: %{{.*}} = call spir_func noundef target("spirv.CooperativeMatrixKHR", float, 3, 16, 16, 2) @_Z32__spirv_CooperativeMatrixLoadKHR{{.*}}(ptr addrspace(1){{.*}}, i32 noundef 0, i64 noundef{{.*}} |
| 16 | +; CHECK-NEXT: %{{.*}} = call spir_func noundef target("spirv.CooperativeMatrixKHR", float, 3, 16, 16, 2) @_Z32__spirv_CooperativeMatrixLoadKHR{{.*}}(ptr addrspace(1){{.*}}, i32 noundef 1, i64 noundef{{.*}} |
| 17 | +; CHECK-NEXT: %{{.*}} = call spir_func noundef target("spirv.CooperativeMatrixKHR", float, 3, 16, 16, 2) @_Z32__spirv_CooperativeMatrixLoadKHR{{.*}}(ptr addrspace(1){{.*}}, i32 noundef 1, i64 noundef{{.*}} |
| 18 | +; CHECK-NEXT: %{{.*}} = call spir_func noundef target("spirv.CooperativeMatrixKHR", float, 3, 16, 16, 2) @_Z32__spirv_CooperativeMatrixLoadKHR{{.*}}(ptr addrspace(1){{.*}}, i32 noundef 2, i64 noundef{{.*}} |
| 19 | +; CHECK-NEXT: ret void |
| 20 | + |
| 21 | +; CHECK-NOT: joint_matrix_layout_to_spv |
| 22 | + |
| 23 | +define weak_odr dso_local spir_kernel void @test(ptr addrspace(1) %matrix.1, ptr addrspace(1) %matrix.2, i64 noundef %stride) { |
| 24 | +entry: |
| 25 | + %layout.1 = alloca i32, align 4 |
| 26 | + %layout.2 = alloca i32, align 4 |
| 27 | + %layout.ascast.1 = addrspacecast ptr %layout.1 to ptr addrspace(4) |
| 28 | + %layout.ascast.2 = addrspacecast ptr %layout.2 to ptr addrspace(4) |
| 29 | + store i32 0, ptr addrspace(4) %layout.ascast.1, align 4 |
| 30 | + store i32 1, ptr addrspace(4) %layout.ascast.2, align 4 |
| 31 | + |
| 32 | + %layout.val.1 = load i32, ptr addrspace(4) %layout.ascast.1, align 4 |
| 33 | + %layout.spv.1 = call spir_func noundef i32 @joint_matrix_layout_to_spv(i32 noundef %layout.val.1) |
| 34 | + %mload.1 = call spir_func noundef target("spirv.CooperativeMatrixKHR", float, 3, 16, 16, 2) @_Z32__spirv_CooperativeMatrixLoadKHRIU3AS1ffLm16ELm16ELN5__spv9MatrixUseE2ELNS1_12MatrixLayoutE3ELNS1_5Scope4FlagE3EEPNS1_28__spirv_CooperativeMatrixKHRIT0_XT5_EXT1_EXT2_EXT3_EEEPT_S3_mi(ptr addrspace(1) noundef %matrix.1, i32 noundef %layout.spv.1, i64 noundef %stride, i32 noundef 0) |
| 35 | + |
| 36 | + %layout.val.2 = load i32, ptr addrspace(4) %layout.ascast.2, align 4 |
| 37 | + %layout.spv.2 = call spir_func noundef i32 @joint_matrix_layout_to_spv(i32 noundef %layout.val.2) |
| 38 | + %mload.2 = call spir_func noundef target("spirv.CooperativeMatrixKHR", float, 3, 16, 16, 2) @_Z32__spirv_CooperativeMatrixLoadKHRIU3AS1ffLm16ELm16ELN5__spv9MatrixUseE2ELNS1_12MatrixLayoutE3ELNS1_5Scope4FlagE3EEPNS1_28__spirv_CooperativeMatrixKHRIT0_XT5_EXT1_EXT2_EXT3_EEEPT_S3_mi(ptr addrspace(1) noundef %matrix.2, i32 noundef %layout.spv.2, i64 noundef %stride, i32 noundef 0) |
| 39 | + |
| 40 | + %layout.spv.3 = call spir_func noundef i32 @joint_matrix_layout_to_spv(i32 noundef %layout.val.2) |
| 41 | + %mload.3 = call spir_func noundef target("spirv.CooperativeMatrixKHR", float, 3, 16, 16, 2) @_Z32__spirv_CooperativeMatrixLoadKHRIU3AS1ffLm16ELm16ELN5__spv9MatrixUseE2ELNS1_12MatrixLayoutE3ELNS1_5Scope4FlagE3EEPNS1_28__spirv_CooperativeMatrixKHRIT0_XT5_EXT1_EXT2_EXT3_EEEPT_S3_mi(ptr addrspace(1) noundef %matrix.2, i32 noundef %layout.spv.3, i64 noundef %stride, i32 noundef 0) |
| 42 | + |
| 43 | + store i32 2, ptr addrspace(4) %layout.ascast.2, align 4 |
| 44 | + %layout.val.4 = load i32, ptr addrspace(4) %layout.ascast.2, align 4 |
| 45 | + %layout.spv.4 = call spir_func noundef i32 @joint_matrix_layout_to_spv(i32 noundef %layout.val.4) |
| 46 | + %mload.4 = call spir_func noundef target("spirv.CooperativeMatrixKHR", float, 3, 16, 16, 2) @_Z32__spirv_CooperativeMatrixLoadKHRIU3AS1ffLm16ELm16ELN5__spv9MatrixUseE2ELNS1_12MatrixLayoutE3ELNS1_5Scope4FlagE3EEPNS1_28__spirv_CooperativeMatrixKHRIT0_XT5_EXT1_EXT2_EXT3_EEEPT_S3_mi(ptr addrspace(1) noundef %matrix.2, i32 noundef %layout.spv.4, i64 noundef %stride, i32 noundef 0) |
| 47 | + ret void |
| 48 | +} |
| 49 | + |
| 50 | +declare dso_local spir_func noundef target("spirv.CooperativeMatrixKHR", float, 3, 16, 16, 2) @_Z32__spirv_CooperativeMatrixLoadKHRIU3AS1ffLm16ELm16ELN5__spv9MatrixUseE2ELNS1_12MatrixLayoutE3ELNS1_5Scope4FlagE3EEPNS1_28__spirv_CooperativeMatrixKHRIT0_XT5_EXT1_EXT2_EXT3_EEEPT_S3_mi(ptr addrspace(1) noundef, i32 noundef, i64 noundef, i32 noundef) |
| 51 | + |
| 52 | +define linkonce_odr dso_local spir_func noundef i32 @joint_matrix_layout_to_spv(i32 noundef %Layout) comdat { |
| 53 | +entry: |
| 54 | + %retval = alloca i32, align 4 |
| 55 | + %Layout.addr = alloca i32, align 4 |
| 56 | + %retval.ascast = addrspacecast ptr %retval to ptr addrspace(4) |
| 57 | + %Layout.addr.ascast = addrspacecast ptr %Layout.addr to ptr addrspace(4) |
| 58 | + store i32 %Layout, ptr addrspace(4) %Layout.addr.ascast, align 4 |
| 59 | + %0 = load i32, ptr addrspace(4) %Layout.addr.ascast, align 4 |
| 60 | + switch i32 %0, label %sw.epilog [ |
| 61 | + i32 0, label %sw.bb |
| 62 | + i32 1, label %sw.bb1 |
| 63 | + i32 2, label %sw.bb2 |
| 64 | + i32 3, label %sw.bb3 |
| 65 | + ] |
| 66 | + |
| 67 | +sw.bb: ; preds = %entry |
| 68 | + store i32 0, ptr addrspace(4) %retval.ascast, align 4 |
| 69 | + br label %return |
| 70 | + |
| 71 | +sw.bb1: ; preds = %entry |
| 72 | + store i32 1, ptr addrspace(4) %retval.ascast, align 4 |
| 73 | + br label %return |
| 74 | + |
| 75 | +sw.bb2: ; preds = %entry |
| 76 | + store i32 2, ptr addrspace(4) %retval.ascast, align 4 |
| 77 | + br label %return |
| 78 | + |
| 79 | +sw.bb3: ; preds = %entry |
| 80 | + store i32 3, ptr addrspace(4) %retval.ascast, align 4 |
| 81 | + br label %return |
| 82 | + |
| 83 | +sw.epilog: ; preds = %entry |
| 84 | + call void @llvm.trap() |
| 85 | + unreachable |
| 86 | + |
| 87 | +return: ; preds = %sw.bb3, %sw.bb2, %sw.bb1, %sw.bb |
| 88 | + %1 = load i32, ptr addrspace(4) %retval.ascast, align 4 |
| 89 | + ret i32 %1 |
| 90 | +} |
0 commit comments