1; RUN: llc -march=r600 -mcpu=SI -verify-machineinstrs< %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s 2; RUN: llc -march=r600 -mcpu=cypress -verify-machineinstrs< %s 3 4declare { i32, i1 } @llvm.usub.with.overflow.i32(i32, i32) nounwind readnone 5declare { i64, i1 } @llvm.usub.with.overflow.i64(i64, i64) nounwind readnone 6 7; FUNC-LABEL: @usubo_i64_zext 8define void @usubo_i64_zext(i64 addrspace(1)* %out, i64 %a, i64 %b) nounwind { 9 %usub = call { i64, i1 } @llvm.usub.with.overflow.i64(i64 %a, i64 %b) nounwind 10 %val = extractvalue { i64, i1 } %usub, 0 11 %carry = extractvalue { i64, i1 } %usub, 1 12 %ext = zext i1 %carry to i64 13 %add2 = add i64 %val, %ext 14 store i64 %add2, i64 addrspace(1)* %out, align 8 15 ret void 16} 17 18; FUNC-LABEL: @s_usubo_i32 19; SI: S_SUB_I32 20define void @s_usubo_i32(i32 addrspace(1)* %out, i1 addrspace(1)* %carryout, i32 %a, i32 %b) nounwind { 21 %usub = call { i32, i1 } @llvm.usub.with.overflow.i32(i32 %a, i32 %b) nounwind 22 %val = extractvalue { i32, i1 } %usub, 0 23 %carry = extractvalue { i32, i1 } %usub, 1 24 store i32 %val, i32 addrspace(1)* %out, align 4 25 store i1 %carry, i1 addrspace(1)* %carryout 26 ret void 27} 28 29; FUNC-LABEL: @v_usubo_i32 30; SI: V_SUBREV_I32_e32 31define void @v_usubo_i32(i32 addrspace(1)* %out, i1 addrspace(1)* %carryout, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr) nounwind { 32 %a = load i32 addrspace(1)* %aptr, align 4 33 %b = load i32 addrspace(1)* %bptr, align 4 34 %usub = call { i32, i1 } @llvm.usub.with.overflow.i32(i32 %a, i32 %b) nounwind 35 %val = extractvalue { i32, i1 } %usub, 0 36 %carry = extractvalue { i32, i1 } %usub, 1 37 store i32 %val, i32 addrspace(1)* %out, align 4 38 store i1 %carry, i1 addrspace(1)* %carryout 39 ret void 40} 41 42; FUNC-LABEL: @s_usubo_i64 43; SI: S_SUB_I32 44; SI: S_SUBB_U32 45define void @s_usubo_i64(i64 addrspace(1)* %out, i1 addrspace(1)* %carryout, i64 %a, i64 %b) nounwind { 46 %usub = call { i64, i1 } @llvm.usub.with.overflow.i64(i64 %a, i64 %b) nounwind 47 %val = extractvalue { i64, i1 } %usub, 0 48 %carry = extractvalue { i64, i1 } %usub, 1 49 store i64 %val, i64 addrspace(1)* %out, align 8 50 store i1 %carry, i1 addrspace(1)* %carryout 51 ret void 52} 53 54; FUNC-LABEL: @v_usubo_i64 55; SI: V_SUB_I32 56; SI: V_SUBB_U32 57define void @v_usubo_i64(i64 addrspace(1)* %out, i1 addrspace(1)* %carryout, i64 addrspace(1)* %aptr, i64 addrspace(1)* %bptr) nounwind { 58 %a = load i64 addrspace(1)* %aptr, align 4 59 %b = load i64 addrspace(1)* %bptr, align 4 60 %usub = call { i64, i1 } @llvm.usub.with.overflow.i64(i64 %a, i64 %b) nounwind 61 %val = extractvalue { i64, i1 } %usub, 0 62 %carry = extractvalue { i64, i1 } %usub, 1 63 store i64 %val, i64 addrspace(1)* %out, align 8 64 store i1 %carry, i1 addrspace(1)* %carryout 65 ret void 66} 67