| 1 |
; ModuleID = '' |
| 2 |
target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" |
| 3 |
target triple = "spir-unknown-unknown" |
| 4 |
|
| 5 |
; RUN: llvm-as %s -o %t.bc |
| 6 |
; RUN: llvm-spirv %t.bc -spirv-text -o %t.spt |
| 7 |
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV |
| 8 |
; RUN: llvm-spirv %t.bc -o %t.spv |
| 9 |
; RUN: spirv-val %t.spv |
| 10 |
; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.bc |
| 11 |
; RUN: llvm-dis < %t.bc | FileCheck %s --check-prefix=CHECK-LLVM |
| 12 |
|
| 13 |
; Check 'LLVM ==> SPIR-V ==> LLVM' conversion of extractvalue/insertvalue. |
| 14 |
|
| 15 |
%struct.arr = type { [7 x float] } |
| 16 |
%struct.st = type { %struct.inner } |
| 17 |
%struct.inner = type { float } |
| 18 |
; CHECK-LLVM: %struct.arr = type { [7 x float] } |
| 19 |
; CHECK-LLVM: %struct.st = type { %struct.inner } |
| 20 |
; CHECK-LLVM: %struct.inner = type { float } |
| 21 |
|
| 22 |
; CHECK-LLVM: define spir_func void @array_test |
| 23 |
; CHECK-LLVM-LABEL: entry |
| 24 |
; CHECK-LLVM: %0 = getelementptr inbounds %struct.arr, ptr addrspace(1) %object, i32 0, i32 0 |
| 25 |
; CHECK-LLVM: %1 = load [7 x float], ptr addrspace(1) %0, align 4 |
| 26 |
; CHECK-LLVM: %2 = extractvalue [7 x float] %1, 4 |
| 27 |
; CHECK-LLVM: %3 = extractvalue [7 x float] %1, 2 |
| 28 |
; CHECK-LLVM: %4 = fadd float %2, %3 |
| 29 |
; CHECK-LLVM: %5 = insertvalue [7 x float] %1, float %4, 5 |
| 30 |
; CHECK-LLVM: store [7 x float] %5, ptr addrspace(1) %0 |
| 31 |
|
| 32 |
; CHECK-SPIRV-LABEL: 5 Function |
| 33 |
; CHECK-SPIRV-NEXT: FunctionParameter {{[0-9]+}} [[object:[0-9]+]] |
| 34 |
; CHECK-SPIRV: 6 InBoundsPtrAccessChain {{[0-9]+}} {{[0-9]+}} [[object]] {{[0-9]+}} {{[0-9]+}} |
| 35 |
; CHECK-SPIRV: 6 Load {{[0-9]+}} [[extracted_array:[0-9]+]] {{[0-9]+}} {{[0-9]+}} 4 |
| 36 |
; CHECK-SPIRV: 5 CompositeExtract {{[0-9]+}} [[elem_4:[0-9]+]] [[extracted_array]] 4 |
| 37 |
; CHECK-SPIRV: 5 CompositeExtract {{[0-9]+}} [[elem_2:[0-9]+]] [[extracted_array]] 2 |
| 38 |
; CHECK-SPIRV: 5 FAdd {{[0-9]+}} [[add:[0-9]+]] [[elem_4]] [[elem_2]] |
| 39 |
; CHECK-SPIRV: 6 CompositeInsert {{[0-9]+}} [[inserted_array:[0-9]+]] [[add]] [[extracted_array]] 5 |
| 40 |
; CHECK-SPIRV: 5 Store {{[0-9]+}} [[inserted_array]] |
| 41 |
; CHECK-SPIRV-LABEL: 1 FunctionEnd |
| 42 |
|
| 43 |
; Function Attrs: nounwind |
| 44 |
define spir_func void @array_test(%struct.arr addrspace(1)* %object) #0 { |
| 45 |
entry: |
| 46 |
%0 = getelementptr inbounds %struct.arr, %struct.arr addrspace(1)* %object, i32 0, i32 0 |
| 47 |
%1 = load [7 x float], [7 x float] addrspace(1)* %0, align 4 |
| 48 |
%2 = extractvalue [7 x float] %1, 4 |
| 49 |
%3 = extractvalue [7 x float] %1, 2 |
| 50 |
%4 = fadd float %2, %3 |
| 51 |
%5 = insertvalue [7 x float] %1, float %4, 5 |
| 52 |
store [7 x float] %5, [7 x float] addrspace(1)* %0 |
| 53 |
ret void |
| 54 |
} |
| 55 |
|
| 56 |
; CHECK-LLVM: define spir_func void @struct_test |
| 57 |
; CHECK-LLVM-LABEL: entry |
| 58 |
; CHECK-LLVM: %0 = getelementptr inbounds %struct.st, ptr addrspace(1) %object, i32 0, i32 0 |
| 59 |
; CHECK-LLVM: %1 = load %struct.inner, ptr addrspace(1) %0, align 4 |
| 60 |
; CHECK-LLVM: %2 = extractvalue %struct.inner %1, 0 |
| 61 |
; CHECK-LLVM: %3 = fadd float %2, 1.000000e+00 |
| 62 |
; CHECK-LLVM: %4 = insertvalue %struct.inner %1, float %3, 0 |
| 63 |
; CHECK-LLVM: store %struct.inner %4, ptr addrspace(1) %0 |
| 64 |
|
| 65 |
; CHECK-SPIRV-LABEL: 5 Function |
| 66 |
; CHECK-SPIRV-NEXT: FunctionParameter {{[0-9]+}} [[object:[0-9]+]] |
| 67 |
; CHECK-SPIRV: 6 InBoundsPtrAccessChain {{[0-9]+}} {{[0-9]+}} [[object]] {{[0-9]+}} {{[0-9]+}} |
| 68 |
; CHECK-SPIRV: 6 Load {{[0-9]+}} [[extracted_struct:[0-9]+]] {{[0-9]+}} {{[0-9]+}} 4 |
| 69 |
; CHECK-SPIRV: 5 CompositeExtract {{[0-9]+}} [[elem:[0-9]+]] [[extracted_struct]] 0 |
| 70 |
; CHECK-SPIRV: 5 FAdd {{[0-9]+}} [[add:[0-9]+]] [[elem]] {{[0-9]+}} |
| 71 |
; CHECK-SPIRV: 6 CompositeInsert {{[0-9]+}} [[inserted_struct:[0-9]+]] [[add]] [[extracted_struct]] 0 |
| 72 |
; CHECK-SPIRV: 5 Store {{[0-9]+}} [[inserted_struct]] |
| 73 |
; CHECK-SPIRV-LABEL: 1 FunctionEnd |
| 74 |
|
| 75 |
; Function Attrs: nounwind |
| 76 |
define spir_func void @struct_test(%struct.st addrspace(1)* %object) #0 { |
| 77 |
entry: |
| 78 |
%0 = getelementptr inbounds %struct.st, %struct.st addrspace(1)* %object, i32 0, i32 0 |
| 79 |
%1 = load %struct.inner, %struct.inner addrspace(1)* %0, align 4 |
| 80 |
%2 = extractvalue %struct.inner %1, 0 |
| 81 |
%3 = fadd float %2, 1.000000e+00 |
| 82 |
%4 = insertvalue %struct.inner %1, float %3, 0 |
| 83 |
store %struct.inner %4, %struct.inner addrspace(1)* %0 |
| 84 |
ret void |
| 85 |
} |
| 86 |
|
| 87 |
attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 88 |
|
| 89 |
!opencl.enable.FP_CONTRACT = !{} |
| 90 |
!opencl.spir.version = !{!0} |
| 91 |
!opencl.ocl.version = !{!0} |
| 92 |
!opencl.used.extensions = !{!1} |
| 93 |
!opencl.used.optional.core.features = !{!1} |
| 94 |
!opencl.compiler.options = !{!1} |
| 95 |
|
| 96 |
!0 = !{i32 1, i32 2} |
| 97 |
!1 = !{} |