From: Roman Lebedev Date: Wed, 18 Sep 2019 20:48:05 +0000 (+0000) Subject: [CodeGen][X86][NFC] Tests for (sub Carry, X) -> (addcarry (sub 0, X), 0, Carry) fold... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7901366bd98c4db4ecddc235100df26638e6a1dc;p=llvm [CodeGen][X86][NFC] Tests for (sub Carry, X) -> (addcarry (sub 0, X), 0, Carry) fold (D62392) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372258 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/CodeGen/X86/subcarry.ll b/test/CodeGen/X86/subcarry.ll index 449391616aa..d5f1d556d76 100644 --- a/test/CodeGen/X86/subcarry.ll +++ b/test/CodeGen/X86/subcarry.ll @@ -162,3 +162,24 @@ entry: %40 = insertvalue %S undef, [4 x i64] %39, 0 ret %S %40 } + +declare {i64, i1} @llvm.uadd.with.overflow(i64, i64) +declare {i64, i1} @llvm.usub.with.overflow(i64, i64) + +define i64 @sub_from_carry(i64 %x, i64 %y, i64* %valout, i64 %z) { +; CHECK-LABEL: sub_from_carry: +; CHECK: # %bb.0: +; CHECK-NEXT: xorl %eax, %eax +; CHECK-NEXT: addq %rsi, %rdi +; CHECK-NEXT: setb %al +; CHECK-NEXT: movq %rdi, (%rdx) +; CHECK-NEXT: subq %rcx, %rax +; CHECK-NEXT: retq + %agg = call {i64, i1} @llvm.uadd.with.overflow(i64 %x, i64 %y) + %val = extractvalue {i64, i1} %agg, 0 + %ov = extractvalue {i64, i1} %agg, 1 + store i64 %val, i64* %valout, align 4 + %carry = zext i1 %ov to i64 + %res = sub i64 %carry, %z + ret i64 %res +}