| 1 |
; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV |
| 2 |
|
| 3 |
; StorageImageReadWithoutFormat/StorageImageWriteWithoutFormat implicitly |
| 4 |
; declare Shader, causing a SPIR-V module to be rejected by the OpenCL |
| 5 |
; run-time. See https://github.com/KhronosGroup/SPIRV-Headers/issues/487 |
| 6 |
; De-facto, OpImageRead and OpImageWrite are allowed to use Unknown Image |
| 7 |
; Formats when the Kernel capability is declared. We reflect this behavior |
| 8 |
; in the test case, and leave the check under CHECK-SPIRV-NOT to track |
| 9 |
; the issue and follow-up its final resolution when ready. |
| 10 |
; CHECK-SPIRV-NOT: OpCapability StorageImageReadWithoutFormat |
| 11 |
|
| 12 |
; CHECK-SPIRV: %[[#]] = OpImageRead %[[#]] %[[#]] %[[#]] Sample %[[#]] |
| 13 |
|
| 14 |
define spir_kernel void @sample_test(target("spirv.Image", void, 1, 0, 0, 1, 0, 0, 0) %source, i32 %sampler, ptr addrspace(1) nocapture %results) { |
| 15 |
entry: |
| 16 |
%call = tail call spir_func i32 @_Z13get_global_idj(i32 0) |
| 17 |
%call1 = tail call spir_func i32 @_Z13get_global_idj(i32 1) |
| 18 |
%call2 = tail call spir_func i32 @_Z15get_image_width19ocl_image2d_msaa_ro(target("spirv.Image", void, 1, 0, 0, 1, 0, 0, 0) %source) |
| 19 |
%call3 = tail call spir_func i32 @_Z16get_image_height19ocl_image2d_msaa_ro(target("spirv.Image", void, 1, 0, 0, 1, 0, 0, 0) %source) |
| 20 |
%call4 = tail call spir_func i32 @_Z21get_image_num_samples19ocl_image2d_msaa_ro(target("spirv.Image", void, 1, 0, 0, 1, 0, 0, 0) %source) |
| 21 |
%cmp20 = icmp eq i32 %call4, 0 |
| 22 |
br i1 %cmp20, label %for.end, label %for.body.lr.ph |
| 23 |
|
| 24 |
for.body.lr.ph: ; preds = %entry |
| 25 |
%vecinit = insertelement <2 x i32> undef, i32 %call, i32 0 |
| 26 |
%vecinit8 = insertelement <2 x i32> %vecinit, i32 %call1, i32 1 |
| 27 |
br label %for.body |
| 28 |
|
| 29 |
for.body: ; preds = %for.body.lr.ph, %for.body |
| 30 |
%sample.021 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ] |
| 31 |
%mul5 = mul i32 %sample.021, %call3 |
| 32 |
%tmp = add i32 %mul5, %call1 |
| 33 |
%tmp19 = mul i32 %tmp, %call2 |
| 34 |
%add7 = add i32 %tmp19, %call |
| 35 |
%call9 = tail call spir_func <4 x float> @_Z11read_imagef19ocl_image2d_msaa_roDv2_ii(target("spirv.Image", void, 1, 0, 0, 1, 0, 0, 0) %source, <2 x i32> %vecinit8, i32 %sample.021) |
| 36 |
%arrayidx = getelementptr inbounds <4 x float>, ptr addrspace(1) %results, i32 %add7 |
| 37 |
store <4 x float> %call9, ptr addrspace(1) %arrayidx, align 16 |
| 38 |
%inc = add nuw i32 %sample.021, 1 |
| 39 |
%cmp = icmp ult i32 %inc, %call4 |
| 40 |
br i1 %cmp, label %for.body, label %for.end.loopexit |
| 41 |
|
| 42 |
for.end.loopexit: ; preds = %for.body |
| 43 |
br label %for.end |
| 44 |
|
| 45 |
for.end: ; preds = %for.end.loopexit, %entry |
| 46 |
ret void |
| 47 |
} |
| 48 |
|
| 49 |
declare spir_func i32 @_Z13get_global_idj(i32) |
| 50 |
|
| 51 |
declare spir_func i32 @_Z15get_image_width19ocl_image2d_msaa_ro(target("spirv.Image", void, 1, 0, 0, 1, 0, 0, 0)) |
| 52 |
|
| 53 |
declare spir_func i32 @_Z16get_image_height19ocl_image2d_msaa_ro(target("spirv.Image", void, 1, 0, 0, 1, 0, 0, 0)) |
| 54 |
|
| 55 |
declare spir_func i32 @_Z21get_image_num_samples19ocl_image2d_msaa_ro(target("spirv.Image", void, 1, 0, 0, 1, 0, 0, 0)) |
| 56 |
|
| 57 |
declare spir_func <4 x float> @_Z11read_imagef19ocl_image2d_msaa_roDv2_ii(target("spirv.Image", void, 1, 0, 0, 1, 0, 0, 0), <2 x i32>, i32) |