mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
[DAGCombine] (addcarry 0, 0, X) -> (ext/trunc X)
Summary: While this makes some case better and some case worse - so it's unclear if it is a worthy combine just by itself - this is a useful canonicalisation. As per discussion in D32756 . Reviewers: jyknight, nemanjai, mkuper, spatel, RKSimon, zvi, bkramer Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32916 llvm-svn: 303441
This commit is contained in:
parent
59ae1d0687
commit
1a98857ddd
@ -2138,6 +2138,17 @@ SDValue DAGCombiner::visitADDCARRY(SDNode *N) {
|
||||
if (isNullConstant(CarryIn))
|
||||
return DAG.getNode(ISD::UADDO, DL, N->getVTList(), N0, N1);
|
||||
|
||||
// fold (addcarry 0, 0, X) -> (and (ext/trunc X), 1) and no carry.
|
||||
if (isNullConstant(N0) && isNullConstant(N1)) {
|
||||
EVT VT = N0.getValueType();
|
||||
EVT CarryVT = CarryIn.getValueType();
|
||||
SDValue CarryExt = DAG.getBoolExtOrTrunc(CarryIn, DL, VT, CarryVT);
|
||||
AddToWorklist(CarryExt.getNode());
|
||||
return CombineTo(N, DAG.getNode(ISD::AND, DL, VT, CarryExt,
|
||||
DAG.getConstant(1, DL, VT)),
|
||||
DAG.getConstant(0, DL, CarryVT));
|
||||
}
|
||||
|
||||
if (SDValue Combined = visitADDCARRYLike(N0, N1, CarryIn, N))
|
||||
return Combined;
|
||||
|
||||
|
@ -86,12 +86,12 @@ entry:
|
||||
define %scalar @pr31719(%scalar* nocapture readonly %this, %scalar %arg.b) {
|
||||
; CHECK-LABEL: pr31719:
|
||||
; CHECK: # BB#0: # %entry
|
||||
; CHECK-NEXT: xorl %r10d, %r10d
|
||||
; CHECK-NEXT: addq 8(%rsi), %rcx
|
||||
; CHECK-NEXT: sbbq %r10, %r10
|
||||
; CHECK-NEXT: andl $1, %r10d
|
||||
; CHECK-NEXT: setb %r10b
|
||||
; CHECK-NEXT: xorl %eax, %eax
|
||||
; CHECK-NEXT: addq 16(%rsi), %r8
|
||||
; CHECK-NEXT: sbbq %rax, %rax
|
||||
; CHECK-NEXT: andl $1, %eax
|
||||
; CHECK-NEXT: setb %al
|
||||
; CHECK-NEXT: addq 24(%rsi), %r9
|
||||
; CHECK-NEXT: addq (%rsi), %rdx
|
||||
; CHECK-NEXT: adcq $0, %rcx
|
||||
@ -190,9 +190,9 @@ entry:
|
||||
define i64 @shiftadd(i64 %a, i64 %b, i64 %c, i64 %d) {
|
||||
; CHECK-LABEL: shiftadd:
|
||||
; CHECK: # BB#0: # %entry
|
||||
; CHECK-NEXT: leaq (%rdx,%rcx), %rax
|
||||
; CHECK-NEXT: addq %rsi, %rdi
|
||||
; CHECK-NEXT: adcq %rcx, %rdx
|
||||
; CHECK-NEXT: movq %rdx, %rax
|
||||
; CHECK-NEXT: adcq $0, %rax
|
||||
; CHECK-NEXT: retq
|
||||
entry:
|
||||
%0 = zext i64 %a to i128
|
||||
@ -213,12 +213,12 @@ define %S @readd(%S* nocapture readonly %this, %S %arg.b) {
|
||||
; CHECK-NEXT: addq (%rsi), %rdx
|
||||
; CHECK-NEXT: movq 8(%rsi), %r10
|
||||
; CHECK-NEXT: adcq $0, %r10
|
||||
; CHECK-NEXT: sbbq %rax, %rax
|
||||
; CHECK-NEXT: andl $1, %eax
|
||||
; CHECK-NEXT: setb %al
|
||||
; CHECK-NEXT: movzbl %al, %eax
|
||||
; CHECK-NEXT: addq %rcx, %r10
|
||||
; CHECK-NEXT: adcq 16(%rsi), %rax
|
||||
; CHECK-NEXT: sbbq %rcx, %rcx
|
||||
; CHECK-NEXT: andl $1, %ecx
|
||||
; CHECK-NEXT: setb %cl
|
||||
; CHECK-NEXT: movzbl %cl, %ecx
|
||||
; CHECK-NEXT: addq %r8, %rax
|
||||
; CHECK-NEXT: adcq 24(%rsi), %rcx
|
||||
; CHECK-NEXT: addq %r9, %rcx
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -138,18 +138,17 @@ define void @test(i256* %a, i256* %b, i256* %out) #0 {
|
||||
; X32-NEXT: adcl $0, %edi
|
||||
; X32-NEXT: movl {{[0-9]+}}(%esp), %ebx
|
||||
; X32-NEXT: adcl $0, %ebx
|
||||
; X32-NEXT: xorl %edx, %edx
|
||||
; X32-NEXT: addl %ecx, %edi
|
||||
; X32-NEXT: adcl %eax, %ebx
|
||||
; X32-NEXT: adcl $0, %edx
|
||||
; X32-NEXT: sbbl %eax, %eax
|
||||
; X32-NEXT: andl $1, %eax
|
||||
; X32-NEXT: setb %al
|
||||
; X32-NEXT: addl {{[0-9]+}}(%esp), %edi
|
||||
; X32-NEXT: adcl {{[0-9]+}}(%esp), %ebx
|
||||
; X32-NEXT: adcl {{[0-9]+}}(%esp), %edx
|
||||
; X32-NEXT: movl %edx, {{[0-9]+}}(%esp) # 4-byte Spill
|
||||
; X32-NEXT: movzbl %al, %eax
|
||||
; X32-NEXT: adcl {{[0-9]+}}(%esp), %eax
|
||||
; X32-NEXT: movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
|
||||
; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
|
||||
; X32-NEXT: adcl $0, %eax
|
||||
; X32-NEXT: movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
|
||||
; X32-NEXT: leal {{[0-9]+}}(%esp), %eax
|
||||
; X32-NEXT: pushl {{[0-9]+}}(%esp) # 4-byte Folded Reload
|
||||
; X32-NEXT: pushl {{[0-9]+}}(%esp) # 4-byte Folded Reload
|
||||
@ -205,76 +204,70 @@ define void @test(i256* %a, i256* %b, i256* %out) #0 {
|
||||
; X64-NEXT: pushq %r14
|
||||
; X64-NEXT: .Lcfi1:
|
||||
; X64-NEXT: .cfi_def_cfa_offset 24
|
||||
; X64-NEXT: pushq %r12
|
||||
; X64-NEXT: pushq %rbx
|
||||
; X64-NEXT: .Lcfi2:
|
||||
; X64-NEXT: .cfi_def_cfa_offset 32
|
||||
; X64-NEXT: pushq %rbx
|
||||
; X64-NEXT: .Lcfi3:
|
||||
; X64-NEXT: .cfi_def_cfa_offset 40
|
||||
; X64-NEXT: .cfi_offset %rbx, -32
|
||||
; X64-NEXT: .Lcfi4:
|
||||
; X64-NEXT: .cfi_offset %rbx, -40
|
||||
; X64-NEXT: .Lcfi5:
|
||||
; X64-NEXT: .cfi_offset %r12, -32
|
||||
; X64-NEXT: .Lcfi6:
|
||||
; X64-NEXT: .cfi_offset %r14, -24
|
||||
; X64-NEXT: .Lcfi7:
|
||||
; X64-NEXT: .Lcfi5:
|
||||
; X64-NEXT: .cfi_offset %r15, -16
|
||||
; X64-NEXT: movq %rdx, %r9
|
||||
; X64-NEXT: movq (%rdi), %r14
|
||||
; X64-NEXT: movq (%rdi), %r11
|
||||
; X64-NEXT: movq 8(%rdi), %r8
|
||||
; X64-NEXT: movq 16(%rdi), %rcx
|
||||
; X64-NEXT: movq 16(%rsi), %rbx
|
||||
; X64-NEXT: movq (%rsi), %r12
|
||||
; X64-NEXT: movq 16(%rdi), %rbx
|
||||
; X64-NEXT: movq 16(%rsi), %r10
|
||||
; X64-NEXT: movq (%rsi), %rcx
|
||||
; X64-NEXT: movq 8(%rsi), %r15
|
||||
; X64-NEXT: movq 24(%rdi), %rdi
|
||||
; X64-NEXT: imulq %r12, %rdi
|
||||
; X64-NEXT: movq %r12, %rax
|
||||
; X64-NEXT: mulq %rcx
|
||||
; X64-NEXT: movq %rax, %r10
|
||||
; X64-NEXT: imulq %rcx, %rdi
|
||||
; X64-NEXT: movq %rcx, %rax
|
||||
; X64-NEXT: mulq %rbx
|
||||
; X64-NEXT: movq %rax, %r14
|
||||
; X64-NEXT: addq %rdi, %rdx
|
||||
; X64-NEXT: imulq %r15, %rcx
|
||||
; X64-NEXT: addq %rdx, %rcx
|
||||
; X64-NEXT: movq %rbx, %rdi
|
||||
; X64-NEXT: imulq %r8, %rdi
|
||||
; X64-NEXT: movq %rbx, %rax
|
||||
; X64-NEXT: mulq %r14
|
||||
; X64-NEXT: movq %rax, %r11
|
||||
; X64-NEXT: addq %rdi, %rdx
|
||||
; X64-NEXT: movq 24(%rsi), %rbx
|
||||
; X64-NEXT: imulq %r14, %rbx
|
||||
; X64-NEXT: imulq %r15, %rbx
|
||||
; X64-NEXT: addq %rdx, %rbx
|
||||
; X64-NEXT: addq %r10, %r11
|
||||
; X64-NEXT: adcq %rcx, %rbx
|
||||
; X64-NEXT: movq %r14, %rax
|
||||
; X64-NEXT: mulq %r12
|
||||
; X64-NEXT: movq %rdx, %rsi
|
||||
; X64-NEXT: movq %r10, %rdi
|
||||
; X64-NEXT: imulq %r8, %rdi
|
||||
; X64-NEXT: movq %r10, %rax
|
||||
; X64-NEXT: mulq %r11
|
||||
; X64-NEXT: movq %rax, %r10
|
||||
; X64-NEXT: movq %r8, %rax
|
||||
; X64-NEXT: mulq %r12
|
||||
; X64-NEXT: movq %rdx, %rcx
|
||||
; X64-NEXT: movq %rax, %rdi
|
||||
; X64-NEXT: addq %rsi, %rdi
|
||||
; X64-NEXT: adcq $0, %rcx
|
||||
; X64-NEXT: movq %r14, %rax
|
||||
; X64-NEXT: mulq %r15
|
||||
; X64-NEXT: addq %rdi, %rdx
|
||||
; X64-NEXT: movq 24(%rsi), %rdi
|
||||
; X64-NEXT: imulq %r11, %rdi
|
||||
; X64-NEXT: addq %rdx, %rdi
|
||||
; X64-NEXT: addq %r14, %r10
|
||||
; X64-NEXT: adcq %rbx, %rdi
|
||||
; X64-NEXT: movq %r11, %rax
|
||||
; X64-NEXT: mulq %rcx
|
||||
; X64-NEXT: movq %rdx, %rsi
|
||||
; X64-NEXT: movq %rax, %r14
|
||||
; X64-NEXT: addq %rdi, %r14
|
||||
; X64-NEXT: movq %r8, %rax
|
||||
; X64-NEXT: mulq %rcx
|
||||
; X64-NEXT: movq %rdx, %rcx
|
||||
; X64-NEXT: movq %rax, %rbx
|
||||
; X64-NEXT: addq %rsi, %rbx
|
||||
; X64-NEXT: adcq $0, %rcx
|
||||
; X64-NEXT: movq %r11, %rax
|
||||
; X64-NEXT: mulq %r15
|
||||
; X64-NEXT: movq %rdx, %rsi
|
||||
; X64-NEXT: movq %rax, %r11
|
||||
; X64-NEXT: addq %rbx, %r11
|
||||
; X64-NEXT: adcq %rcx, %rsi
|
||||
; X64-NEXT: sbbq %rcx, %rcx
|
||||
; X64-NEXT: andl $1, %ecx
|
||||
; X64-NEXT: setb %al
|
||||
; X64-NEXT: movzbl %al, %ecx
|
||||
; X64-NEXT: movq %r8, %rax
|
||||
; X64-NEXT: mulq %r15
|
||||
; X64-NEXT: addq %rsi, %rax
|
||||
; X64-NEXT: adcq %rcx, %rdx
|
||||
; X64-NEXT: addq %r11, %rax
|
||||
; X64-NEXT: adcq %rbx, %rdx
|
||||
; X64-NEXT: movq %r10, (%r9)
|
||||
; X64-NEXT: movq %r14, 8(%r9)
|
||||
; X64-NEXT: addq %r10, %rax
|
||||
; X64-NEXT: adcq %rdi, %rdx
|
||||
; X64-NEXT: movq %r14, (%r9)
|
||||
; X64-NEXT: movq %r11, 8(%r9)
|
||||
; X64-NEXT: movq %rax, 16(%r9)
|
||||
; X64-NEXT: movq %rdx, 24(%r9)
|
||||
; X64-NEXT: popq %rbx
|
||||
; X64-NEXT: popq %r12
|
||||
; X64-NEXT: popq %r14
|
||||
; X64-NEXT: popq %r15
|
||||
; X64-NEXT: retq
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -27,16 +27,14 @@ define i128 @mulhioverflow(i64 %a, i64 %b, i64 %c) nounwind {
|
||||
; X32-NEXT: addl $32, %esp
|
||||
; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
|
||||
; X32-NEXT: andl $1, %edi
|
||||
; X32-NEXT: xorl %ecx, %ecx
|
||||
; X32-NEXT: addl {{[0-9]+}}(%esp), %edi
|
||||
; X32-NEXT: adcl $0, %eax
|
||||
; X32-NEXT: adcl $0, %ecx
|
||||
; X32-NEXT: sbbl %edx, %edx
|
||||
; X32-NEXT: andl $1, %edx
|
||||
; X32-NEXT: setb %cl
|
||||
; X32-NEXT: movzbl %cl, %ecx
|
||||
; X32-NEXT: movl %edi, (%esi)
|
||||
; X32-NEXT: movl %eax, 4(%esi)
|
||||
; X32-NEXT: movl %ecx, 8(%esi)
|
||||
; X32-NEXT: movl %edx, 12(%esi)
|
||||
; X32-NEXT: movl $0, 12(%esi)
|
||||
; X32-NEXT: movl %esi, %eax
|
||||
; X32-NEXT: leal -8(%ebp), %esp
|
||||
; X32-NEXT: popl %esi
|
||||
|
Loading…
Reference in New Issue
Block a user