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_imagef15ocl_image2dmsaaDv2_ii(%opencl.image2d_msaa_t 9 10; CHECK-SPIRV: 7 ImageRead {{[0-9]+}} {{[0-9]+}} {{[0-9]+}} {{[0-9]+}} 64 {{[0-9]+}} 11 12target 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" 13target triple = "spir-unknown-unknown" 14 15%opencl.image2d_msaa_t = type opaque 16 17; Function Attrs: nounwind 18define spir_kernel void @sample_test(%opencl.image2d_msaa_t addrspace(1)* %source, i32 %sampler, <4 x float> addrspace(1)* nocapture %results) #0 { 19entry: 20 %call = tail call spir_func i32 @_Z13get_global_idj(i32 0) #2 21 %call1 = tail call spir_func i32 @_Z13get_global_idj(i32 1) #2 22 %call2 = tail call spir_func i32 @_Z15get_image_width15ocl_image2dmsaa(%opencl.image2d_msaa_t addrspace(1)* %source) #2 23 %call3 = tail call spir_func i32 @_Z16get_image_height15ocl_image2dmsaa(%opencl.image2d_msaa_t addrspace(1)* %source) #2 24 %call4 = tail call spir_func i32 @_Z21get_image_num_samples15ocl_image2dmsaa(%opencl.image2d_msaa_t addrspace(1)* %source) #2 25 %cmp20 = icmp eq i32 %call4, 0 26 br i1 %cmp20, label %for.end, label %for.body.lr.ph 27 28for.body.lr.ph: ; preds = %entry 29 %vecinit = insertelement <2 x i32> undef, i32 %call, i32 0 30 %vecinit8 = insertelement <2 x i32> %vecinit, i32 %call1, i32 1 31 br label %for.body 32 33for.body: ; preds = %for.body.lr.ph, %for.body 34 %sample.021 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ] 35 %mul5 = mul i32 %sample.021, %call3 36 %tmp = add i32 %mul5, %call1 37 %tmp19 = mul i32 %tmp, %call2 38 %add7 = add i32 %tmp19, %call 39 %call9 = tail call spir_func <4 x float> @_Z11read_imagef15ocl_image2dmsaaDv2_ii(%opencl.image2d_msaa_t addrspace(1)* %source, <2 x i32> %vecinit8, i32 %sample.021) #2 40 %arrayidx = getelementptr inbounds <4 x float>, <4 x float> addrspace(1)* %results, i32 %add7 41 store <4 x float> %call9, <4 x float> addrspace(1)* %arrayidx, align 16 42 %inc = add nuw i32 %sample.021, 1 43 %cmp = icmp ult i32 %inc, %call4 44 br i1 %cmp, label %for.body, label %for.end.loopexit 45 46for.end.loopexit: ; preds = %for.body 47 br label %for.end 48 49for.end: ; preds = %for.end.loopexit, %entry 50 ret void 51} 52 53declare spir_func i32 @_Z13get_global_idj(i32) #1 54 55declare spir_func i32 @_Z15get_image_width15ocl_image2dmsaa(%opencl.image2d_msaa_t addrspace(1)*) #1 56 57declare spir_func i32 @_Z16get_image_height15ocl_image2dmsaa(%opencl.image2d_msaa_t addrspace(1)*) #1 58 59declare spir_func i32 @_Z21get_image_num_samples15ocl_image2dmsaa(%opencl.image2d_msaa_t addrspace(1)*) #1 60 61declare spir_func <4 x float> @_Z11read_imagef15ocl_image2dmsaaDv2_ii(%opencl.image2d_msaa_t addrspace(1)*, <2 x i32>, i32) #1 62 63attributes #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" } 64attributes #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" } 65attributes #2 = { nounwind } 66 67!opencl.kernels = !{!0} 68!opencl.enable.FP_CONTRACT = !{} 69!opencl.spir.version = !{!6} 70!opencl.ocl.version = !{!7} 71!opencl.used.extensions = !{!8} 72!opencl.used.optional.core.features = !{!9} 73!opencl.compiler.options = !{!10} 74 75!0 = !{void (%opencl.image2d_msaa_t addrspace(1)*, i32, <4 x float> addrspace(1)*)* @sample_test, !1, !2, !3, !4, !5} 76!1 = !{!"kernel_arg_addr_space", i32 1, i32 0, i32 1} 77!2 = !{!"kernel_arg_access_qual", !"read_only", !"none", !"none"} 78!3 = !{!"kernel_arg_type", !"image2d_msaa_t", !"sampler_t", !"float4*"} 79!4 = !{!"kernel_arg_base_type", !"image2d_msaa_t", !"sampler_t", !"float4*"} 80!5 = !{!"kernel_arg_type_qual", !"", !"", !""} 81!6 = !{i32 1, i32 2} 82!7 = !{i32 2, i32 0} 83!8 = !{!"cl_khr_gl_msaa_sharing"} 84!9 = !{!"cl_images"} 85!10 = !{} 86