[llvm] r299973 - [X86] Create the correct ADC/SBB SDNode when lowering add.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 11 12:11:20 PDT 2017
Author: davide
Date: Tue Apr 11 14:11:20 2017
New Revision: 299973
URL: http://llvm.org/viewvc/llvm-project?rev=299973&view=rev
Log:
[X86] Create the correct ADC/SBB SDNode when lowering add.
Differential Revision: https://reviews.llvm.org/D31911
Added:
llvm/trunk/test/CodeGen/X86/pr32588.ll
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=299973&r1=299972&r2=299973&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Tue Apr 11 14:11:20 2017
@@ -34606,15 +34606,17 @@ static SDValue combineAddOrSubToADCOrSBB
SDValue NewCmp = DAG.getNode(X86ISD::CMP, DL, MVT::i32, Z,
DAG.getConstant(1, DL, Z.getValueType()));
+ SDVTList VTs = DAG.getVTList(N->getValueType(0), MVT::i32);
+
// X - (Z != 0) --> sub X, (zext(setne Z, 0)) --> adc X, -1, (cmp Z, 1)
// X + (Z != 0) --> add X, (zext(setne Z, 0)) --> sbb X, -1, (cmp Z, 1)
if (CC == X86::COND_NE)
- return DAG.getNode(IsSub ? X86ISD::ADC : X86ISD::SBB, DL, VT, X,
+ return DAG.getNode(IsSub ? X86ISD::ADC : X86ISD::SBB, DL, VTs, X,
DAG.getConstant(-1ULL, DL, VT), NewCmp);
// X - (Z == 0) --> sub X, (zext(sete Z, 0)) --> sbb X, 0, (cmp Z, 1)
// X + (Z == 0) --> add X, (zext(sete Z, 0)) --> adc X, 0, (cmp Z, 1)
- return DAG.getNode(IsSub ? X86ISD::SBB : X86ISD::ADC, DL, VT, X,
+ return DAG.getNode(IsSub ? X86ISD::SBB : X86ISD::ADC, DL, VTs, X,
DAG.getConstant(0, DL, VT), NewCmp);
}
Added: llvm/trunk/test/CodeGen/X86/pr32588.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pr32588.ll?rev=299973&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/pr32588.ll (added)
+++ llvm/trunk/test/CodeGen/X86/pr32588.ll Tue Apr 11 14:11:20 2017
@@ -0,0 +1,27 @@
+; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux | FileCheck %s
+
+ at c = external local_unnamed_addr global i32, align 4
+ at b = external local_unnamed_addr global i32, align 4
+ at d = external local_unnamed_addr global i32, align 4
+
+; CHECK: cmpl $1, c(%rip)
+; CHECK-NEXT: sbbl %eax, %eax
+; CHECK-NEXT: andl $1, %eax
+; CHECK-NEXT: movl %eax, d(%rip)
+; CHECK-NEXT: retq
+
+define void @fn1() {
+entry:
+ %0 = load i32, i32* @c, align 4
+ %tobool1 = icmp eq i32 %0, 0
+ %xor = zext i1 %tobool1 to i32
+ %1 = load i32, i32* @b, align 4
+ %tobool2 = icmp ne i32 %1, 0
+ %tobool4 = icmp ne i32 undef, 0
+ %2 = and i1 %tobool4, %tobool2
+ %sub = sext i1 %2 to i32
+ %div = sdiv i32 %sub, 2
+ %add = add nsw i32 %div, %xor
+ store i32 %add, i32* @d, align 4
+ ret void
+}
More information about the llvm-commits
mailing list