Add test case for add to sub post legalization. NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355797 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Amaury Sechet 2019-03-11 01:25:48 +00:00
parent 7ddc0aad26
commit 5ddf9b4b32

View File

@ -386,3 +386,29 @@ define i128 @addcarry1_not(i128 %n) {
%2 = add i128 %1, 1
ret i128 %2
}
define i128 @addcarry_to_subcarry(i64 %a, i64 %b) {
; CHECK-LABEL: addcarry_to_subcarry:
; CHECK: # %bb.0:
; CHECK-NEXT: notq %rsi
; CHECK-NEXT: xorl %eax, %eax
; CHECK-NEXT: movq %rdi, %rcx
; CHECK-NEXT: addq %rsi, %rcx
; CHECK-NEXT: setb %al
; CHECK-NEXT: addq $1, %rcx
; CHECK-NEXT: adcq %rdi, %rax
; CHECK-NEXT: setb %cl
; CHECK-NEXT: movzbl %cl, %edx
; CHECK-NEXT: addq %rsi, %rax
; CHECK-NEXT: adcq $0, %rdx
; CHECK-NEXT: retq
%notb = xor i64 %b, -1
%notb128 = zext i64 %notb to i128
%a128 = zext i64 %a to i128
%sum1 = add i128 %a128, 1
%sub1 = add i128 %sum1, %notb128
%hi = lshr i128 %sub1, 64
%sum2 = add i128 %hi, %a128
%sub2 = add i128 %sum2, %notb128
ret i128 %sub2
}