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 4 declare { i32, i1 } @llvm.ssub.with.overflow.i32(i32, i32) nounwind readnone 5 declare { i64, i1 } @llvm.ssub.with.overflow.i64(i64, i64) nounwind readnone 6 7 ; FUNC-LABEL: @ssubo_i64_zext 8 define void @ssubo_i64_zext(i64 addrspace(1)* %out, i64 %a, i64 %b) nounwind { 9 %ssub = call { i64, i1 } @llvm.ssub.with.overflow.i64(i64 %a, i64 %b) nounwind 10 %val = extractvalue { i64, i1 } %ssub, 0 11 %carry = extractvalue { i64, i1 } %ssub, 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_ssubo_i32 19 define void @s_ssubo_i32(i32 addrspace(1)* %out, i1 addrspace(1)* %carryout, i32 %a, i32 %b) nounwind { 20 %ssub = call { i32, i1 } @llvm.ssub.with.overflow.i32(i32 %a, i32 %b) nounwind 21 %val = extractvalue { i32, i1 } %ssub, 0 22 %carry = extractvalue { i32, i1 } %ssub, 1 23 store i32 %val, i32 addrspace(1)* %out, align 4 24 store i1 %carry, i1 addrspace(1)* %carryout 25 ret void 26 } 27 28 ; FUNC-LABEL: @v_ssubo_i32 29 define void @v_ssubo_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 %ssub = call { i32, i1 } @llvm.ssub.with.overflow.i32(i32 %a, i32 %b) nounwind 33 %val = extractvalue { i32, i1 } %ssub, 0 34 %carry = extractvalue { i32, i1 } %ssub, 1 35 store i32 %val, i32 addrspace(1)* %out, align 4 36 store i1 %carry, i1 addrspace(1)* %carryout 37 ret void 38 } 39 40 ; FUNC-LABEL: @s_ssubo_i64 41 ; SI: S_SUB_I32 42 ; SI: S_SUBB_U32 43 define void @s_ssubo_i64(i64 addrspace(1)* %out, i1 addrspace(1)* %carryout, i64 %a, i64 %b) nounwind { 44 %ssub = call { i64, i1 } @llvm.ssub.with.overflow.i64(i64 %a, i64 %b) nounwind 45 %val = extractvalue { i64, i1 } %ssub, 0 46 %carry = extractvalue { i64, i1 } %ssub, 1 47 store i64 %val, i64 addrspace(1)* %out, align 8 48 store i1 %carry, i1 addrspace(1)* %carryout 49 ret void 50 } 51 52 ; FUNC-LABEL: @v_ssubo_i64 53 ; SI: V_SUB_I32_e32 54 ; SI: V_SUBB_U32_e32 55 define void @v_ssubo_i64(i64 addrspace(1)* %out, i1 addrspace(1)* %carryout, i64 addrspace(1)* %aptr, i64 addrspace(1)* %bptr) nounwind { 56 %a = load i64 addrspace(1)* %aptr, align 4 57 %b = load i64 addrspace(1)* %bptr, align 4 58 %ssub = call { i64, i1 } @llvm.ssub.with.overflow.i64(i64 %a, i64 %b) nounwind 59 %val = extractvalue { i64, i1 } %ssub, 0 60 %carry = extractvalue { i64, i1 } %ssub, 1 61 store i64 %val, i64 addrspace(1)* %out, align 8 62 store i1 %carry, i1 addrspace(1)* %carryout 63 ret void 64 } 65