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