Debian Codegraph @

llvm-project/llvm/projects/llvm-spirv/test/transcoding/image_signedness.ll

raw
1 ; Test that signedness of calls to read_image(u)i/write_image(u)i is preserved.
2
3 ; RUN: llvm-as -opaque-pointers=0 %s -o %t.bc
4 ; RUN: llvm-spirv %t.bc -opaque-pointers=0 -o %t.spv
5 ; RUN: spirv-val %t.spv
6 ; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
7 ; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
8 ; RUN: llvm-spirv -r --spirv-target-env=SPV-IR %t.spv -o %t.rev.bc
9 ; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-SPV-IR
10
11 ; ModuleID = 'image_signedness.ll'
12 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"
13 target triple = "spir-unknown-unknown"
14
15 %opencl.image1d_ro_t = type opaque
16 %opencl.image1d_array_rw_t = type opaque
17 %opencl.sampler_t = type opaque
18 %opencl.image2d_wo_t = type opaque
19
20 ; CHECK-LLVM-LABEL: @imagereads
21 ; CHECK-LLVM: call spir_func <4 x i32> @_Z12read_imageui14ocl_image1d_ro11ocl_sampleri(
22 ; CHECK-LLVM: call spir_func <4 x i32> @_Z11read_imagei14ocl_image1d_ro11ocl_sampleri(
23 ; CHECK-LLVM: call spir_func <4 x i32> @_Z12read_imageui20ocl_image1d_array_rwDv2_i(
24 ; CHECK-LLVM: call spir_func <4 x i32> @_Z12read_imageui14ocl_image1d_roi(
25 ; CHECK-LLVM: call spir_func <4 x i32> @_Z11read_imagei14ocl_image1d_roi(
26 ; CHECK-SPV-IR: call spir_func <4 x i32> @_Z37__spirv_ImageSampleExplicitLod_Ruint4PU3AS140__spirv_SampledImage__void_0_0_0_0_0_0_0iif(
27 ; CHECK-SPV-IR: call spir_func <4 x i32> @_Z36__spirv_ImageSampleExplicitLod_Rint4PU3AS140__spirv_SampledImage__void_0_0_0_0_0_0_0iif(
28 ; CHECK-SPV-IR: call spir_func <4 x i32> @_Z24__spirv_ImageRead_Ruint4PU3AS133__spirv_Image__void_0_0_1_0_0_0_2Dv2_ii(
29 ; CHECK-SPV-IR: call spir_func <4 x i32> @_Z24__spirv_ImageRead_Ruint4PU3AS133__spirv_Image__void_0_0_0_0_0_0_0ii(
30 ; CHECK-SPV-IR: call spir_func <4 x i32> @_Z23__spirv_ImageRead_Rint4PU3AS133__spirv_Image__void_0_0_0_0_0_0_0ii(
31
32 ; Function Attrs: convergent nounwind
33 define dso_local spir_kernel void @imagereads(%opencl.image1d_ro_t addrspace(1)* %im, %opencl.image1d_array_rw_t addrspace(1)* %ima, <4 x i32> addrspace(1)* nocapture %res, <4 x i32> addrspace(1)* nocapture %resu) local_unnamed_addr #0 !kernel_arg_addr_space !4 !kernel_arg_access_qual !5 !kernel_arg_type !6 !kernel_arg_base_type !7 !kernel_arg_type_qual !8 {
34 entry:
35 %0 = tail call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 19) #2
36 %call = tail call spir_func <4 x i32> @_Z12read_imageui14ocl_image1d_ro11ocl_sampleri(%opencl.image1d_ro_t addrspace(1)* %im, %opencl.sampler_t addrspace(2)* %0, i32 42) #3
37 store <4 x i32> %call, <4 x i32> addrspace(1)* %res, align 16, !tbaa !9
38 %call1 = tail call spir_func <4 x i32> @_Z11read_imagei14ocl_image1d_ro11ocl_sampleri(%opencl.image1d_ro_t addrspace(1)* %im, %opencl.sampler_t addrspace(2)* %0, i32 43) #3
39 store <4 x i32> %call1, <4 x i32> addrspace(1)* %resu, align 16, !tbaa !9
40 %call2 = tail call spir_func <4 x i32> @_Z12read_imageui20ocl_image1d_array_rwDv2_i(%opencl.image1d_array_rw_t addrspace(1)* %ima, <2 x i32> undef) #3
41 store <4 x i32> %call2, <4 x i32> addrspace(1)* %resu, align 16, !tbaa !9
42 %call3 = tail call spir_func <4 x i32> @_Z12read_imageui14ocl_image1d_roi(%opencl.image1d_ro_t addrspace(1)* %im, i32 44) #3
43 store <4 x i32> %call3, <4 x i32> addrspace(1)* %res, align 16, !tbaa !9
44 %call4 = tail call spir_func <4 x i32> @_Z11read_imagei14ocl_image1d_roi(%opencl.image1d_ro_t addrspace(1)* %im, i32 45) #3
45 store <4 x i32> %call4, <4 x i32> addrspace(1)* %resu, align 16, !tbaa !9
46 ret void
47 }
48
49 ; CHECK-LLVM-LABEL: @imagewrites
50 ; CHECK-LLVM: call spir_func void @_Z12write_imagei14ocl_image2d_woDv2_iDv4_i(
51 ; CHECK-LLVM: call spir_func void @_Z13write_imageui14ocl_image2d_woDv2_iDv4_j(
52 ; CHECK-SPV-IR: call spir_func void @_Z18__spirv_ImageWritePU3AS133__spirv_Image__void_1_0_0_0_0_0_1Dv2_iDv4_ii(
53 ; CHECK-SPV-IR: call spir_func void @_Z18__spirv_ImageWritePU3AS133__spirv_Image__void_1_0_0_0_0_0_1Dv2_iDv4_ji(
54
55 ; Function Attrs: alwaysinline convergent nounwind
56 define spir_kernel void @imagewrites(i32 %offset, <4 x i32> addrspace(1)* nocapture readonly %input, <4 x i32> addrspace(1)* nocapture readonly %inputu, %opencl.image2d_wo_t addrspace(1)* %output) local_unnamed_addr #0 !kernel_arg_addr_space !14 !kernel_arg_access_qual !15 !kernel_arg_type !16 !kernel_arg_base_type !17 !kernel_arg_type_qual !18 !kernel_arg_name !19 !kernel_attributes !20 {
57 entry:
58 %idxprom = sext i32 %offset to i64
59 %arrayidx = getelementptr inbounds <4 x i32>, <4 x i32> addrspace(1)* %input, i64 %idxprom
60 %0 = load <4 x i32>, <4 x i32> addrspace(1)* %arrayidx, align 16
61 tail call void @_Z12write_imagei14ocl_image2d_woDv2_iDv4_i(%opencl.image2d_wo_t addrspace(1)* %output, <2 x i32> <i32 11, i32 11>, <4 x i32> %0) #3
62 %arrayidx3 = getelementptr inbounds <4 x i32>, <4 x i32> addrspace(1)* %inputu, i64 %idxprom
63 %1 = load <4 x i32>, <4 x i32> addrspace(1)* %arrayidx3, align 16
64 tail call void @_Z13write_imageui14ocl_image2d_woDv2_iDv4_j(%opencl.image2d_wo_t addrspace(1)* %output, <2 x i32> <i32 22, i32 22>, <4 x i32> %1) #3
65 ret void
66 }
67
68 declare dso_local %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32) local_unnamed_addr
69
70 ; Function Attrs: convergent nounwind readonly
71 declare dso_local spir_func <4 x i32> @_Z12read_imageui14ocl_image1d_ro11ocl_sampleri(%opencl.image1d_ro_t addrspace(1)*, %opencl.sampler_t addrspace(2)*, i32) local_unnamed_addr #1
72
73 ; Function Attrs: convergent nounwind readonly
74 declare dso_local spir_func <4 x i32> @_Z11read_imagei14ocl_image1d_ro11ocl_sampleri(%opencl.image1d_ro_t addrspace(1)*, %opencl.sampler_t addrspace(2)*, i32) local_unnamed_addr #1
75
76 ; Function Attrs: alwaysinline convergent nounwind readonly
77 declare <4 x i32> @_Z12read_imageui14ocl_image1d_roi(%opencl.image1d_ro_t addrspace(1)*, i32) local_unnamed_addr #1
78
79 ; Function Attrs: alwaysinline convergent nounwind readonly
80 declare <4 x i32> @_Z11read_imagei14ocl_image1d_roi(%opencl.image1d_ro_t addrspace(1)*, i32) local_unnamed_addr #1
81
82 ; Function Attrs: alwaysinline convergent nounwind readonly
83 declare <4 x i32> @_Z12read_imageui20ocl_image1d_array_rwDv2_i(%opencl.image1d_array_rw_t addrspace(1)*, <2 x i32>) local_unnamed_addr #1
84
85 ; Function Attrs: alwaysinline convergent
86 declare void @_Z12write_imagei14ocl_image2d_woDv2_iDv4_i(%opencl.image2d_wo_t addrspace(1)*, <2 x i32>, <4 x i32>) local_unnamed_addr
87
88 ; Function Attrs: alwaysinline convergent
89 declare void @_Z13write_imageui14ocl_image2d_woDv2_iDv4_j(%opencl.image2d_wo_t addrspace(1)*, <2 x i32>, <4 x i32>) local_unnamed_addr
90
91 attributes #0 = { convergent nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "denorms-are-zero"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="128" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" "unsafe-fp-math"="false" "use-soft-float"="false" }
92 attributes #1 = { convergent nounwind readonly "correctly-rounded-divide-sqrt-fp-math"="false" "denorms-are-zero"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
93 attributes #2 = { nounwind }
94 attributes #3 = { convergent nounwind readonly }
95
96 !llvm.module.flags = !{!0}
97 !opencl.ocl.version = !{!1}
98 !opencl.spir.version = !{!2}
99 !llvm.ident = !{!3}
100
101 !0 = !{i32 1, !"wchar_size", i32 4}
102 !1 = !{i32 1, i32 0}
103 !2 = !{i32 1, i32 2}
104 !3 = !{!"clang version 8.0.0 (https://git.llvm.org/git/clang.git 2d5099826365b50ff253e48c0832255600e68202) (https://git.llvm.org/git/llvm.git 787527b1af60b0b9d4a35b7fef3fb51cfde43784)"}
105 !4 = !{i32 1, i32 1}
106 !5 = !{!"read_only", !"read_write", !"none"}
107 !6 = !{!"image1d_t", !"image1d_array_t", !"uint4*"}
108 !7 = !{!"image1d_t", !"image1d_array_t", !"uint __attribute__((ext_vector_type(4)))*"}
109 !8 = !{!"", !"", !""}
110 !9 = !{!10, !10, i64 0}
111 !10 = !{!"omnipotent char", !11, i64 0}
112 !11 = !{!"Simple C/C++ TBAA"}
113 !14 = !{i32 0, i32 1, i32 1, i32 1}
114 !15 = !{!"none", !"none", !"none", !"write_only"}
115 !16 = !{!"int", !"int4*", !"uint4*", !"image2d_t"}
116 !17 = !{!"int", !"int __attribute__((ext_vector_type(4)))*", !"uint __attribute__((ext_vector_type(4)))*", !"image2d_t"}
117 !18 = !{!"", !"", !"", !""}
118 !19 = !{!"offset", !"input", !"inputu", !"output"}
119 !20 = !{!""}