[PATCH] D133469: [X86] Fold SUB(SBB(X,0,W), Y) -> SBB(X,Y,W)
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 7 21:26:07 PDT 2022
craig.topper created this revision.
craig.topper added reviewers: RKSimon, spatel.
Herald added subscribers: StephenFan, pengfei, hiraditya.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added a project: LLVM.
Fixes PR57576.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D133469
Files:
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/pr57576.ll
Index: llvm/test/CodeGen/X86/pr57576.ll
===================================================================
--- llvm/test/CodeGen/X86/pr57576.ll
+++ llvm/test/CodeGen/X86/pr57576.ll
@@ -6,8 +6,7 @@
; CHECK: # %bb.0:
; CHECK-NEXT: movq %rdi, %rax
; CHECK-NEXT: subq %rdx, %rax
-; CHECK-NEXT: sbbq $0, %rsi
-; CHECK-NEXT: subq %rcx, %rsi
+; CHECK-NEXT: sbbq %rcx, %rsi
; CHECK-NEXT: movq %rsi, %rdx
; CHECK-NEXT: retq
%5 = zext i64 %1 to i128
Index: llvm/lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- llvm/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -53951,6 +53951,14 @@
Op1.getOperand(0), Op1.getOperand(2));
}
+ // Fold SUB(SBB(X,0,W), Y) -> SBB(X,Y,W)
+ if (Op0.getOpcode() == X86ISD::SBB && Op0->hasOneUse() &&
+ X86::isZeroNode(Op0.getOperand(1))) {
+ assert(!Op0->hasAnyUseOfValue(1) && "Overflow bit in use");
+ return DAG.getNode(X86ISD::SBB, SDLoc(Op1), Op0->getVTList(),
+ Op0.getOperand(0), Op1, Op0.getOperand(2));
+ }
+
// Fold SUB(X,SBB(Y,Z,W)) -> SUB(ADC(X,Z,W),Y)
// Don't fold to ADC(0,0,W)/SETCC_CARRY pattern which will prevent more folds.
if (Op1.getOpcode() == X86ISD::SBB && Op1->hasOneUse() &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133469.458637.patch
Type: text/x-patch
Size: 1324 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220908/386ff3dd/attachment.bin>
More information about the llvm-commits
mailing list