• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -march=amdgcn -mcpu=SI -verify-machineinstrs< %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
2; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs< %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
3; RUN: llc -march=r600 -mcpu=cypress -verify-machineinstrs< %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
4
5declare { i32, i1 } @llvm.usub.with.overflow.i32(i32, i32) nounwind readnone
6declare { i64, i1 } @llvm.usub.with.overflow.i64(i64, i64) nounwind readnone
7
8; FUNC-LABEL: {{^}}usubo_i64_zext:
9
10; EG: SUBB_UINT
11; EG: ADDC_UINT
12define void @usubo_i64_zext(i64 addrspace(1)* %out, i64 %a, i64 %b) nounwind {
13  %usub = call { i64, i1 } @llvm.usub.with.overflow.i64(i64 %a, i64 %b) nounwind
14  %val = extractvalue { i64, i1 } %usub, 0
15  %carry = extractvalue { i64, i1 } %usub, 1
16  %ext = zext i1 %carry to i64
17  %add2 = add i64 %val, %ext
18  store i64 %add2, i64 addrspace(1)* %out, align 8
19  ret void
20}
21
22; FUNC-LABEL: {{^}}s_usubo_i32:
23; SI: s_sub_i32
24
25; EG-DAG: SUBB_UINT
26; EG-DAG: SUB_INT
27define void @s_usubo_i32(i32 addrspace(1)* %out, i1 addrspace(1)* %carryout, i32 %a, i32 %b) nounwind {
28  %usub = call { i32, i1 } @llvm.usub.with.overflow.i32(i32 %a, i32 %b) nounwind
29  %val = extractvalue { i32, i1 } %usub, 0
30  %carry = extractvalue { i32, i1 } %usub, 1
31  store i32 %val, i32 addrspace(1)* %out, align 4
32  store i1 %carry, i1 addrspace(1)* %carryout
33  ret void
34}
35
36; FUNC-LABEL: {{^}}v_usubo_i32:
37; SI: v_subrev_i32_e32
38
39; EG-DAG: SUBB_UINT
40; EG-DAG: SUB_INT
41define void @v_usubo_i32(i32 addrspace(1)* %out, i1 addrspace(1)* %carryout, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr) nounwind {
42  %a = load i32, i32 addrspace(1)* %aptr, align 4
43  %b = load i32, i32 addrspace(1)* %bptr, align 4
44  %usub = call { i32, i1 } @llvm.usub.with.overflow.i32(i32 %a, i32 %b) nounwind
45  %val = extractvalue { i32, i1 } %usub, 0
46  %carry = extractvalue { i32, i1 } %usub, 1
47  store i32 %val, i32 addrspace(1)* %out, align 4
48  store i1 %carry, i1 addrspace(1)* %carryout
49  ret void
50}
51
52; FUNC-LABEL: {{^}}s_usubo_i64:
53; SI: s_sub_u32
54; SI: s_subb_u32
55
56; EG-DAG: SUBB_UINT
57; EG-DAG: SUB_INT
58; EG-DAG: SUB_INT
59; EG: SUB_INT
60define void @s_usubo_i64(i64 addrspace(1)* %out, i1 addrspace(1)* %carryout, i64 %a, i64 %b) nounwind {
61  %usub = call { i64, i1 } @llvm.usub.with.overflow.i64(i64 %a, i64 %b) nounwind
62  %val = extractvalue { i64, i1 } %usub, 0
63  %carry = extractvalue { i64, i1 } %usub, 1
64  store i64 %val, i64 addrspace(1)* %out, align 8
65  store i1 %carry, i1 addrspace(1)* %carryout
66  ret void
67}
68
69; FUNC-LABEL: {{^}}v_usubo_i64:
70; SI: v_sub_i32
71; SI: v_subb_u32
72
73; EG-DAG: SUBB_UINT
74; EG-DAG: SUB_INT
75; EG-DAG: SUB_INT
76; EG: SUB_INT
77define void @v_usubo_i64(i64 addrspace(1)* %out, i1 addrspace(1)* %carryout, i64 addrspace(1)* %aptr, i64 addrspace(1)* %bptr) nounwind {
78  %a = load i64, i64 addrspace(1)* %aptr, align 4
79  %b = load i64, i64 addrspace(1)* %bptr, align 4
80  %usub = call { i64, i1 } @llvm.usub.with.overflow.i64(i64 %a, i64 %b) nounwind
81  %val = extractvalue { i64, i1 } %usub, 0
82  %carry = extractvalue { i64, i1 } %usub, 1
83  store i64 %val, i64 addrspace(1)* %out, align 8
84  store i1 %carry, i1 addrspace(1)* %carryout
85  ret void
86}
87