[PATCH] D120435: [X86] Combine ADC(ADD(X,Y),0,Carry) -> ADC(X,Y,Carry)
Paweł Bylica via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 25 05:31:54 PST 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeb1ff70fc5fc: [X86] Combine ADC(ADD(X,Y),0,Carry) -> ADC(X,Y,Carry) (authored by chfast).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120435/new/
https://reviews.llvm.org/D120435
Files:
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/addcarry.ll
Index: llvm/test/CodeGen/X86/addcarry.ll
===================================================================
--- llvm/test/CodeGen/X86/addcarry.ll
+++ llvm/test/CodeGen/X86/addcarry.ll
@@ -1366,11 +1366,9 @@
define i32 @addcarry_ult(i32 %a, i32 %b, i32 %x, i32 %y) {
; CHECK-LABEL: addcarry_ult:
; CHECK: # %bb.0:
-; CHECK-NEXT: # kill: def $esi killed $esi def $rsi
-; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
-; CHECK-NEXT: leal (%rdi,%rsi), %eax
+; CHECK-NEXT: movl %edi, %eax
; CHECK-NEXT: cmpl %ecx, %edx
-; CHECK-NEXT: adcl $0, %eax
+; CHECK-NEXT: adcl %esi, %eax
; CHECK-NEXT: retq
%s = add i32 %a, %b
%k = icmp ult i32 %x, %y
@@ -1382,11 +1380,9 @@
define i32 @addcarry_ugt(i32 %a, i32 %b, i32 %x, i32 %y) {
; CHECK-LABEL: addcarry_ugt:
; CHECK: # %bb.0:
-; CHECK-NEXT: # kill: def $esi killed $esi def $rsi
-; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
-; CHECK-NEXT: leal (%rdi,%rsi), %eax
+; CHECK-NEXT: movl %edi, %eax
; CHECK-NEXT: cmpl %edx, %ecx
-; CHECK-NEXT: adcl $0, %eax
+; CHECK-NEXT: adcl %esi, %eax
; CHECK-NEXT: retq
%s = add i32 %a, %b
%k = icmp ugt i32 %x, %y
Index: llvm/lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- llvm/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -52150,6 +52150,13 @@
return DAG.getNode(X86ISD::ADC, SDLoc(N), VTs, LHS, RHS, Flags);
}
+ // Fold ADC(ADD(X,Y),0,Carry) -> ADC(X,Y,Carry)
+ // iff the flag result is dead.
+ if (LHS.getOpcode() == ISD::ADD && isNullConstant(RHS) &&
+ !N->hasAnyUseOfValue(1))
+ return DAG.getNode(X86ISD::ADC, SDLoc(N), N->getVTList(), LHS.getOperand(0),
+ LHS.getOperand(1), CarryIn);
+
return SDValue();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120435.411390.patch
Type: text/x-patch
Size: 1830 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220225/284db55c/attachment.bin>
More information about the llvm-commits
mailing list