Skip to content

Commit 2b67f5e

Browse files
[SPIRV] Addition of image_store.ll and signed_arithmetic_overflow.ll (#152289)
--Test for signed arithmetic overflow intrinsics, which is for now expectedly failing --Test checking that no duplicate image types are emitted. --------- Co-authored-by: Michal Paszkowski <[email protected]>
1 parent d297987 commit 2b67f5e

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
2+
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
3+
4+
; Image types may be represented in two ways while translating to SPIR-V:
5+
; - OpenCL form, for example, '%opencl.image2d_ro_t',
6+
; - SPIR-V form, for example, '%spirv.Image._void_1_0_0_0_0_0_0',
7+
; but it is still one type which should be translated to one SPIR-V type.
8+
;
9+
; The test checks that the code below is successfully translated and only one
10+
; SPIR-V type for images is generated (no duplicate OpTypeImage instructions).
11+
12+
; CHECK: %[[#]] = OpTypeImage %[[#]] 2D
13+
; CHECK-NOT: %[[#]] = OpTypeImage %[[#]] 2D
14+
15+
declare spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_ff(ptr addrspace(1), ptr addrspace(2), <2 x float>, float)
16+
17+
define spir_kernel void @read_image(ptr addrspace(1) %srcimg, ptr addrspace(2) %sampler){
18+
entry:
19+
%spirvimg.addr = alloca target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0), align 8
20+
%val = call <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_ff(ptr addrspace(1) %srcimg, ptr addrspace(2) %sampler, <2 x float> zeroinitializer, float 0.0)
21+
ret void
22+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
2+
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -filetype=obj -o - | spirv-val %}
3+
; XFAIL: *
4+
;@llvm.sadd.with.overflow and @llvm.ssub.with.overflow has not been implemented.
5+
6+
define spir_func void @test_sadd_overflow(ptr %out_result, ptr %out_overflow, i32 %a, i32 %b) {
7+
entry:
8+
%res = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %a, i32 %b)
9+
%val = extractvalue { i32, i1 } %res, 0
10+
%ofl = extractvalue { i32, i1 } %res, 1
11+
store i32 %val, ptr %out_result
12+
%zext_ofl = zext i1 %ofl to i8
13+
store i8 %zext_ofl, ptr %out_overflow
14+
ret void
15+
}
16+
17+
declare { i32, i1 } @llvm.sadd.with.overflow.i32(i32, i32)
18+
19+
define spir_func void @test_ssub_overflow(ptr %out_result, ptr %out_overflow, i32 %a, i32 %b) {
20+
entry:
21+
%res = call { i32, i1 } @llvm.ssub.with.overflow.i32(i32 %a, i32 %b)
22+
%val = extractvalue { i32, i1 } %res, 0
23+
%ofl = extractvalue { i32, i1 } %res, 1
24+
store i32 %val, ptr %out_result
25+
%zext_ofl = zext i1 %ofl to i8
26+
store i8 %zext_ofl, ptr %out_overflow
27+
ret void
28+
}
29+
30+
declare { i32, i1 } @llvm.ssub.with.overflow.i32(i32, i32)

0 commit comments

Comments
 (0)