1 ; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
3 %struct.ST = type { i32, i32, i32 }
5 ; CHECK-DAG: OpName %[[#struct:]] "struct.ST"
6 ; CHECK-DAG: %[[#int:]] = OpTypeInt 32 0
7 ; CHECK-DAG: %[[#struct]] = OpTypeStruct %[[#int]] %[[#int]] %[[#int]]
8 ; CHECK-DAG: %[[#structP:]] = OpTypePointer Function %[[#struct]]
9 ; CHECK-DAG: %[[#intP:]] = OpTypePointer Function %[[#int]]
10 ; CHECK-DAG: %[[#zero:]] = OpConstant %[[#int]] 0
11 ; CHECK-DAG: %[[#one:]] = OpConstant %[[#int]] 1
12 ; CHECK-DAG: %[[#two:]] = OpConstant %[[#int]] 2
13 ; CHECK-DAG: %[[#three:]] = OpConstant %[[#int]] 3
15 define dso_local spir_func i32 @func() {
17 ; CHECK-SPIRV: %[[#st:]] = OpVariable %[[#structP]]
18 %st = alloca %struct.ST, align 4
19 ; CHECK-SPIRV: %[[#a:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#st]] %[[#zero]] %[[#zero]]
20 ; CHECK-SPIRV: OpStore %[[#a]] %[[#one]]
21 %a = getelementptr inbounds %struct.ST, %struct.ST* %st, i32 0, i32 0
22 store i32 1, i32* %a, align 4
23 ; CHECK-SPIRV: %[[#b:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#st]] %[[#zero]] %[[#one]]
24 ; CHECK-SPIRV: OpStore %[[#b]] %[[#two]]
25 %b = getelementptr inbounds %struct.ST, %struct.ST* %st, i32 0, i32 1
26 store i32 2, i32* %b, align 4
27 ; CHECK-SPIRV: %[[#c:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#st]] %[[#zero]] %[[#two]]
28 ; CHECK-SPIRV: OpStore %[[#c]] %[[#three]]
29 %c = getelementptr inbounds %struct.ST, %struct.ST* %st, i32 0, i32 2
30 store i32 3, i32* %c, align 4
31 ; CHECK-SPIRV: %[[#a1:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#st]] %[[#zero]] %[[#zero]]
32 ; CHECK-SPIRV: %[[#]] = OpLoad %[[#int]] %[[#a1]]
33 %a1 = getelementptr inbounds %struct.ST, %struct.ST* %st, i32 0, i32 0
34 %0 = load i32, i32* %a1, align 4
35 ; CHECK-SPIRV: %[[#b1:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#st]] %[[#zero]] %[[#one]]
36 ; CHECK-SPIRV: %[[#]] = OpLoad %[[#int]] %[[#b1]]
37 %b2 = getelementptr inbounds %struct.ST, %struct.ST* %st, i32 0, i32 1
38 %1 = load i32, i32* %b2, align 4
39 %add = add nsw i32 %0, %1
40 ; CHECK-SPIRV: %[[#c1:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#st]] %[[#zero]] %[[#two]]
41 ; CHECK-SPIRV: %[[#]] = OpLoad %[[#int]] %[[#c1]]
42 %c3 = getelementptr inbounds %struct.ST, %struct.ST* %st, i32 0, i32 2
43 %2 = load i32, i32* %c3, align 4
44 %add4 = add nsw i32 %add, %2