xref: /llvm-project/llvm/test/CodeGen/SPIRV/hlsl-resources/StorageImageNonUniformIdx.ll (revision 4b692a95d103f3ad30d6be1ce6d5dda0bd90bc1f)
1; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv1.5-vulkan-library %s -o - | FileCheck %s
2; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv1.5-vulkan-library %s -o - -filetype=obj | spirv-val %}
3
4; CHECK: OpCapability Shader
5; CHECK: OpCapability ShaderNonUniformEXT
6; CHECK-NEXT: OpCapability StorageImageArrayNonUniformIndexing
7; CHECK-NEXT: OpCapability Image1D
8; CHECK-NOT: OpCapability
9
10; CHECK-DAG: OpDecorate [[Var:%[0-9]+]] DescriptorSet 3
11; CHECK-DAG: OpDecorate [[Var]] Binding 4
12; CHECK: OpDecorate [[Zero:%[0-9]+]] NonUniform
13; CHECK: OpDecorate [[ac0:%[0-9]+]] NonUniform
14; CHECK: OpDecorate [[ld0:%[0-9]+]] NonUniform
15; CHECK: OpDecorate [[One:%[0-9]+]] NonUniform
16; CHECK: OpDecorate [[ac1:%[0-9]+]] NonUniform
17; CHECK: OpDecorate [[ld1:%[0-9]+]] NonUniform
18
19; CHECK-DAG: [[int:%[0-9]+]] = OpTypeInt 32 0
20; CHECK-DAG: [[BufferType:%[0-9]+]] = OpTypeImage [[int]] 1D 2 0 0 2 R32i {{$}}
21; CHECK-DAG: [[BufferPtrType:%[0-9]+]] = OpTypePointer UniformConstant [[BufferType]]
22; CHECK-DAG: [[ArraySize:%[0-9]+]] = OpConstant [[int]] 3
23; CHECK-DAG: [[One]] = OpConstant [[int]] 1
24; CHECK-DAG: [[Zero]] = OpConstant [[int]] 0
25; CHECK-DAG: [[BufferArrayType:%[0-9]+]] = OpTypeArray [[BufferType]] [[ArraySize]]
26; CHECK-DAG: [[ArrayPtrType:%[0-9]+]] = OpTypePointer UniformConstant [[BufferArrayType]]
27; CHECK-DAG: [[Var]] = OpVariable [[ArrayPtrType]] UniformConstant
28
29; CHECK: {{%[0-9]+}} = OpFunction {{%[0-9]+}} DontInline {{%[0-9]+}}
30; CHECK-NEXT: OpLabel
31define void @main() #0 {
32; CHECK: [[ac0]] = OpAccessChain [[BufferPtrType]] [[Var]] [[Zero]]
33; CHECK: [[ld0]] = OpLoad [[BufferType]] [[ac0]]
34  %buffer0 = call target("spirv.Image", i32, 0, 2, 0, 0, 2, 24)
35      @llvm.spv.resource.handlefrombinding.tspirv.Image_f32_0_2_0_0_2_24(
36          i32 3, i32 4, i32 3, i32 0, i1 true)
37  %ptr0 = tail call noundef nonnull align 4 dereferenceable(4) ptr @llvm.spv.resource.getpointer.p0.tspirv.Image_f32_5_2_0_0_2_0t(target("spirv.Image", i32, 0, 2, 0, 0, 2, 24) %buffer0, i32 0)
38  store i32 0, ptr %ptr0, align 4
39
40; CHECK: [[ac1:%[0-9]+]] = OpAccessChain [[BufferPtrType]] [[Var]] [[One]]
41; CHECK: [[ld1]] = OpLoad [[BufferType]] [[ac1]]
42  %buffer1 = call target("spirv.Image", i32, 0, 2, 0, 0, 2, 24)
43      @llvm.spv.resource.handlefrombinding.tspirv.Image_f32_0_2_0_0_2_24(
44          i32 3, i32 4, i32 3, i32 1, i1 true)
45  %ptr1 = tail call noundef nonnull align 4 dereferenceable(4) ptr @llvm.spv.resource.getpointer.p0.tspirv.Image_f32_5_2_0_0_2_0t(target("spirv.Image", i32, 0, 2, 0, 0, 2, 24) %buffer1, i32 0)
46  store i32 0, ptr %ptr1, align 4
47  ret void
48}
49
50attributes #0 = { convergent noinline norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
51