[llvm] r372258 - [CodeGen][X86][NFC] Tests for (sub Carry, X) -> (addcarry (sub 0, X), 0, Carry) fold (D62392)
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 18 13:48:06 PDT 2019
Author: lebedevri
Date: Wed Sep 18 13:48:05 2019
New Revision: 372258
URL: http://llvm.org/viewvc/llvm-project?rev=372258&view=rev
Log:
[CodeGen][X86][NFC] Tests for (sub Carry, X) -> (addcarry (sub 0, X), 0, Carry) fold (D62392)
Modified:
llvm/trunk/test/CodeGen/X86/subcarry.ll
Modified: llvm/trunk/test/CodeGen/X86/subcarry.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/subcarry.ll?rev=372258&r1=372257&r2=372258&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/subcarry.ll (original)
+++ llvm/trunk/test/CodeGen/X86/subcarry.ll Wed Sep 18 13:48:05 2019
@@ -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
+}
More information about the llvm-commits
mailing list