|
2 | 2 | ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-vulkan-library %s -o - -filetype=obj | spirv-val %}
|
3 | 3 |
|
4 | 4 | ; CHECK-DAG: [[float:%[0-9]+]] = OpTypeFloat 32
|
| 5 | +; CHECK-DAG: [[v2float:%[0-9]+]] = OpTypeVector [[float]] 2 |
5 | 6 | ; CHECK-DAG: [[v4float:%[0-9]+]] = OpTypeVector [[float]] 4
|
6 | 7 | ; CHECK-DAG: [[int:%[0-9]+]] = OpTypeInt 32 0
|
7 | 8 | ; CHECK-DAG: [[zero:%[0-9]+]] = OpConstant [[int]] 0
|
|
10 | 11 | ; CHECK-DAG: [[twenty_three:%[0-9]+]] = OpConstant [[int]] 23
|
11 | 12 | ; CHECK-DAG: [[ImageType:%[0-9]+]] = OpTypeImage [[float]] Buffer 2 0 0 2 Rgba32f
|
12 | 13 | ; CHECK-DAG: [[ImagePtr:%[0-9]+]] = OpTypePointer UniformConstant [[ImageType]]
|
13 |
| -; CHECK: [[Var:%[0-9]+]] = OpVariable [[ImagePtr]] UniformConstant |
| 14 | +; CHECK-DAG: [[Var:%[0-9]+]] = OpVariable [[ImagePtr]] UniformConstant |
14 | 15 |
|
15 | 16 | ; Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none)
|
16 |
| -define void @main() local_unnamed_addr #0 { |
| 17 | +; CHECK: OpFunction |
| 18 | +define void @main_scalar() local_unnamed_addr #0 { |
17 | 19 | entry:
|
18 | 20 | ; CHECK: [[H:%[0-9]+]] = OpLoad [[ImageType]] [[Var]]
|
19 | 21 | %s_h.i = tail call target("spirv.Image", float, 5, 2, 0, 0, 2, 1) @llvm.spv.resource.handlefrombinding.tspirv.Image_f32_5_2_0_0_2_0t(i32 3, i32 5, i32 1, i32 0, i1 false)
|
@@ -50,6 +52,86 @@ bb_both:
|
50 | 52 | ret void
|
51 | 53 | }
|
52 | 54 |
|
| 55 | +; Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) |
| 56 | +; CHECK: OpFunction |
| 57 | +define void @main_vector2() local_unnamed_addr #0 { |
| 58 | +entry: |
| 59 | +; CHECK: [[H:%[0-9]+]] = OpLoad [[ImageType]] [[Var]] |
| 60 | + %s_h.i = tail call target("spirv.Image", float, 5, 2, 0, 0, 2, 1) @llvm.spv.resource.handlefrombinding.tspirv.Image_f32_5_2_0_0_2_0t(i32 3, i32 5, i32 1, i32 0, i1 false) |
| 61 | + |
| 62 | +; CHECK: [[R:%[0-9]+]] = OpImageRead [[v4float]] [[H]] [[one]] |
| 63 | +; CHECK: [[E0:%[0-9]+]] = OpCompositeExtract [[float]] [[R]] 0 |
| 64 | +; CHECK: [[E1:%[0-9]+]] = OpCompositeExtract [[float]] [[R]] 1 |
| 65 | +; CHECK: [[V:%[0-9]+]] = OpCompositeConstruct [[v2float]] [[E0]] [[E1]] |
| 66 | + %0 = 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", float, 5, 2, 0, 0, 2, 1) %s_h.i, i32 1) |
| 67 | + %1 = load <2 x float>, ptr %0, align 4 |
| 68 | +; CHECK: OpBranch [[bb_store:%[0-9]+]] |
| 69 | + br label %bb_store |
| 70 | + |
| 71 | +; CHECK: [[bb_store]] = OpLabel |
| 72 | +bb_store: |
| 73 | + |
| 74 | +; CHECK: [[H:%[0-9]+]] = OpLoad [[ImageType]] [[Var]] |
| 75 | +; CHECK: OpImageWrite [[H]] [[zero]] [[V]] |
| 76 | + %2 = 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", float, 5, 2, 0, 0, 2, 1) %s_h.i, i32 0) |
| 77 | + store <2 x float> %1, ptr %2, align 4 |
| 78 | +; CHECK: OpBranch [[bb_both:%[0-9]+]] |
| 79 | + br label %bb_both |
| 80 | + |
| 81 | +; CHECK: [[bb_both]] = OpLabel |
| 82 | +bb_both: |
| 83 | +; CHECK: [[H:%[0-9]+]] = OpLoad [[ImageType]] [[Var]] |
| 84 | +; CHECK: [[R:%[0-9]+]] = OpImageRead [[v4float]] [[H]] [[twenty_three]] |
| 85 | +; CHECK: [[E0:%[0-9]+]] = OpCompositeExtract [[float]] [[R]] 0 |
| 86 | +; CHECK: [[E1:%[0-9]+]] = OpCompositeExtract [[float]] [[R]] 1 |
| 87 | +; CHECK: [[V:%[0-9]+]] = OpCompositeConstruct [[v2float]] [[E0]] [[E1]] |
| 88 | + %3 = 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", float, 5, 2, 0, 0, 2, 1) %s_h.i, i32 23) |
| 89 | + %4 = load <2 x float>, ptr %3, align 4 |
| 90 | + |
| 91 | +; CHECK: [[H:%[0-9]+]] = OpLoad [[ImageType]] [[Var]] |
| 92 | +; CHECK: OpImageWrite [[H]] [[twenty]] [[V]] |
| 93 | + %5 = 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", float, 5, 2, 0, 0, 2, 1) %s_h.i, i32 20) |
| 94 | + store <2 x float> %4, ptr %5, align 4 |
| 95 | + ret void |
| 96 | +} |
| 97 | + |
| 98 | +; Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) |
| 99 | +; CHECK: OpFunction |
| 100 | +define void @main_vector4() local_unnamed_addr #0 { |
| 101 | +entry: |
| 102 | +; CHECK: [[H:%[0-9]+]] = OpLoad [[ImageType]] [[Var]] |
| 103 | + %s_h.i = tail call target("spirv.Image", float, 5, 2, 0, 0, 2, 1) @llvm.spv.resource.handlefrombinding.tspirv.Image_f32_5_2_0_0_2_0t(i32 3, i32 5, i32 1, i32 0, i1 false) |
| 104 | + |
| 105 | +; CHECK: [[R:%[0-9]+]] = OpImageRead [[v4float]] [[H]] [[one]] |
| 106 | + %0 = 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", float, 5, 2, 0, 0, 2, 1) %s_h.i, i32 1) |
| 107 | + %1 = load <4 x float>, ptr %0, align 4 |
| 108 | +; CHECK: OpBranch [[bb_store:%[0-9]+]] |
| 109 | + br label %bb_store |
| 110 | + |
| 111 | +; CHECK: [[bb_store]] = OpLabel |
| 112 | +bb_store: |
| 113 | + |
| 114 | +; CHECK: [[H:%[0-9]+]] = OpLoad [[ImageType]] [[Var]] |
| 115 | +; CHECK: OpImageWrite [[H]] [[zero]] [[R]] |
| 116 | + %2 = 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", float, 5, 2, 0, 0, 2, 1) %s_h.i, i32 0) |
| 117 | + store <4 x float> %1, ptr %2, align 4 |
| 118 | +; CHECK: OpBranch [[bb_both:%[0-9]+]] |
| 119 | + br label %bb_both |
| 120 | + |
| 121 | +; CHECK: [[bb_both]] = OpLabel |
| 122 | +bb_both: |
| 123 | +; CHECK: [[H:%[0-9]+]] = OpLoad [[ImageType]] [[Var]] |
| 124 | +; CHECK: [[R:%[0-9]+]] = OpImageRead [[v4float]] [[H]] [[twenty_three]] |
| 125 | + %3 = 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", float, 5, 2, 0, 0, 2, 1) %s_h.i, i32 23) |
| 126 | + %4 = load <4 x float>, ptr %3, align 4 |
| 127 | + |
| 128 | +; CHECK: [[H:%[0-9]+]] = OpLoad [[ImageType]] [[Var]] |
| 129 | +; CHECK: OpImageWrite [[H]] [[twenty]] [[R]] |
| 130 | + %5 = 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", float, 5, 2, 0, 0, 2, 1) %s_h.i, i32 20) |
| 131 | + store <4 x float> %4, ptr %5, align 4 |
| 132 | + ret void |
| 133 | +} |
| 134 | + |
53 | 135 | ; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(none)
|
54 | 136 | declare ptr @llvm.spv.resource.getpointer.p0.tspirv.Image_f32_5_2_0_0_2_0t(target("spirv.Image", float, 5, 2, 0, 0, 2, 1), i32) #1
|
55 | 137 |
|
|
0 commit comments