| 1 |
; RUN: llvm-spirv %s -to-binary -o %t.spv |
| 2 |
; RUN: spirv-val %t.spv |
| 3 |
; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.bc |
| 4 |
; RUN: llvm-dis < %t.bc | FileCheck %s --check-prefix=CHECK-LLVM |
| 5 |
|
| 6 |
119734787 65536 458752 21 0 |
| 7 |
2 Capability Addresses |
| 8 |
2 Capability Linkage |
| 9 |
2 Capability Kernel |
| 10 |
2 Capability Float64 |
| 11 |
2 Capability Matrix |
| 12 |
3 MemoryModel 2 2 |
| 13 |
8 EntryPoint 6 20 "matrix_times_matrix" |
| 14 |
3 Source 3 102000 |
| 15 |
3 Name 12 "res" |
| 16 |
3 Name 13 "lhs" |
| 17 |
3 Name 14 "rhs" |
| 18 |
|
| 19 |
2 TypeVoid 5 |
| 20 |
3 TypeFloat 6 32 |
| 21 |
4 TypeVector 7 6 4 ; 7 : Vector of 4 floats |
| 22 |
4 TypeMatrix 8 7 4 ; 8 : Matrix of 4 vectors |
| 23 |
4 TypePointer 9 7 8 ; 9 : Pointer to Matrix |
| 24 |
6 TypeFunction 10 5 9 9 9 |
| 25 |
|
| 26 |
5 Function 5 20 0 10 ; lhs x rhs -> res |
| 27 |
3 FunctionParameter 9 12 ; res : Pointer to Matrix |
| 28 |
3 FunctionParameter 9 13 ; lhs : Pointer to Matrix |
| 29 |
3 FunctionParameter 9 14 ; rhs : Pointer to Matrix |
| 30 |
|
| 31 |
2 Label 15 |
| 32 |
4 Load 8 16 13 |
| 33 |
4 Load 8 17 14 |
| 34 |
5 MatrixTimesMatrix 8 18 16 17 |
| 35 |
3 Store 12 18 |
| 36 |
1 Return |
| 37 |
|
| 38 |
1 FunctionEnd |
| 39 |
|
| 40 |
; 4x4 Matrix multiplication requires 16 vector multiplication |
| 41 |
; CHECK-LLVM: %1 = load [4 x <4 x float>], ptr %lhs |
| 42 |
; CHECK-LLVM: %2 = load [4 x <4 x float>], ptr %rhs |
| 43 |
; CHECK-LLVM: %3 = extractvalue [4 x <4 x float>] %2, 0 |
| 44 |
; CHECK-LLVM: %4 = extractelement <4 x float> %3, i32 0 |
| 45 |
; CHECK-LLVM: %.splatinsert = insertelement <4 x float> poison, float %4, i64 0 |
| 46 |
; CHECK-LLVM: %.splat = shufflevector <4 x float> %.splatinsert, <4 x float> poison, <4 x i32> zeroinitializer |
| 47 |
; CHECK-LLVM: %5 = extractvalue [4 x <4 x float>] %1, 0 |
| 48 |
; CHECK-LLVM: %6 = fmul <4 x float> %.splat, %5 |
| 49 |
; CHECK-LLVM: %7 = fadd <4 x float> zeroinitializer, %6 |
| 50 |
; CHECK-LLVM: %8 = extractelement <4 x float> %3, i32 1 |
| 51 |
; CHECK-LLVM: %.splatinsert1 = insertelement <4 x float> poison, float %8, i64 0 |
| 52 |
; CHECK-LLVM: %.splat2 = shufflevector <4 x float> %.splatinsert1, <4 x float> poison, <4 x i32> zeroinitializer |
| 53 |
; CHECK-LLVM: %9 = extractvalue [4 x <4 x float>] %1, 1 |
| 54 |
; CHECK-LLVM: %10 = fmul <4 x float> %.splat2, %9 |
| 55 |
; CHECK-LLVM: %11 = fadd <4 x float> %7, %10 |
| 56 |
; CHECK-LLVM: %12 = extractelement <4 x float> %3, i32 2 |
| 57 |
; CHECK-LLVM: %.splatinsert3 = insertelement <4 x float> poison, float %12, i64 0 |
| 58 |
; CHECK-LLVM: %.splat4 = shufflevector <4 x float> %.splatinsert3, <4 x float> poison, <4 x i32> zeroinitializer |
| 59 |
; CHECK-LLVM: %13 = extractvalue [4 x <4 x float>] %1, 2 |
| 60 |
; CHECK-LLVM: %14 = fmul <4 x float> %.splat4, %13 |
| 61 |
; CHECK-LLVM: %15 = fadd <4 x float> %11, %14 |
| 62 |
; CHECK-LLVM: %16 = extractelement <4 x float> %3, i32 3 |
| 63 |
; CHECK-LLVM: %.splatinsert5 = insertelement <4 x float> poison, float %16, i64 0 |
| 64 |
; CHECK-LLVM: %.splat6 = shufflevector <4 x float> %.splatinsert5, <4 x float> poison, <4 x i32> zeroinitializer |
| 65 |
; CHECK-LLVM: %17 = extractvalue [4 x <4 x float>] %1, 3 |
| 66 |
; CHECK-LLVM: %18 = fmul <4 x float> %.splat6, %17 |
| 67 |
; CHECK-LLVM: %19 = fadd <4 x float> %15, %18 |
| 68 |
; CHECK-LLVM: %20 = insertvalue [4 x <4 x float>] undef, <4 x float> %19, 0 |
| 69 |
; CHECK-LLVM: %21 = extractvalue [4 x <4 x float>] %2, 1 |
| 70 |
; CHECK-LLVM: %22 = extractelement <4 x float> %21, i32 0 |
| 71 |
; CHECK-LLVM: %.splatinsert7 = insertelement <4 x float> poison, float %22, i64 0 |
| 72 |
; CHECK-LLVM: %.splat8 = shufflevector <4 x float> %.splatinsert7, <4 x float> poison, <4 x i32> zeroinitializer |
| 73 |
; CHECK-LLVM: %23 = extractvalue [4 x <4 x float>] %1, 0 |
| 74 |
; CHECK-LLVM: %24 = fmul <4 x float> %.splat8, %23 |
| 75 |
; CHECK-LLVM: %25 = fadd <4 x float> zeroinitializer, %24 |
| 76 |
; CHECK-LLVM: %26 = extractelement <4 x float> %21, i32 1 |
| 77 |
; CHECK-LLVM: %.splatinsert9 = insertelement <4 x float> poison, float %26, i64 0 |
| 78 |
; CHECK-LLVM: %.splat10 = shufflevector <4 x float> %.splatinsert9, <4 x float> poison, <4 x i32> zeroinitializer |
| 79 |
; CHECK-LLVM: %27 = extractvalue [4 x <4 x float>] %1, 1 |
| 80 |
; CHECK-LLVM: %28 = fmul <4 x float> %.splat10, %27 |
| 81 |
; CHECK-LLVM: %29 = fadd <4 x float> %25, %28 |
| 82 |
; CHECK-LLVM: %30 = extractelement <4 x float> %21, i32 2 |
| 83 |
; CHECK-LLVM: %.splatinsert11 = insertelement <4 x float> poison, float %30, i64 0 |
| 84 |
; CHECK-LLVM: %.splat12 = shufflevector <4 x float> %.splatinsert11, <4 x float> poison, <4 x i32> zeroinitializer |
| 85 |
; CHECK-LLVM: %31 = extractvalue [4 x <4 x float>] %1, 2 |
| 86 |
; CHECK-LLVM: %32 = fmul <4 x float> %.splat12, %31 |
| 87 |
; CHECK-LLVM: %33 = fadd <4 x float> %29, %32 |
| 88 |
; CHECK-LLVM: %34 = extractelement <4 x float> %21, i32 3 |
| 89 |
; CHECK-LLVM: %.splatinsert13 = insertelement <4 x float> poison, float %34, i64 0 |
| 90 |
; CHECK-LLVM: %.splat14 = shufflevector <4 x float> %.splatinsert13, <4 x float> poison, <4 x i32> zeroinitializer |
| 91 |
; CHECK-LLVM: %35 = extractvalue [4 x <4 x float>] %1, 3 |
| 92 |
; CHECK-LLVM: %36 = fmul <4 x float> %.splat14, %35 |
| 93 |
; CHECK-LLVM: %37 = fadd <4 x float> %33, %36 |
| 94 |
; CHECK-LLVM: %38 = insertvalue [4 x <4 x float>] %20, <4 x float> %37, 1 |
| 95 |
; CHECK-LLVM: %39 = extractvalue [4 x <4 x float>] %2, 2 |
| 96 |
; CHECK-LLVM: %40 = extractelement <4 x float> %39, i32 0 |
| 97 |
; CHECK-LLVM: %.splatinsert15 = insertelement <4 x float> poison, float %40, i64 0 |
| 98 |
; CHECK-LLVM: %.splat16 = shufflevector <4 x float> %.splatinsert15, <4 x float> poison, <4 x i32> zeroinitializer |
| 99 |
; CHECK-LLVM: %41 = extractvalue [4 x <4 x float>] %1, 0 |
| 100 |
; CHECK-LLVM: %42 = fmul <4 x float> %.splat16, %41 |
| 101 |
; CHECK-LLVM: %43 = fadd <4 x float> zeroinitializer, %42 |
| 102 |
; CHECK-LLVM: %44 = extractelement <4 x float> %39, i32 1 |
| 103 |
; CHECK-LLVM: %.splatinsert17 = insertelement <4 x float> poison, float %44, i64 0 |
| 104 |
; CHECK-LLVM: %.splat18 = shufflevector <4 x float> %.splatinsert17, <4 x float> poison, <4 x i32> zeroinitializer |
| 105 |
; CHECK-LLVM: %45 = extractvalue [4 x <4 x float>] %1, 1 |
| 106 |
; CHECK-LLVM: %46 = fmul <4 x float> %.splat18, %45 |
| 107 |
; CHECK-LLVM: %47 = fadd <4 x float> %43, %46 |
| 108 |
; CHECK-LLVM: %48 = extractelement <4 x float> %39, i32 2 |
| 109 |
; CHECK-LLVM: %.splatinsert19 = insertelement <4 x float> poison, float %48, i64 0 |
| 110 |
; CHECK-LLVM: %.splat20 = shufflevector <4 x float> %.splatinsert19, <4 x float> poison, <4 x i32> zeroinitializer |
| 111 |
; CHECK-LLVM: %49 = extractvalue [4 x <4 x float>] %1, 2 |
| 112 |
; CHECK-LLVM: %50 = fmul <4 x float> %.splat20, %49 |
| 113 |
; CHECK-LLVM: %51 = fadd <4 x float> %47, %50 |
| 114 |
; CHECK-LLVM: %52 = extractelement <4 x float> %39, i32 3 |
| 115 |
; CHECK-LLVM: %.splatinsert21 = insertelement <4 x float> poison, float %52, i64 0 |
| 116 |
; CHECK-LLVM: %.splat22 = shufflevector <4 x float> %.splatinsert21, <4 x float> poison, <4 x i32> zeroinitializer |
| 117 |
; CHECK-LLVM: %53 = extractvalue [4 x <4 x float>] %1, 3 |
| 118 |
; CHECK-LLVM: %54 = fmul <4 x float> %.splat22, %53 |
| 119 |
; CHECK-LLVM: %55 = fadd <4 x float> %51, %54 |
| 120 |
; CHECK-LLVM: %56 = insertvalue [4 x <4 x float>] %38, <4 x float> %55, 2 |
| 121 |
; CHECK-LLVM: %57 = extractvalue [4 x <4 x float>] %2, 3 |
| 122 |
; CHECK-LLVM: %58 = extractelement <4 x float> %57, i32 0 |
| 123 |
; CHECK-LLVM: %.splatinsert23 = insertelement <4 x float> poison, float %58, i64 0 |
| 124 |
; CHECK-LLVM: %.splat24 = shufflevector <4 x float> %.splatinsert23, <4 x float> poison, <4 x i32> zeroinitializer |
| 125 |
; CHECK-LLVM: %59 = extractvalue [4 x <4 x float>] %1, 0 |
| 126 |
; CHECK-LLVM: %60 = fmul <4 x float> %.splat24, %59 |
| 127 |
; CHECK-LLVM: %61 = fadd <4 x float> zeroinitializer, %60 |
| 128 |
; CHECK-LLVM: %62 = extractelement <4 x float> %57, i32 1 |
| 129 |
; CHECK-LLVM: %.splatinsert25 = insertelement <4 x float> poison, float %62, i64 0 |
| 130 |
; CHECK-LLVM: %.splat26 = shufflevector <4 x float> %.splatinsert25, <4 x float> poison, <4 x i32> zeroinitializer |
| 131 |
; CHECK-LLVM: %63 = extractvalue [4 x <4 x float>] %1, 1 |
| 132 |
; CHECK-LLVM: %64 = fmul <4 x float> %.splat26, %63 |
| 133 |
; CHECK-LLVM: %65 = fadd <4 x float> %61, %64 |
| 134 |
; CHECK-LLVM: %66 = extractelement <4 x float> %57, i32 2 |
| 135 |
; CHECK-LLVM: %.splatinsert27 = insertelement <4 x float> poison, float %66, i64 0 |
| 136 |
; CHECK-LLVM: %.splat28 = shufflevector <4 x float> %.splatinsert27, <4 x float> poison, <4 x i32> zeroinitializer |
| 137 |
; CHECK-LLVM: %67 = extractvalue [4 x <4 x float>] %1, 2 |
| 138 |
; CHECK-LLVM: %68 = fmul <4 x float> %.splat28, %67 |
| 139 |
; CHECK-LLVM: %69 = fadd <4 x float> %65, %68 |
| 140 |
; CHECK-LLVM: %70 = extractelement <4 x float> %57, i32 3 |
| 141 |
; CHECK-LLVM: %.splatinsert29 = insertelement <4 x float> poison, float %70, i64 0 |
| 142 |
; CHECK-LLVM: %.splat30 = shufflevector <4 x float> %.splatinsert29, <4 x float> poison, <4 x i32> zeroinitializer |
| 143 |
; CHECK-LLVM: %71 = extractvalue [4 x <4 x float>] %1, 3 |
| 144 |
; CHECK-LLVM: %72 = fmul <4 x float> %.splat30, %71 |
| 145 |
; CHECK-LLVM: %73 = fadd <4 x float> %69, %72 |
| 146 |
; CHECK-LLVM: %74 = insertvalue [4 x <4 x float>] %56, <4 x float> %73, 3 |
| 147 |
; CHECK-LLVM: store [4 x <4 x float>] %74, ptr %res |
| 148 |
; CHECK-LLVM: ret void |