1 ; RUN: llc -march=amdgcn -mcpu=SI -verify-machineinstrs< %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
2 ; RUN: llc -march=r600 -mcpu=cypress -verify-machineinstrs< %s
4 declare { i32, i1 } @llvm.sadd.with.overflow.i32(i32, i32) nounwind readnone
5 declare { i64, i1 } @llvm.sadd.with.overflow.i64(i64, i64) nounwind readnone
7 ; FUNC-LABEL: {{^}}saddo_i64_zext:
8 define void @saddo_i64_zext(i64 addrspace(1)* %out, i64 %a, i64 %b) nounwind {
9 %sadd = call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 %a, i64 %b) nounwind
10 %val = extractvalue { i64, i1 } %sadd, 0
11 %carry = extractvalue { i64, i1 } %sadd, 1
12 %ext = zext i1 %carry to i64
13 %add2 = add i64 %val, %ext
14 store i64 %add2, i64 addrspace(1)* %out, align 8
18 ; FUNC-LABEL: {{^}}s_saddo_i32:
19 define void @s_saddo_i32(i32 addrspace(1)* %out, i1 addrspace(1)* %carryout, i32 %a, i32 %b) nounwind {
20 %sadd = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %a, i32 %b) nounwind
21 %val = extractvalue { i32, i1 } %sadd, 0
22 %carry = extractvalue { i32, i1 } %sadd, 1
23 store i32 %val, i32 addrspace(1)* %out, align 4
24 store i1 %carry, i1 addrspace(1)* %carryout
28 ; FUNC-LABEL: {{^}}v_saddo_i32:
29 define void @v_saddo_i32(i32 addrspace(1)* %out, i1 addrspace(1)* %carryout, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr) nounwind {
30 %a = load i32 addrspace(1)* %aptr, align 4
31 %b = load i32 addrspace(1)* %bptr, align 4
32 %sadd = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %a, i32 %b) nounwind
33 %val = extractvalue { i32, i1 } %sadd, 0
34 %carry = extractvalue { i32, i1 } %sadd, 1
35 store i32 %val, i32 addrspace(1)* %out, align 4
36 store i1 %carry, i1 addrspace(1)* %carryout
40 ; FUNC-LABEL: {{^}}s_saddo_i64:
41 define void @s_saddo_i64(i64 addrspace(1)* %out, i1 addrspace(1)* %carryout, i64 %a, i64 %b) nounwind {
42 %sadd = call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 %a, i64 %b) nounwind
43 %val = extractvalue { i64, i1 } %sadd, 0
44 %carry = extractvalue { i64, i1 } %sadd, 1
45 store i64 %val, i64 addrspace(1)* %out, align 8
46 store i1 %carry, i1 addrspace(1)* %carryout
50 ; FUNC-LABEL: {{^}}v_saddo_i64:
53 define void @v_saddo_i64(i64 addrspace(1)* %out, i1 addrspace(1)* %carryout, i64 addrspace(1)* %aptr, i64 addrspace(1)* %bptr) nounwind {
54 %a = load i64 addrspace(1)* %aptr, align 4
55 %b = load i64 addrspace(1)* %bptr, align 4
56 %sadd = call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 %a, i64 %b) nounwind
57 %val = extractvalue { i64, i1 } %sadd, 0
58 %carry = extractvalue { i64, i1 } %sadd, 1
59 store i64 %val, i64 addrspace(1)* %out, align 8
60 store i1 %carry, i1 addrspace(1)* %carryout