48 lines · plain
1; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s2; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}3 4%struct.ST = type { i32, i32, i32 }5 6; CHECK-DAG: OpName %[[#struct:]] "struct.ST"7; CHECK-DAG: %[[#int:]] = OpTypeInt 32 08; CHECK-DAG: %[[#struct]] = OpTypeStruct %[[#int]] %[[#int]] %[[#int]]9; CHECK-DAG: %[[#structP:]] = OpTypePointer Function %[[#struct]]10; CHECK-DAG: %[[#intP:]] = OpTypePointer Function %[[#int]]11; CHECK-DAG: %[[#zero:]] = OpConstantNull %[[#int]]12; CHECK-DAG: %[[#one:]] = OpConstant %[[#int]] 1{{$}}13; CHECK-DAG: %[[#two:]] = OpConstant %[[#int]] 2{{$}}14; CHECK-DAG: %[[#three:]] = OpConstant %[[#int]] 3{{$}}15 16define dso_local spir_func i32 @func() {17entry:18; CHECK-SPIRV: %[[#st:]] = OpVariable %[[#structP]]19 %st = alloca %struct.ST, align 420; CHECK-SPIRV: %[[#a:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#st]] %[[#zero]] %[[#zero]]21; CHECK-SPIRV: OpStore %[[#a]] %[[#one]]22 %a = getelementptr inbounds %struct.ST, %struct.ST* %st, i32 0, i32 023 store i32 1, i32* %a, align 424; CHECK-SPIRV: %[[#b:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#st]] %[[#zero]] %[[#one]]25; CHECK-SPIRV: OpStore %[[#b]] %[[#two]]26 %b = getelementptr inbounds %struct.ST, %struct.ST* %st, i32 0, i32 127 store i32 2, i32* %b, align 428; CHECK-SPIRV: %[[#c:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#st]] %[[#zero]] %[[#two]]29; CHECK-SPIRV: OpStore %[[#c]] %[[#three]]30 %c = getelementptr inbounds %struct.ST, %struct.ST* %st, i32 0, i32 231 store i32 3, i32* %c, align 432; CHECK-SPIRV: %[[#a1:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#st]] %[[#zero]] %[[#zero]]33; CHECK-SPIRV: %[[#]] = OpLoad %[[#int]] %[[#a1]]34 %a1 = getelementptr inbounds %struct.ST, %struct.ST* %st, i32 0, i32 035 %0 = load i32, i32* %a1, align 436; CHECK-SPIRV: %[[#b1:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#st]] %[[#zero]] %[[#one]]37; CHECK-SPIRV: %[[#]] = OpLoad %[[#int]] %[[#b1]]38 %b2 = getelementptr inbounds %struct.ST, %struct.ST* %st, i32 0, i32 139 %1 = load i32, i32* %b2, align 440 %add = add nsw i32 %0, %141; CHECK-SPIRV: %[[#c1:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#st]] %[[#zero]] %[[#two]]42; CHECK-SPIRV: %[[#]] = OpLoad %[[#int]] %[[#c1]]43 %c3 = getelementptr inbounds %struct.ST, %struct.ST* %st, i32 0, i32 244 %2 = load i32, i32* %c3, align 445 %add4 = add nsw i32 %add, %246 ret i32 %add447}48