| 1 |
; RUN: llc -O0 -mtriple=spirv64-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: %[[#IntTy:]] = OpTypeInt |
| 13 |
; CHECK-SPIRV: %[[#IVecTy:]] = OpTypeVector %[[#IntTy]] |
| 14 |
; CHECK-SPIRV: %[[#FloatTy:]] = OpTypeFloat |
| 15 |
; CHECK-SPIRV: %[[#FVecTy:]] = OpTypeVector %[[#FloatTy]] |
| 16 |
; CHECK-SPIRV: OpImageRead %[[#IVecTy]] |
| 17 |
; CHECK-SPIRV: OpImageRead %[[#FVecTy]] |
| 18 |
|
| 19 |
;; __kernel void kernelA(__read_only image3d_t input) { |
| 20 |
;; uint4 c = read_imageui(input, (int4)(0, 0, 0, 0)); |
| 21 |
;; } |
| 22 |
;; |
| 23 |
;; __kernel void kernelB(__read_only image3d_t input) { |
| 24 |
;; float4 f = read_imagef(input, (int4)(0, 0, 0, 0)); |
| 25 |
;; } |
| 26 |
|
| 27 |
define dso_local spir_kernel void @kernelA(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) %input) { |
| 28 |
entry: |
| 29 |
%input.addr = alloca target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0), align 8 |
| 30 |
%c = alloca <4 x i32>, align 16 |
| 31 |
%.compoundliteral = alloca <4 x i32>, align 16 |
| 32 |
store target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) %input, ptr %input.addr, align 8 |
| 33 |
%0 = load target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0), ptr %input.addr, align 8 |
| 34 |
store <4 x i32> zeroinitializer, ptr %.compoundliteral, align 16 |
| 35 |
%1 = load <4 x i32>, ptr %.compoundliteral, align 16 |
| 36 |
%call = call spir_func <4 x i32> @_Z12read_imageui14ocl_image3d_roDv4_i(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) %0, <4 x i32> noundef %1) |
| 37 |
store <4 x i32> %call, ptr %c, align 16 |
| 38 |
ret void |
| 39 |
} |
| 40 |
|
| 41 |
declare spir_func <4 x i32> @_Z12read_imageui14ocl_image3d_roDv4_i(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) %0, <4 x i32> noundef %1) |
| 42 |
|
| 43 |
define dso_local spir_kernel void @kernelB(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) %input) { |
| 44 |
entry: |
| 45 |
%input.addr = alloca target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0), align 8 |
| 46 |
%f = alloca <4 x float>, align 16 |
| 47 |
%.compoundliteral = alloca <4 x i32>, align 16 |
| 48 |
store target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) %input, ptr %input.addr, align 8 |
| 49 |
%0 = load target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0), ptr %input.addr, align 8 |
| 50 |
store <4 x i32> zeroinitializer, ptr %.compoundliteral, align 16 |
| 51 |
%1 = load <4 x i32>, ptr %.compoundliteral, align 16 |
| 52 |
%call = call spir_func <4 x float> @_Z11read_imagef14ocl_image3d_roDv4_i(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) %0, <4 x i32> noundef %1) |
| 53 |
store <4 x float> %call, ptr %f, align 16 |
| 54 |
ret void |
| 55 |
} |
| 56 |
|
| 57 |
declare spir_func <4 x float> @_Z11read_imagef14ocl_image3d_roDv4_i(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) %0, <4 x i32> noundef %1) |