| 1 |
; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv1.6-vulkan1.3-library %s -o - | FileCheck %s |
| 2 |
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv1.6-vulkan1.3-library %s -o - -filetype=obj | spirv-val --target-env vulkan1.3 %} |
| 3 |
|
| 4 |
@.str.b0 = private unnamed_addr constant [3 x i8] c"B0\00", align 1 |
| 5 |
|
| 6 |
; CHECK-DAG: [[uint:%[0-9]+]] = OpTypeInt 32 0 |
| 7 |
; CHECK-DAG: [[v2int:%[0-9]+]] = OpTypeVector [[uint]] 2 |
| 8 |
; CHECK-DAG: [[v4int:%[0-9]+]] = OpTypeVector [[uint]] 4 |
| 9 |
; CHECK-DAG: [[zero:%[0-9]+]] = OpConstant [[uint]] 0 |
| 10 |
; CHECK-DAG: [[one:%[0-9]+]] = OpConstant [[uint]] 1 |
| 11 |
; CHECK-DAG: [[twenty:%[0-9]+]] = OpConstant [[uint]] 20 |
| 12 |
; CHECK-DAG: [[twenty_three:%[0-9]+]] = OpConstant [[uint]] 23 |
| 13 |
; CHECK-DAG: [[ImageType:%[0-9]+]] = OpTypeImage [[uint]] Buffer 2 0 0 2 Unknown |
| 14 |
; CHECK-DAG: [[ImagePtr:%[0-9]+]] = OpTypePointer UniformConstant [[ImageType]] |
| 15 |
; CHECK-DAG: [[Var:%[0-9]+]] = OpVariable [[ImagePtr]] UniformConstant |
| 16 |
|
| 17 |
; Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) |
| 18 |
; CHECK: OpFunction |
| 19 |
define void @main_scalar() local_unnamed_addr #0 { |
| 20 |
entry: |
| 21 |
; CHECK: [[H:%[0-9]+]] = OpLoad [[ImageType]] [[Var]] |
| 22 |
%s_h.i = tail call target("spirv.Image", i32, 5, 2, 0, 0, 2, 0) @llvm.spv.resource.handlefrombinding.tspirv.Image_i32_5_2_0_0_2_0t(i32 3, i32 5, i32 1, i32 0, ptr nonnull @.str.b0) |
| 23 |
|
| 24 |
; CHECK: [[R:%[0-9]+]] = OpImageRead [[v4int]] [[H]] [[one]] |
| 25 |
; CHECK: [[V:%[0-9]+]] = OpCompositeExtract [[uint]] [[R]] 0 |
| 26 |
%0 = tail call noundef nonnull align 4 dereferenceable(4) ptr @llvm.spv.resource.getpointer.p0.tspirv.Image_i32_5_2_0_0_2_0t(target("spirv.Image", i32, 5, 2, 0, 0, 2, 0) %s_h.i, i32 1) |
| 27 |
%1 = load i32, ptr %0, align 4 |
| 28 |
; CHECK: OpBranch [[bb_store:%[0-9]+]] |
| 29 |
br label %bb_store |
| 30 |
|
| 31 |
; CHECK: [[bb_store]] = OpLabel |
| 32 |
bb_store: |
| 33 |
|
| 34 |
; CHECK: [[H:%[0-9]+]] = OpLoad [[ImageType]] [[Var]] |
| 35 |
; CHECK: OpImageWrite [[H]] [[zero]] [[V]] |
| 36 |
%2 = tail call noundef nonnull align 4 dereferenceable(4) ptr @llvm.spv.resource.getpointer.p0.tspirv.Image_i32_5_2_0_0_2_0t(target("spirv.Image", i32, 5, 2, 0, 0, 2, 0) %s_h.i, i32 0) |
| 37 |
store i32 %1, ptr %2, align 4 |
| 38 |
; CHECK: OpBranch [[bb_both:%[0-9]+]] |
| 39 |
br label %bb_both |
| 40 |
|
| 41 |
; CHECK: [[bb_both]] = OpLabel |
| 42 |
bb_both: |
| 43 |
; CHECK: [[H:%[0-9]+]] = OpLoad [[ImageType]] [[Var]] |
| 44 |
; CHECK: [[R:%[0-9]+]] = OpImageRead [[v4int]] [[H]] [[twenty_three]] |
| 45 |
; CHECK: [[V:%[0-9]+]] = OpCompositeExtract [[uint]] [[R]] 0 |
| 46 |
%3 = tail call noundef nonnull align 4 dereferenceable(4) ptr @llvm.spv.resource.getpointer.p0.tspirv.Image_i32_5_2_0_0_2_0t(target("spirv.Image", i32, 5, 2, 0, 0, 2, 0) %s_h.i, i32 23) |
| 47 |
%4 = load i32, ptr %3, align 4 |
| 48 |
|
| 49 |
; CHECK: [[H:%[0-9]+]] = OpLoad [[ImageType]] [[Var]] |
| 50 |
; CHECK: OpImageWrite [[H]] [[twenty]] [[V]] |
| 51 |
%5 = tail call noundef nonnull align 4 dereferenceable(4) ptr @llvm.spv.resource.getpointer.p0.tspirv.Image_i32_5_2_0_0_2_0t(target("spirv.Image", i32, 5, 2, 0, 0, 2, 0) %s_h.i, i32 20) |
| 52 |
store i32 %4, ptr %5, align 4 |
| 53 |
ret void |
| 54 |
} |
| 55 |
|
| 56 |
; Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) |
| 57 |
; CHECK: OpFunction |
| 58 |
define void @main_vector2() local_unnamed_addr #0 { |
| 59 |
entry: |
| 60 |
; CHECK: [[H:%[0-9]+]] = OpLoad [[ImageType]] [[Var]] |
| 61 |
%s_h.i = tail call target("spirv.Image", i32, 5, 2, 0, 0, 2, 0) @llvm.spv.resource.handlefrombinding.tspirv.Image_i32_5_2_0_0_2_0t(i32 3, i32 5, i32 1, i32 0, ptr nonnull @.str.b0) |
| 62 |
|
| 63 |
; CHECK: [[R:%[0-9]+]] = OpImageRead [[v4int]] [[H]] [[one]] |
| 64 |
; CHECK: [[E0:%[0-9]+]] = OpCompositeExtract [[uint]] [[R]] 0 |
| 65 |
; CHECK: [[E1:%[0-9]+]] = OpCompositeExtract [[uint]] [[R]] 1 |
| 66 |
; CHECK: [[V:%[0-9]+]] = OpCompositeConstruct [[v2int]] [[E0]] [[E1]] |
| 67 |
%0 = tail call noundef nonnull align 4 dereferenceable(4) ptr @llvm.spv.resource.getpointer.p0.tspirv.Image_i32_5_2_0_0_2_0t(target("spirv.Image", i32, 5, 2, 0, 0, 2, 0) %s_h.i, i32 1) |
| 68 |
%1 = load <2 x i32>, ptr %0, align 4 |
| 69 |
; CHECK: OpBranch [[bb_store:%[0-9]+]] |
| 70 |
br label %bb_store |
| 71 |
|
| 72 |
; CHECK: [[bb_store]] = OpLabel |
| 73 |
bb_store: |
| 74 |
|
| 75 |
; CHECK: [[H:%[0-9]+]] = OpLoad [[ImageType]] [[Var]] |
| 76 |
; CHECK: OpImageWrite [[H]] [[zero]] [[V]] |
| 77 |
%2 = tail call noundef nonnull align 4 dereferenceable(4) ptr @llvm.spv.resource.getpointer.p0.tspirv.Image_i32_5_2_0_0_2_0t(target("spirv.Image", i32, 5, 2, 0, 0, 2, 0) %s_h.i, i32 0) |
| 78 |
store <2 x i32> %1, ptr %2, align 4 |
| 79 |
; CHECK: OpBranch [[bb_both:%[0-9]+]] |
| 80 |
br label %bb_both |
| 81 |
|
| 82 |
; CHECK: [[bb_both]] = OpLabel |
| 83 |
bb_both: |
| 84 |
; CHECK: [[H:%[0-9]+]] = OpLoad [[ImageType]] [[Var]] |
| 85 |
; CHECK: [[R:%[0-9]+]] = OpImageRead [[v4int]] [[H]] [[twenty_three]] |
| 86 |
; CHECK: [[E0:%[0-9]+]] = OpCompositeExtract [[uint]] [[R]] 0 |
| 87 |
; CHECK: [[E1:%[0-9]+]] = OpCompositeExtract [[uint]] [[R]] 1 |
| 88 |
; CHECK: [[V:%[0-9]+]] = OpCompositeConstruct [[v2int]] [[E0]] [[E1]] |
| 89 |
%3 = tail call noundef nonnull align 4 dereferenceable(4) ptr @llvm.spv.resource.getpointer.p0.tspirv.Image_i32_5_2_0_0_2_0t(target("spirv.Image", i32, 5, 2, 0, 0, 2, 0) %s_h.i, i32 23) |
| 90 |
%4 = load <2 x i32>, ptr %3, align 4 |
| 91 |
|
| 92 |
; CHECK: [[H:%[0-9]+]] = OpLoad [[ImageType]] [[Var]] |
| 93 |
; CHECK: OpImageWrite [[H]] [[twenty]] [[V]] |
| 94 |
%5 = tail call noundef nonnull align 4 dereferenceable(4) ptr @llvm.spv.resource.getpointer.p0.tspirv.Image_i32_5_2_0_0_2_0t(target("spirv.Image", i32, 5, 2, 0, 0, 2, 0) %s_h.i, i32 20) |
| 95 |
store <2 x i32> %4, ptr %5, align 4 |
| 96 |
ret void |
| 97 |
} |
| 98 |
|
| 99 |
; Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) |
| 100 |
; CHECK: OpFunction |
| 101 |
define void @main_vector4() local_unnamed_addr #0 { |
| 102 |
entry: |
| 103 |
; CHECK: [[H:%[0-9]+]] = OpLoad [[ImageType]] [[Var]] |
| 104 |
%s_h.i = tail call target("spirv.Image", i32, 5, 2, 0, 0, 2, 0) @llvm.spv.resource.handlefrombinding.tspirv.Image_i32_5_2_0_0_2_0t(i32 3, i32 5, i32 1, i32 0, ptr nonnull @.str.b0) |
| 105 |
|
| 106 |
; CHECK: [[R:%[0-9]+]] = OpImageRead [[v4int]] [[H]] [[one]] |
| 107 |
%0 = tail call noundef nonnull align 4 dereferenceable(4) ptr @llvm.spv.resource.getpointer.p0.tspirv.Image_i32_5_2_0_0_2_0t(target("spirv.Image", i32, 5, 2, 0, 0, 2, 0) %s_h.i, i32 1) |
| 108 |
%1 = load <4 x i32>, ptr %0, align 4 |
| 109 |
; CHECK: OpBranch [[bb_store:%[0-9]+]] |
| 110 |
br label %bb_store |
| 111 |
|
| 112 |
; CHECK: [[bb_store]] = OpLabel |
| 113 |
bb_store: |
| 114 |
|
| 115 |
; CHECK: [[H:%[0-9]+]] = OpLoad [[ImageType]] [[Var]] |
| 116 |
; CHECK: OpImageWrite [[H]] [[zero]] [[R]] |
| 117 |
%2 = tail call noundef nonnull align 4 dereferenceable(4) ptr @llvm.spv.resource.getpointer.p0.tspirv.Image_i32_5_2_0_0_2_0t(target("spirv.Image", i32, 5, 2, 0, 0, 2, 0) %s_h.i, i32 0) |
| 118 |
store <4 x i32> %1, ptr %2, align 4 |
| 119 |
; CHECK: OpBranch [[bb_both:%[0-9]+]] |
| 120 |
br label %bb_both |
| 121 |
|
| 122 |
; CHECK: [[bb_both]] = OpLabel |
| 123 |
bb_both: |
| 124 |
; CHECK: [[H:%[0-9]+]] = OpLoad [[ImageType]] [[Var]] |
| 125 |
; CHECK: [[R:%[0-9]+]] = OpImageRead [[v4int]] [[H]] [[twenty_three]] |
| 126 |
%3 = tail call noundef nonnull align 4 dereferenceable(4) ptr @llvm.spv.resource.getpointer.p0.tspirv.Image_i32_5_2_0_0_2_0t(target("spirv.Image", i32, 5, 2, 0, 0, 2, 0) %s_h.i, i32 23) |
| 127 |
%4 = load <4 x i32>, ptr %3, align 4 |
| 128 |
|
| 129 |
; CHECK: [[H:%[0-9]+]] = OpLoad [[ImageType]] [[Var]] |
| 130 |
; CHECK: OpImageWrite [[H]] [[twenty]] [[R]] |
| 131 |
%5 = tail call noundef nonnull align 4 dereferenceable(4) ptr @llvm.spv.resource.getpointer.p0.tspirv.Image_i32_5_2_0_0_2_0t(target("spirv.Image", i32, 5, 2, 0, 0, 2, 0) %s_h.i, i32 20) |
| 132 |
store <4 x i32> %4, ptr %5, align 4 |
| 133 |
ret void |
| 134 |
} |
| 135 |
|
| 136 |
attributes #0 = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } |
| 137 |
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(none) } |