[llvm] r301919 - [DAGCombine] (add X, (addcarry Y, 0, Carry)) -> (addcarry X, Y, Carry)
Amaury Sechet via llvm-commits
llvm-commits at lists.llvm.org
Tue May 2 06:34:25 PDT 2017
Author: deadalnix
Date: Tue May 2 08:34:25 2017
New Revision: 301919
URL: http://llvm.org/viewvc/llvm-project?rev=301919&view=rev
Log:
[DAGCombine] (add X, (addcarry Y, 0, Carry)) -> (addcarry X, Y, Carry)
Summary: Common pattern when legalizing large integers operations. Similar to D32687, when the carry isn't used.
Reviewers: jyknight, nemanjai, mkuper, spatel, RKSimon, zvi, bkramer
Differential Revision: https://reviews.llvm.org/D32738
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/trunk/test/CodeGen/X86/adde-carry.ll
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=301919&r1=301918&r2=301919&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Tue May 2 08:34:25 2017
@@ -2015,6 +2015,11 @@ SDValue DAGCombiner::visitADDLike(SDValu
}
}
+ // (add X, (addcarry Y, 0, Carry)) -> (addcarry X, Y, Carry)
+ if (N1.getOpcode() == ISD::ADDCARRY && isNullConstant(N1.getOperand(1)))
+ return DAG.getNode(ISD::ADDCARRY, DL, N1->getVTList(),
+ N0, N1.getOperand(0), N1.getOperand(2));
+
return SDValue();
}
Modified: llvm/trunk/test/CodeGen/X86/adde-carry.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/adde-carry.ll?rev=301919&r1=301918&r2=301919&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/adde-carry.ll (original)
+++ llvm/trunk/test/CodeGen/X86/adde-carry.ll Tue May 2 08:34:25 2017
@@ -47,7 +47,7 @@ define void @c(i16* nocapture %r, i64 %a
; CHECK-LABEL: c:
; CHECK: # BB#0: # %entry
; CHECK-NEXT: addq %rdx, %rsi
-; CHECK-NEXT: adcl $0, %ecx
+; CHECK-NEXT: adcw $0, %cx
; CHECK-NEXT: movw %cx, (%rdi)
; CHECK-NEXT: retq
entry:
@@ -66,7 +66,7 @@ define void @d(i8* nocapture %r, i64 %a,
; CHECK-LABEL: d:
; CHECK: # BB#0: # %entry
; CHECK-NEXT: addq %rdx, %rsi
-; CHECK-NEXT: adcl $0, %ecx
+; CHECK-NEXT: adcb $0, %cl
; CHECK-NEXT: movb %cl, (%rdi)
; CHECK-NEXT: retq
entry:
@@ -90,17 +90,16 @@ define %scalar @pr31719(%scalar* nocaptu
; CHECK-NEXT: sbbq %r10, %r10
; CHECK-NEXT: andl $1, %r10d
; CHECK-NEXT: addq 8(%rsi), %rcx
-; CHECK-NEXT: sbbq %r11, %r11
-; CHECK-NEXT: andl $1, %r11d
-; CHECK-NEXT: addq %r10, %rcx
-; CHECK-NEXT: adcq $0, %r11
-; CHECK-NEXT: addq 16(%rsi), %r8
; CHECK-NEXT: sbbq %rax, %rax
; CHECK-NEXT: andl $1, %eax
-; CHECK-NEXT: addq %r11, %r8
+; CHECK-NEXT: addq %r10, %rcx
; CHECK-NEXT: adcq $0, %rax
+; CHECK-NEXT: addq 16(%rsi), %r8
+; CHECK-NEXT: sbbq %r10, %r10
+; CHECK-NEXT: andl $1, %r10d
; CHECK-NEXT: addq 24(%rsi), %r9
-; CHECK-NEXT: addq %rax, %r9
+; CHECK-NEXT: addq %rax, %r8
+; CHECK-NEXT: adcq %r10, %r9
; CHECK-NEXT: movq %rdx, (%rdi)
; CHECK-NEXT: movq %rcx, 8(%rdi)
; CHECK-NEXT: movq %r8, 16(%rdi)
@@ -163,8 +162,7 @@ define void @muladd(%accumulator* nocapt
; CHECK-NEXT: movq %rax, (%rdi)
; CHECK-NEXT: addq 8(%rdi), %rdx
; CHECK-NEXT: movq %rdx, 8(%rdi)
-; CHECK-NEXT: sbbl %eax, %eax
-; CHECK-NEXT: subl %eax, 16(%rdi)
+; CHECK-NEXT: adcl $0, 16(%rdi)
; CHECK-NEXT: retq
entry:
%0 = zext i64 %arg.a to i128
More information about the llvm-commits
mailing list