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 4 5declare { i32, i1 } @llvm.ssub.with.overflow.i32(i32, i32) nounwind readnone 6declare { i64, i1 } @llvm.ssub.with.overflow.i64(i64, i64) nounwind readnone 7 8; FUNC-LABEL: {{^}}ssubo_i64_zext: 9define void @ssubo_i64_zext(i64 addrspace(1)* %out, i64 %a, i64 %b) nounwind { 10 %ssub = call { i64, i1 } @llvm.ssub.with.overflow.i64(i64 %a, i64 %b) nounwind 11 %val = extractvalue { i64, i1 } %ssub, 0 12 %carry = extractvalue { i64, i1 } %ssub, 1 13 %ext = zext i1 %carry to i64 14 %add2 = add i64 %val, %ext 15 store i64 %add2, i64 addrspace(1)* %out, align 8 16 ret void 17} 18 19; FUNC-LABEL: {{^}}s_ssubo_i32: 20define void @s_ssubo_i32(i32 addrspace(1)* %out, i1 addrspace(1)* %carryout, i32 %a, i32 %b) nounwind { 21 %ssub = call { i32, i1 } @llvm.ssub.with.overflow.i32(i32 %a, i32 %b) nounwind 22 %val = extractvalue { i32, i1 } %ssub, 0 23 %carry = extractvalue { i32, i1 } %ssub, 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_ssubo_i32: 30define void @v_ssubo_i32(i32 addrspace(1)* %out, i1 addrspace(1)* %carryout, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr) nounwind { 31 %a = load i32, i32 addrspace(1)* %aptr, align 4 32 %b = load i32, i32 addrspace(1)* %bptr, align 4 33 %ssub = call { i32, i1 } @llvm.ssub.with.overflow.i32(i32 %a, i32 %b) nounwind 34 %val = extractvalue { i32, i1 } %ssub, 0 35 %carry = extractvalue { i32, i1 } %ssub, 1 36 store i32 %val, i32 addrspace(1)* %out, align 4 37 store i1 %carry, i1 addrspace(1)* %carryout 38 ret void 39} 40 41; FUNC-LABEL: {{^}}s_ssubo_i64: 42; SI: s_sub_u32 43; SI: s_subb_u32 44define void @s_ssubo_i64(i64 addrspace(1)* %out, i1 addrspace(1)* %carryout, i64 %a, i64 %b) nounwind { 45 %ssub = call { i64, i1 } @llvm.ssub.with.overflow.i64(i64 %a, i64 %b) nounwind 46 %val = extractvalue { i64, i1 } %ssub, 0 47 %carry = extractvalue { i64, i1 } %ssub, 1 48 store i64 %val, i64 addrspace(1)* %out, align 8 49 store i1 %carry, i1 addrspace(1)* %carryout 50 ret void 51} 52 53; FUNC-LABEL: {{^}}v_ssubo_i64: 54; SI: v_sub_i32_e32 55; SI: v_subb_u32_e32 56define void @v_ssubo_i64(i64 addrspace(1)* %out, i1 addrspace(1)* %carryout, i64 addrspace(1)* %aptr, i64 addrspace(1)* %bptr) nounwind { 57 %a = load i64, i64 addrspace(1)* %aptr, align 4 58 %b = load i64, i64 addrspace(1)* %bptr, align 4 59 %ssub = call { i64, i1 } @llvm.ssub.with.overflow.i64(i64 %a, i64 %b) nounwind 60 %val = extractvalue { i64, i1 } %ssub, 0 61 %carry = extractvalue { i64, i1 } %ssub, 1 62 store i64 %val, i64 addrspace(1)* %out, align 8 63 store i1 %carry, i1 addrspace(1)* %carryout 64 ret void 65} 66