| 1 |
; RUN: llc -verify-machineinstrs -O3 -mtriple=spirv1.6-unknown-vulkan1.3-compute %s -o - | FileCheck %s |
| 2 |
; RUN: %if spirv-tools %{ llc -O3 -mtriple=spirv1.6-unknown-vulkan1.3-compute %s -o - -filetype=obj | spirv-val %} |
| 3 |
|
| 4 |
%struct.S1 = type { <4 x i32>, [10 x <4 x float>], <4 x float> } |
| 5 |
%struct.S2 = type { <4 x float>, <4 x i32> } |
| 6 |
|
| 7 |
@.str = private unnamed_addr constant [3 x i8] c"In\00", align 1 |
| 8 |
|
| 9 |
define <4 x float> @main() { |
| 10 |
entry: |
| 11 |
%0 = tail call target("spirv.VulkanBuffer", [0 x %struct.S1], 12, 0) @llvm.spv.resource.handlefrombinding.tspirv.VulkanBuffer_a0s_struct.S1s_12_0t(i32 0, i32 1, i32 1, i32 0, ptr nonnull @.str) |
| 12 |
%3 = tail call noundef align 1 dereferenceable(192) ptr addrspace(11) @llvm.spv.resource.getpointer.p11.tspirv.VulkanBuffer_a0s_struct.S1s_12_0t(target("spirv.VulkanBuffer", [0 x %struct.S1], 12, 0) %0, i32 0) |
| 13 |
|
| 14 |
; CHECK-DAG: %[[#ulong:]] = OpTypeInt 64 0 |
| 15 |
; CHECK-DAG: %[[#ulong_1:]] = OpConstant %[[#ulong]] 1 |
| 16 |
; CHECK-DAG: %[[#ulong_3:]] = OpConstant %[[#ulong]] 3 |
| 17 |
|
| 18 |
; CHECK-DAG: %[[#uint:]] = OpTypeInt 32 0 |
| 19 |
; CHECK-DAG: %[[#uint_0:]] = OpConstant %[[#uint]] 0 |
| 20 |
; CHECK-DAG: %[[#uint_10:]] = OpConstant %[[#uint]] 10 |
| 21 |
|
| 22 |
; CHECK-DAG: %[[#float:]] = OpTypeFloat 32 |
| 23 |
; CHECK-DAG: %[[#v4f:]] = OpTypeVector %[[#float]] 4 |
| 24 |
; CHECK-DAG: %[[#arr_v4f:]] = OpTypeArray %[[#v4f]] %[[#uint_10]] |
| 25 |
; CHECK-DAG: %[[#S1:]] = OpTypeStruct %[[#]] %[[#arr_v4f]] %[[#]] |
| 26 |
; CHECK-DAG: %[[#sb_S1:]] = OpTypePointer StorageBuffer %[[#S1]] |
| 27 |
; CHECK-DAG: %[[#sb_v4f:]] = OpTypePointer StorageBuffer %[[#v4f]] |
| 28 |
|
| 29 |
; CHECK: %[[#tmp:]] = OpAccessChain %[[#sb_S1]] %[[#]] %[[#uint_0]] %[[#uint_0]] |
| 30 |
; CHECK: %[[#ptr:]] = OpInBoundsAccessChain %[[#sb_v4f]] %[[#tmp]] %[[#ulong_1]] %[[#ulong_3]] |
| 31 |
; This rewritten GEP combined all constant indices into a single value. |
| 32 |
; We should make sure the correct indices are retrieved. |
| 33 |
%arrayidx.i = getelementptr inbounds nuw i8, ptr addrspace(11) %3, i64 64 |
| 34 |
|
| 35 |
; CHECK: OpLoad %[[#v4f]] %[[#ptr]] |
| 36 |
%4 = load <4 x float>, ptr addrspace(11) %arrayidx.i, align 1 |
| 37 |
|
| 38 |
ret <4 x float> %4 |
| 39 |
} |
| 40 |
|
| 41 |
declare i32 @llvm.spv.flattened.thread.id.in.group() |
| 42 |
declare target("spirv.VulkanBuffer", [0 x %struct.S1], 12, 0) @llvm.spv.resource.handlefrombinding.tspirv.VulkanBuffer_a0s_struct.S1s_12_0t(i32, i32, i32, i32, ptr) |
| 43 |
declare ptr addrspace(11) @llvm.spv.resource.getpointer.p11.tspirv.VulkanBuffer_a0s_struct.S1s_12_0t(target("spirv.VulkanBuffer", [0 x %struct.S1], 12, 0), i32) |
| 44 |
|
| 45 |
attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" } |
| 46 |
|