1 ; RUN: llvm-as %s -o %t.bc 2 ; RUN: llvm-spirv %t.bc -spirv-text -o %t.txt 3 ; RUN: FileCheck < %t.txt %s --check-prefix=CHECK-SPIRV 4 ; RUN: llvm-spirv %t.bc -o %t.spv 5 ; RUN: llvm-spirv -r %t.spv -o %t.rev.bc 6 ; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM 7 8 ; CHECK-LLVM: call spir_func <4 x float> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_i 9 10 ; CHECK-SPIRV-DAG: 5 SampledImage {{[0-9]+}} {{[0-9]+}} {{[0-9]+}} [[SamplerID:[0-9]+]] 11 ; CHECK-SPIRV-DAG: 6 ConstantSampler {{[0-9]+}} [[SamplerID]] 1 0 4294967295 12 13 target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" 14 target triple = "spir-unknown-unknown" 15 16 %opencl.image2d_t = type opaque 17 18 ; Function Attrs: nounwind 19 define spir_kernel void @applySelection(%opencl.image2d_t addrspace(1)* %input, %opencl.image2d_t addrspace(1)* %selection, i32 %width, i32 %height, float %bleed, %opencl.image2d_t addrspace(1)* %output) #0 { 20 entry: 21 %call = tail call spir_func i32 @_Z13get_global_idj(i32 0) #3 22 %call1 = tail call spir_func i32 @_Z13get_global_idj(i32 1) #3 23 %cmp = icmp slt i32 %call1, %height 24 %cmp2 = icmp slt i32 %call, %width 25 %or.cond = and i1 %cmp2, %cmp 26 br i1 %or.cond, label %if.end, label %return 27 28 if.end: ; preds = %entry 29 %vecinit = insertelement <2 x i32> undef, i32 %call, i32 0 30 %vecinit3 = insertelement <2 x i32> %vecinit, i32 %call1, i32 1 31 %call5 = tail call spir_func <4 x float> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_i(%opencl.image2d_t addrspace(1)* %selection, i32 2, <2 x i32> %vecinit3) #3 32 %0 = extractelement <4 x float> %call5, i32 0 33 %sub = fsub float 1.000000e+00, %bleed 34 %1 = tail call float @llvm.fmuladd.f32(float %sub, float %0, float %bleed) 35 %splat.splatinsert = insertelement <4 x float> undef, float %1, i32 0 36 %splat.splat = shufflevector <4 x float> %splat.splatinsert, <4 x float> undef, <4 x i32> zeroinitializer 37 %call6 = tail call spir_func <4 x float> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_i(%opencl.image2d_t addrspace(1)* %input, i32 2, <2 x i32> %vecinit3) #3 38 %mul = fmul <4 x float> %call6, %splat.splat 39 tail call spir_func void @_Z12write_imagef11ocl_image2dDv2_iDv4_f(%opencl.image2d_t addrspace(1)* %output, <2 x i32> %vecinit3, <4 x float> %mul) #3 40 br label %return 41 42 return: ; preds = %entry, %if.end 43 ret void 44 } 45 46 declare spir_func i32 @_Z13get_global_idj(i32) #1 47 48 declare spir_func <4 x float> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_i(%opencl.image2d_t addrspace(1)*, i32, <2 x i32>) #1 49 50 declare spir_func void @_Z12write_imagef11ocl_image2dDv2_iDv4_f(%opencl.image2d_t addrspace(1)*, <2 x i32>, <4 x float>) #1 51 52 ; Function Attrs: nounwind readnone 53 declare float @llvm.fmuladd.f32(float, float, float) #2 54 55 attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } 56 attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } 57 attributes #2 = { nounwind readnone } 58 attributes #3 = { nounwind } 59 60 !opencl.kernels = !{!0} 61 !opencl.enable.FP_CONTRACT = !{} 62 !opencl.spir.version = !{!6} 63 !opencl.ocl.version = !{!7} 64 !opencl.used.extensions = !{!8} 65 !opencl.used.optional.core.features = !{!9} 66 !opencl.compiler.options = !{!8} 67 68 !0 = !{void (%opencl.image2d_t addrspace(1)*, %opencl.image2d_t addrspace(1)*, i32, i32, float, %opencl.image2d_t addrspace(1)*)* @applySelection, !1, !2, !3, !4, !5} 69 !1 = !{!"kernel_arg_addr_space", i32 1, i32 1, i32 0, i32 0, i32 0, i32 1} 70 !2 = !{!"kernel_arg_access_qual", !"read_only", !"read_only", !"none", !"none", !"none", !"write_only"} 71 !3 = !{!"kernel_arg_type", !"image2d_t", !"image2d_t", !"int", !"int", !"float", !"image2d_t"} 72 !4 = !{!"kernel_arg_base_type", !"image2d_t", !"image2d_t", !"int", !"int", !"float", !"image2d_t"} 73 !5 = !{!"kernel_arg_type_qual", !"", !"", !"", !"", !"", !""} 74 !6 = !{i32 1, i32 2} 75 !7 = !{i32 2, i32 0} 76 !8 = !{} 77 !9 = !{!"cl_images"} 78