1 ; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
3 ; CHECK-SPIRV: OpName %[[#v:]] "v"
4 ; CHECK-SPIRV: OpName %[[#index:]] "index"
5 ; CHECK-SPIRV: OpName %[[#res:]] "res"
7 ; CHECK-SPIRV-DAG: %[[#int16:]] = OpTypeInt 16
8 ; CHECK-SPIRV-DAG: %[[#int32:]] = OpTypeInt 32
9 ; CHECK-SPIRV-DAG: %[[#int16_2:]] = OpTypeVector %[[#int16]] 2
11 ; CHECK-SPIRV: %[[#undef:]] = OpUndef %[[#int16_2]]
13 ; CHECK-SPIRV-DAG: %[[#const1:]] = OpConstant %[[#int16]] 4
14 ; CHECK-SPIRV-DAG: %[[#const2:]] = OpConstant %[[#int16]] 8
15 ; CHECK-SPIRV-NOT: %[[#idx1:]] = OpConstant %[[#int32]] 0
16 ; CHECK-SPIRV-NOT: %[[#idx2:]] = OpConstant %[[#int32]] 1
18 ; CHECK-SPIRV: %[[#vec1:]] = OpCompositeInsert %[[#int16_2]] %[[#const1]] %[[#undef]] 0
19 ; CHECK-SPIRV: %[[#vec2:]] = OpCompositeInsert %[[#int16_2]] %[[#const2]] %[[#vec1]] 1
20 ; CHECK-SPIRV: %[[#res]] = OpVectorInsertDynamic %[[#int16_2]] %[[#vec2]] %[[#v]] %[[#index]]
22 define spir_kernel void @test(<2 x i16>* nocapture %out, i16 %v, i32 %index) {
24 %vec1 = insertelement <2 x i16> undef, i16 4, i32 0
25 %vec2 = insertelement <2 x i16> %vec1, i16 8, i32 1
26 %res = insertelement <2 x i16> %vec2, i16 %v, i32 %index
27 store <2 x i16> %res, <2 x i16>* %out, align 4