1 ; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
2 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
4 %i8struct = type {i8, i8}
5 %i16struct = type {i16, i16}
6 %i32struct = type {i32, i32}
7 %i64struct = type {i64, i64}
8 %vecstruct = type {<4 x i32>, <4 x i32>}
10 ; CHECK-SPIRV-DAG: [[uchar:%[a-z0-9_]+]] = OpTypeInt 8
11 ; CHECK-SPIRV-DAG: [[ushort:%[a-z0-9_]+]] = OpTypeInt 16
12 ; CHECK-SPIRV-DAG: [[uint:%[a-z0-9_]+]] = OpTypeInt 32
13 ; CHECK-SPIRV-DAG: [[ulong:%[a-z0-9_]+]] = OpTypeInt 64
14 ; CHECK-SPIRV-DAG: [[void:%[a-z0-9_]+]] = OpTypeVoid
15 ; CHECK-SPIRV-DAG: [[i8struct:%[a-z0-9_]+]] = OpTypeStruct [[uchar]] [[uchar]]
16 ; CHECK-SPIRV-DAG: [[_ptr_Function_i8struct:%[a-z0-9_]+]] = OpTypePointer Function [[i8struct]]
17 ; CHECK-SPIRV-DAG: [[i16struct:%[a-z0-9_]+]] = OpTypeStruct [[ushort]] [[ushort]]
18 ; CHECK-SPIRV-DAG: [[_ptr_Function_i16struct:%[a-z0-9_]+]] = OpTypePointer Function [[i16struct]]
19 ; CHECK-SPIRV-DAG: [[i32struct:%[a-z0-9_]+]] = OpTypeStruct [[uint]] [[uint]]
20 ; CHECK-SPIRV-DAG: [[_ptr_Function_i32struct:%[a-z0-9_]+]] = OpTypePointer Function [[i32struct]]
21 ; CHECK-SPIRV-DAG: [[i64struct:%[a-z0-9_]+]] = OpTypeStruct [[ulong]] [[ulong]]
22 ; CHECK-SPIRV-DAG: [[_ptr_Function_i64struct:%[a-z0-9_]+]] = OpTypePointer Function [[i64struct]]
23 ; CHECK-SPIRV-DAG: [[v4uint:%[a-z0-9_]+]] = OpTypeVector [[uint]] 4
24 ; CHECK-SPIRV-DAG: [[vecstruct:%[a-z0-9_]+]] = OpTypeStruct [[v4uint]] [[v4uint]]
25 ; CHECK-SPIRV-DAG: [[_ptr_Function_vecstruct:%[a-z0-9_]+]] = OpTypePointer Function [[vecstruct]]
26 ; CHECK-SPIRV-DAG: [[struct_anon:%[a-z0-9_.]+]] = OpTypeStruct [[uint]] [[uint]]
27 ; CHECK-SPIRV-DAG: [[_ptr_Function_struct_anon:%[a-z0-9_]+]] = OpTypePointer Function [[struct_anon]]
28 ; CHECK-SPIRV-DAG: [[_ptr_Generic_struct_anon:%[a-z0-9_]+]] = OpTypePointer Generic [[struct_anon]]
30 define spir_func void @test_builtin_isubborrowcc(i8 %a, i8 %b) {
33 call void @_Z18__spirv_ISubBorrowcc(ptr sret (%i8struct) %0, i8 %a, i8 %b)
36 ; CHECK-SPIRV: [[a:%[a-z0-9_]+]] = OpFunctionParameter [[uchar]]
37 ; CHECK-SPIRV: [[b:%[a-z0-9_]+]] = OpFunctionParameter [[uchar]]
38 ; CHECK-SPIRV: [[entry:%[a-z0-9_]+]] = OpLabel
39 ; CHECK-SPIRV: [[var_11:%[a-z0-9_]+]] = OpVariable [[_ptr_Function_i8struct]] Function
40 ; CHECK-SPIRV: [[var_12:%[a-z0-9_]+]] = OpISubBorrow [[i8struct]] [[a]] [[b]]
41 ; CHECK-SPIRV: OpStore [[var_11]] [[var_12]]
42 ; CHECK-SPIRV: OpReturn
43 ; CHECK-SPIRV: OpFunctionEnd
45 define spir_func void @test_builtin_isubborrowss(i16 %a, i16 %b) {
47 %0 = alloca %i16struct
48 call void @_Z18__spirv_ISubBorrowss(ptr sret (%i16struct) %0, i16 %a, i16 %b)
51 ; CHECK-SPIRV: [[a_0:%[a-z0-9_]+]] = OpFunctionParameter [[ushort]]
52 ; CHECK-SPIRV: [[b_0:%[a-z0-9_]+]] = OpFunctionParameter [[ushort]]
53 ; CHECK-SPIRV: [[entry_0:%[a-z0-9_]+]] = OpLabel
54 ; CHECK-SPIRV: [[var_21:%[a-z0-9_]+]] = OpVariable [[_ptr_Function_i16struct]] Function
55 ; CHECK-SPIRV: [[var_22:%[a-z0-9_]+]] = OpISubBorrow [[i16struct]] [[a_0]] [[b_0]]
56 ; CHECK-SPIRV: OpStore [[var_21]] [[var_22]]
57 ; CHECK-SPIRV: OpReturn
58 ; CHECK-SPIRV: OpFunctionEnd
60 define spir_func void @test_builtin_isubborrowii(i32 %a, i32 %b) {
62 %0 = alloca %i32struct
63 call void @_Z18__spirv_ISubBorrowii(ptr sret (%i32struct) %0, i32 %a, i32 %b)
66 ; CHECK-SPIRV: [[a_1:%[a-z0-9_]+]] = OpFunctionParameter [[uint]]
67 ; CHECK-SPIRV: [[b_1:%[a-z0-9_]+]] = OpFunctionParameter [[uint]]
68 ; CHECK-SPIRV: [[entry_1:%[a-z0-9_]+]] = OpLabel
69 ; CHECK-SPIRV: [[var_31:%[a-z0-9_]+]] = OpVariable [[_ptr_Function_i32struct]] Function
70 ; CHECK-SPIRV: [[var_32:%[a-z0-9_]+]] = OpISubBorrow [[i32struct]] [[a_1]] [[b_1]]
71 ; CHECK-SPIRV: OpStore [[var_31]] [[var_32]]
72 ; CHECK-SPIRV: OpReturn
73 ; CHECK-SPIRV: OpFunctionEnd
75 define spir_func void @test_builtin_isubborrowll(i64 %a, i64 %b) {
77 %0 = alloca %i64struct
78 call void @_Z18__spirv_ISubBorrowll(ptr sret (%i64struct) %0, i64 %a, i64 %b)
81 ; CHECK-SPIRV: [[a_2:%[a-z0-9_]+]] = OpFunctionParameter [[ulong]]
82 ; CHECK-SPIRV: [[b_2:%[a-z0-9_]+]] = OpFunctionParameter [[ulong]]
83 ; CHECK-SPIRV: [[entry_2:%[a-z0-9_]+]] = OpLabel
84 ; CHECK-SPIRV: [[var_41:%[a-z0-9_]+]] = OpVariable [[_ptr_Function_i64struct]] Function
85 ; CHECK-SPIRV: [[var_42:%[a-z0-9_]+]] = OpISubBorrow [[i64struct]] [[a_2]] [[b_2]]
86 ; CHECK-SPIRV: OpStore [[var_41]] [[var_42]]
87 ; CHECK-SPIRV: OpReturn
88 ; CHECK-SPIRV: OpFunctionEnd
90 define spir_func void @test_builtin_isubborrowDv4_xS_(<4 x i32> %a, <4 x i32> %b) {
92 %0 = alloca %vecstruct
93 call void @_Z18__spirv_ISubBorrowDv4_iS_(ptr sret (%vecstruct) %0, <4 x i32> %a, <4 x i32> %b)
96 ; CHECK-SPIRV: [[a_3:%[a-z0-9_]+]] = OpFunctionParameter [[v4uint]]
97 ; CHECK-SPIRV: [[b_3:%[a-z0-9_]+]] = OpFunctionParameter [[v4uint]]
98 ; CHECK-SPIRV: [[entry_3:%[a-z0-9_]+]] = OpLabel
99 ; CHECK-SPIRV: [[var_51:%[a-z0-9_]+]] = OpVariable [[_ptr_Function_vecstruct]] Function
100 ; CHECK-SPIRV: [[var_52:%[a-z0-9_]+]] = OpISubBorrow [[vecstruct]] [[a_3]] [[b_3]]
101 ; CHECK-SPIRV: OpStore [[var_51]] [[var_52]]
102 ; CHECK-SPIRV: OpReturn
103 ; CHECK-SPIRV: OpFunctionEnd
105 %struct.anon = type { i32, i32 }
107 define spir_func void @test_builtin_isubborrow_anon(i32 %a, i32 %b) {
109 %0 = alloca %struct.anon
110 %1 = addrspacecast ptr %0 to ptr addrspace(4)
111 call spir_func void @_Z18__spirv_ISubBorrowIiiE4anonIT_T0_ES1_S2_(ptr addrspace(4) sret(%struct.anon) align 4 %1, i32 %a, i32 %b)
114 ; CHECK-SPIRV: [[a_4:%[a-z0-9_]+]] = OpFunctionParameter [[uint]]
115 ; CHECK-SPIRV: [[b_4:%[a-z0-9_]+]] = OpFunctionParameter [[uint]]
116 ; CHECK-SPIRV: [[entry_4:%[a-z0-9_]+]] = OpLabel
117 ; CHECK-SPIRV: [[var_59:%[a-z0-9_]+]] = OpVariable [[_ptr_Function_struct_anon]] Function
118 ; CHECK-SPIRV: [[var_61:%[a-z0-9_]+]] = OpPtrCastToGeneric [[_ptr_Generic_struct_anon]] [[var_59]]
119 ; CHECK-SPIRV: [[var_62:%[a-z0-9_]+]] = OpISubBorrow [[struct_anon]] [[a_4]] [[b_4]]
120 ; CHECK-SPIRV: OpStore [[var_61]] [[var_62]]
122 declare void @_Z18__spirv_ISubBorrowIiiE4anonIT_T0_ES1_S2_(ptr addrspace(4) sret(%struct.anon) align 4, i32, i32)
123 declare void @_Z18__spirv_ISubBorrowcc(ptr sret(%i8struct), i8, i8)
124 declare void @_Z18__spirv_ISubBorrowss(ptr sret(%i16struct), i16, i16)
125 declare void @_Z18__spirv_ISubBorrowii(ptr sret(%i32struct), i32, i32)
126 declare void @_Z18__spirv_ISubBorrowll(ptr sret(%i64struct), i64, i64)
127 declare void @_Z18__spirv_ISubBorrowDv4_iS_(ptr sret (%vecstruct), <4 x i32>, <4 x i32>)