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 5 declare { i32, i1 } @llvm.uadd.with.overflow.i32(i32, i32) nounwind readnone 6 declare { i64, i1 } @llvm.uadd.with.overflow.i64(i64, i64) nounwind readnone 7 8 ; FUNC-LABEL: {{^}}uaddo_i64_zext: 9 ; SI: add 10 ; SI: addc 11 ; SI: addc 12 define void @uaddo_i64_zext(i64 addrspace(1)* %out, i64 %a, i64 %b) nounwind { 13 %uadd = call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %a, i64 %b) nounwind 14 %val = extractvalue { i64, i1 } %uadd, 0 15 %carry = extractvalue { i64, i1 } %uadd, 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_uaddo_i32: 23 ; SI: s_add_i32 24 define void @s_uaddo_i32(i32 addrspace(1)* %out, i1 addrspace(1)* %carryout, i32 %a, i32 %b) nounwind { 25 %uadd = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %a, i32 %b) nounwind 26 %val = extractvalue { i32, i1 } %uadd, 0 27 %carry = extractvalue { i32, i1 } %uadd, 1 28 store i32 %val, i32 addrspace(1)* %out, align 4 29 store i1 %carry, i1 addrspace(1)* %carryout 30 ret void 31 } 32 33 ; FUNC-LABEL: {{^}}v_uaddo_i32: 34 ; SI: v_add_i32 35 define void @v_uaddo_i32(i32 addrspace(1)* %out, i1 addrspace(1)* %carryout, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr) nounwind { 36 %a = load i32, i32 addrspace(1)* %aptr, align 4 37 %b = load i32, i32 addrspace(1)* %bptr, align 4 38 %uadd = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %a, i32 %b) nounwind 39 %val = extractvalue { i32, i1 } %uadd, 0 40 %carry = extractvalue { i32, i1 } %uadd, 1 41 store i32 %val, i32 addrspace(1)* %out, align 4 42 store i1 %carry, i1 addrspace(1)* %carryout 43 ret void 44 } 45 46 ; FUNC-LABEL: {{^}}s_uaddo_i64: 47 ; SI: s_add_u32 48 ; SI: s_addc_u32 49 define void @s_uaddo_i64(i64 addrspace(1)* %out, i1 addrspace(1)* %carryout, i64 %a, i64 %b) nounwind { 50 %uadd = call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %a, i64 %b) nounwind 51 %val = extractvalue { i64, i1 } %uadd, 0 52 %carry = extractvalue { i64, i1 } %uadd, 1 53 store i64 %val, i64 addrspace(1)* %out, align 8 54 store i1 %carry, i1 addrspace(1)* %carryout 55 ret void 56 } 57 58 ; FUNC-LABEL: {{^}}v_uaddo_i64: 59 ; SI: v_add_i32 60 ; SI: v_addc_u32 61 define void @v_uaddo_i64(i64 addrspace(1)* %out, i1 addrspace(1)* %carryout, i64 addrspace(1)* %aptr, i64 addrspace(1)* %bptr) nounwind { 62 %a = load i64, i64 addrspace(1)* %aptr, align 4 63 %b = load i64, i64 addrspace(1)* %bptr, align 4 64 %uadd = call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %a, i64 %b) nounwind 65 %val = extractvalue { i64, i1 } %uadd, 0 66 %carry = extractvalue { i64, i1 } %uadd, 1 67 store i64 %val, i64 addrspace(1)* %out, align 8 68 store i1 %carry, i1 addrspace(1)* %carryout 69 ret void 70 } 71