]> granicus.if.org Git - llvm/commitdiff
Add ADDC to SelectionDAG::computeKnownBits and ComputeNumSignBits.
authorAmaury Sechet <deadalnix@gmail.com>
Mon, 6 Feb 2017 14:59:06 +0000 (14:59 +0000)
committerAmaury Sechet <deadalnix@gmail.com>
Mon, 6 Feb 2017 14:59:06 +0000 (14:59 +0000)
Summary: As per title.

Reviewers: bkramer, sunfish, lattner, RKSimon

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D29521

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294188 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/SelectionDAG.cpp
test/CodeGen/X86/known-bits.ll

index b9f6fc0f1ab6805417e0ac2cc72be34f0ee52df0..9e802b99ed4a838d855b7c6943a7932d93a5f39f 100644 (file)
@@ -2506,6 +2506,7 @@ void SelectionDAG::computeKnownBits(SDValue Op, APInt &KnownZero,
     LLVM_FALLTHROUGH;
   }
   case ISD::ADD:
+  case ISD::ADDC:
   case ISD::ADDE: {
     // Output known-0 bits are known if clear or set in both the low clear bits
     // common to both LHS & RHS.  For example, 8+(X<<3) is known to have the
@@ -2526,7 +2527,7 @@ void SelectionDAG::computeKnownBits(SDValue Op, APInt &KnownZero,
     KnownZeroLow = std::min(KnownZeroLow,
                             KnownZero2.countTrailingOnes());
 
-    if (Opcode == ISD::ADD) {
+    if (Opcode == ISD::ADD || Opcode == ISD::ADDC) {
       KnownZero |= APInt::getLowBitsSet(BitWidth, KnownZeroLow);
       if (KnownZeroHigh > 1)
         KnownZero |= APInt::getHighBitsSet(BitWidth, KnownZeroHigh - 1);
@@ -2945,6 +2946,7 @@ unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, unsigned Depth) const {
     }
     break;
   case ISD::ADD:
+  case ISD::ADDC:
     // Add can have at most one carry bit.  Thus we know that the output
     // is, at worst, one more bit than the inputs.
     Tmp = ComputeNumSignBits(Op.getOperand(0), Depth+1);
index cd39b441a0eb88d0898e57bdbb8e4874665b9324..f3fa12700f9ea3cd318f37537b19ccef5cca9610 100644 (file)
@@ -138,10 +138,9 @@ define i128 @knownbits_mask_addc_shl(i64 %a0, i64 %a1, i64 %a2) nounwind {
 ; X32-NEXT:    adcl $0, %ecx
 ; X32-NEXT:    shldl $22, %edx, %ecx
 ; X32-NEXT:    shldl $22, %esi, %edx
-; X32-NEXT:    shll $22, %esi
-; X32-NEXT:    movl %esi, 4(%eax)
 ; X32-NEXT:    movl %edx, 8(%eax)
 ; X32-NEXT:    movl %ecx, 12(%eax)
+; X32-NEXT:    movl $0, 4(%eax)
 ; X32-NEXT:    movl $0, (%eax)
 ; X32-NEXT:    popl %esi
 ; X32-NEXT:    popl %edi
@@ -155,8 +154,7 @@ define i128 @knownbits_mask_addc_shl(i64 %a0, i64 %a1, i64 %a2) nounwind {
 ; X64-NEXT:    sbbq %rax, %rax
 ; X64-NEXT:    subl %eax, %edx
 ; X64-NEXT:    shldq $54, %rsi, %rdx
-; X64-NEXT:    shlq $54, %rsi
-; X64-NEXT:    movq %rsi, %rax
+; X64-NEXT:    xorl %eax, %eax
 ; X64-NEXT:    retq
   %1 = and i64 %a0, -1024
   %2 = zext i64 %1 to i128