; RUN: llvm-spirv %s -to-binary -o %t.spv ; RUN: spirv-val %t.spv ; RUN: llvm-spirv -r %t.spv -o %t.bc ; RUN: llvm-dis < %t.bc | FileCheck %s --check-prefix=CHECK-LLVM 119734787 65536 458752 21 0 2 Capability Addresses 2 Capability Linkage 2 Capability Kernel 2 Capability Float64 2 Capability Matrix 3 MemoryModel 2 2 8 EntryPoint 6 20 "matrix_times_matrix" 3 Source 3 102000 3 Name 12 "res" 3 Name 13 "lhs" 3 Name 14 "rhs" 2 TypeVoid 5 3 TypeFloat 6 32 4 TypeVector 7 6 4 ; 7 : Vector of 4 floats 4 TypeMatrix 8 7 4 ; 8 : Matrix of 4 vectors 4 TypePointer 9 7 8 ; 9 : Pointer to Matrix 6 TypeFunction 10 5 9 9 9 5 Function 5 20 0 10 ; lhs x rhs -> res 3 FunctionParameter 9 12 ; res : Pointer to Matrix 3 FunctionParameter 9 13 ; lhs : Pointer to Matrix 3 FunctionParameter 9 14 ; rhs : Pointer to Matrix 2 Label 15 4 Load 8 16 13 4 Load 8 17 14 5 MatrixTimesMatrix 8 18 16 17 3 Store 12 18 1 Return 1 FunctionEnd ; 4x4 Matrix multiplication requires 16 vector multiplication ; CHECK-LLVM: %1 = load [4 x <4 x float>], ptr %lhs ; CHECK-LLVM: %2 = load [4 x <4 x float>], ptr %rhs ; CHECK-LLVM: %3 = extractvalue [4 x <4 x float>] %2, 0 ; CHECK-LLVM: %4 = extractelement <4 x float> %3, i32 0 ; CHECK-LLVM: %.splatinsert = insertelement <4 x float> poison, float %4, i64 0 ; CHECK-LLVM: %.splat = shufflevector <4 x float> %.splatinsert, <4 x float> poison, <4 x i32> zeroinitializer ; CHECK-LLVM: %5 = extractvalue [4 x <4 x float>] %1, 0 ; CHECK-LLVM: %6 = fmul <4 x float> %.splat, %5 ; CHECK-LLVM: %7 = fadd <4 x float> zeroinitializer, %6 ; CHECK-LLVM: %8 = extractelement <4 x float> %3, i32 1 ; CHECK-LLVM: %.splatinsert1 = insertelement <4 x float> poison, float %8, i64 0 ; CHECK-LLVM: %.splat2 = shufflevector <4 x float> %.splatinsert1, <4 x float> poison, <4 x i32> zeroinitializer ; CHECK-LLVM: %9 = extractvalue [4 x <4 x float>] %1, 1 ; CHECK-LLVM: %10 = fmul <4 x float> %.splat2, %9 ; CHECK-LLVM: %11 = fadd <4 x float> %7, %10 ; CHECK-LLVM: %12 = extractelement <4 x float> %3, i32 2 ; CHECK-LLVM: %.splatinsert3 = insertelement <4 x float> poison, float %12, i64 0 ; CHECK-LLVM: %.splat4 = shufflevector <4 x float> %.splatinsert3, <4 x float> poison, <4 x i32> zeroinitializer ; CHECK-LLVM: %13 = extractvalue [4 x <4 x float>] %1, 2 ; CHECK-LLVM: %14 = fmul <4 x float> %.splat4, %13 ; CHECK-LLVM: %15 = fadd <4 x float> %11, %14 ; CHECK-LLVM: %16 = extractelement <4 x float> %3, i32 3 ; CHECK-LLVM: %.splatinsert5 = insertelement <4 x float> poison, float %16, i64 0 ; CHECK-LLVM: %.splat6 = shufflevector <4 x float> %.splatinsert5, <4 x float> poison, <4 x i32> zeroinitializer ; CHECK-LLVM: %17 = extractvalue [4 x <4 x float>] %1, 3 ; CHECK-LLVM: %18 = fmul <4 x float> %.splat6, %17 ; CHECK-LLVM: %19 = fadd <4 x float> %15, %18 ; CHECK-LLVM: %20 = insertvalue [4 x <4 x float>] poison, <4 x float> %19, 0 ; CHECK-LLVM: %21 = extractvalue [4 x <4 x float>] %2, 1 ; CHECK-LLVM: %22 = extractelement <4 x float> %21, i32 0 ; CHECK-LLVM: %.splatinsert7 = insertelement <4 x float> poison, float %22, i64 0 ; CHECK-LLVM: %.splat8 = shufflevector <4 x float> %.splatinsert7, <4 x float> poison, <4 x i32> zeroinitializer ; CHECK-LLVM: %23 = extractvalue [4 x <4 x float>] %1, 0 ; CHECK-LLVM: %24 = fmul <4 x float> %.splat8, %23 ; CHECK-LLVM: %25 = fadd <4 x float> zeroinitializer, %24 ; CHECK-LLVM: %26 = extractelement <4 x float> %21, i32 1 ; CHECK-LLVM: %.splatinsert9 = insertelement <4 x float> poison, float %26, i64 0 ; CHECK-LLVM: %.splat10 = shufflevector <4 x float> %.splatinsert9, <4 x float> poison, <4 x i32> zeroinitializer ; CHECK-LLVM: %27 = extractvalue [4 x <4 x float>] %1, 1 ; CHECK-LLVM: %28 = fmul <4 x float> %.splat10, %27 ; CHECK-LLVM: %29 = fadd <4 x float> %25, %28 ; CHECK-LLVM: %30 = extractelement <4 x float> %21, i32 2 ; CHECK-LLVM: %.splatinsert11 = insertelement <4 x float> poison, float %30, i64 0 ; CHECK-LLVM: %.splat12 = shufflevector <4 x float> %.splatinsert11, <4 x float> poison, <4 x i32> zeroinitializer ; CHECK-LLVM: %31 = extractvalue [4 x <4 x float>] %1, 2 ; CHECK-LLVM: %32 = fmul <4 x float> %.splat12, %31 ; CHECK-LLVM: %33 = fadd <4 x float> %29, %32 ; CHECK-LLVM: %34 = extractelement <4 x float> %21, i32 3 ; CHECK-LLVM: %.splatinsert13 = insertelement <4 x float> poison, float %34, i64 0 ; CHECK-LLVM: %.splat14 = shufflevector <4 x float> %.splatinsert13, <4 x float> poison, <4 x i32> zeroinitializer ; CHECK-LLVM: %35 = extractvalue [4 x <4 x float>] %1, 3 ; CHECK-LLVM: %36 = fmul <4 x float> %.splat14, %35 ; CHECK-LLVM: %37 = fadd <4 x float> %33, %36 ; CHECK-LLVM: %38 = insertvalue [4 x <4 x float>] %20, <4 x float> %37, 1 ; CHECK-LLVM: %39 = extractvalue [4 x <4 x float>] %2, 2 ; CHECK-LLVM: %40 = extractelement <4 x float> %39, i32 0 ; CHECK-LLVM: %.splatinsert15 = insertelement <4 x float> poison, float %40, i64 0 ; CHECK-LLVM: %.splat16 = shufflevector <4 x float> %.splatinsert15, <4 x float> poison, <4 x i32> zeroinitializer ; CHECK-LLVM: %41 = extractvalue [4 x <4 x float>] %1, 0 ; CHECK-LLVM: %42 = fmul <4 x float> %.splat16, %41 ; CHECK-LLVM: %43 = fadd <4 x float> zeroinitializer, %42 ; CHECK-LLVM: %44 = extractelement <4 x float> %39, i32 1 ; CHECK-LLVM: %.splatinsert17 = insertelement <4 x float> poison, float %44, i64 0 ; CHECK-LLVM: %.splat18 = shufflevector <4 x float> %.splatinsert17, <4 x float> poison, <4 x i32> zeroinitializer ; CHECK-LLVM: %45 = extractvalue [4 x <4 x float>] %1, 1 ; CHECK-LLVM: %46 = fmul <4 x float> %.splat18, %45 ; CHECK-LLVM: %47 = fadd <4 x float> %43, %46 ; CHECK-LLVM: %48 = extractelement <4 x float> %39, i32 2 ; CHECK-LLVM: %.splatinsert19 = insertelement <4 x float> poison, float %48, i64 0 ; CHECK-LLVM: %.splat20 = shufflevector <4 x float> %.splatinsert19, <4 x float> poison, <4 x i32> zeroinitializer ; CHECK-LLVM: %49 = extractvalue [4 x <4 x float>] %1, 2 ; CHECK-LLVM: %50 = fmul <4 x float> %.splat20, %49 ; CHECK-LLVM: %51 = fadd <4 x float> %47, %50 ; CHECK-LLVM: %52 = extractelement <4 x float> %39, i32 3 ; CHECK-LLVM: %.splatinsert21 = insertelement <4 x float> poison, float %52, i64 0 ; CHECK-LLVM: %.splat22 = shufflevector <4 x float> %.splatinsert21, <4 x float> poison, <4 x i32> zeroinitializer ; CHECK-LLVM: %53 = extractvalue [4 x <4 x float>] %1, 3 ; CHECK-LLVM: %54 = fmul <4 x float> %.splat22, %53 ; CHECK-LLVM: %55 = fadd <4 x float> %51, %54 ; CHECK-LLVM: %56 = insertvalue [4 x <4 x float>] %38, <4 x float> %55, 2 ; CHECK-LLVM: %57 = extractvalue [4 x <4 x float>] %2, 3 ; CHECK-LLVM: %58 = extractelement <4 x float> %57, i32 0 ; CHECK-LLVM: %.splatinsert23 = insertelement <4 x float> poison, float %58, i64 0 ; CHECK-LLVM: %.splat24 = shufflevector <4 x float> %.splatinsert23, <4 x float> poison, <4 x i32> zeroinitializer ; CHECK-LLVM: %59 = extractvalue [4 x <4 x float>] %1, 0 ; CHECK-LLVM: %60 = fmul <4 x float> %.splat24, %59 ; CHECK-LLVM: %61 = fadd <4 x float> zeroinitializer, %60 ; CHECK-LLVM: %62 = extractelement <4 x float> %57, i32 1 ; CHECK-LLVM: %.splatinsert25 = insertelement <4 x float> poison, float %62, i64 0 ; CHECK-LLVM: %.splat26 = shufflevector <4 x float> %.splatinsert25, <4 x float> poison, <4 x i32> zeroinitializer ; CHECK-LLVM: %63 = extractvalue [4 x <4 x float>] %1, 1 ; CHECK-LLVM: %64 = fmul <4 x float> %.splat26, %63 ; CHECK-LLVM: %65 = fadd <4 x float> %61, %64 ; CHECK-LLVM: %66 = extractelement <4 x float> %57, i32 2 ; CHECK-LLVM: %.splatinsert27 = insertelement <4 x float> poison, float %66, i64 0 ; CHECK-LLVM: %.splat28 = shufflevector <4 x float> %.splatinsert27, <4 x float> poison, <4 x i32> zeroinitializer ; CHECK-LLVM: %67 = extractvalue [4 x <4 x float>] %1, 2 ; CHECK-LLVM: %68 = fmul <4 x float> %.splat28, %67 ; CHECK-LLVM: %69 = fadd <4 x float> %65, %68 ; CHECK-LLVM: %70 = extractelement <4 x float> %57, i32 3 ; CHECK-LLVM: %.splatinsert29 = insertelement <4 x float> poison, float %70, i64 0 ; CHECK-LLVM: %.splat30 = shufflevector <4 x float> %.splatinsert29, <4 x float> poison, <4 x i32> zeroinitializer ; CHECK-LLVM: %71 = extractvalue [4 x <4 x float>] %1, 3 ; CHECK-LLVM: %72 = fmul <4 x float> %.splat30, %71 ; CHECK-LLVM: %73 = fadd <4 x float> %69, %72 ; CHECK-LLVM: %74 = insertvalue [4 x <4 x float>] %56, <4 x float> %73, 3 ; CHECK-LLVM: store [4 x <4 x float>] %74, ptr %res ; CHECK-LLVM: ret void