[PATCH] D30436: [SelectionDAG] Make SelectionDAG aware of the known bits in USUBO and SSUBO and SUBC.

Amaury SECHET via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 10 09:38:54 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL297482: [SelectionDAG] Make SelectionDAG aware of the known bits in USUBO and SSUBO and… (authored by deadalnix).

Changed prior to commit:
  https://reviews.llvm.org/D30436?vs=91365&id=91368#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30436

Files:
  llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  llvm/trunk/test/CodeGen/X86/known-bits.ll


Index: llvm/trunk/test/CodeGen/X86/known-bits.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/known-bits.ll
+++ llvm/trunk/test/CodeGen/X86/known-bits.ll
@@ -247,11 +247,11 @@
 ; X64:       # BB#0:
 ; X64-NEXT:    shlq $32, %rdi
 ; X64-NEXT:    shlq $32, %rsi
-; X64-NEXT:    subq %rsi, %rdi
-; X64-NEXT:    setb %cl
+; X64-NEXT:    cmpq %rsi, %rdi
+; X64-NEXT:    setb %al
 ; X64-NEXT:    seto %dl
-; X64-NEXT:    leal (%rdi,%rdi), %eax
-; X64-NEXT:    orb %cl, %dl
+; X64-NEXT:    orb %al, %dl
+; X64-NEXT:    xorl %eax, %eax
 ; X64-NEXT:    retq
   %1 = shl i64 %a0, 32
   %2 = shl i64 %a1, 32
Index: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -2297,8 +2297,6 @@
     KnownOne &= KnownOne2;
     KnownZero &= KnownZero2;
     break;
-  case ISD::SSUBO:
-  case ISD::USUBO:
   case ISD::SMULO:
   case ISD::UMULO:
     if (Op.getResNo() != 1)
@@ -2493,8 +2491,19 @@
     // All bits are zero except the low bit.
     KnownZero = APInt::getHighBitsSet(BitWidth, BitWidth - 1);
     break;
-
-  case ISD::SUB: {
+  case ISD::USUBO:
+  case ISD::SSUBO:
+    if (Op.getResNo() == 1) {
+      // If we know the result of a setcc has the top bits zero, use this info.
+      if (TLI->getBooleanContents(Op.getOperand(0).getValueType()) ==
+              TargetLowering::ZeroOrOneBooleanContent &&
+          BitWidth > 1)
+        KnownZero.setBits(1, BitWidth);
+      break;
+    }
+    LLVM_FALLTHROUGH;
+  case ISD::SUB:
+  case ISD::SUBC: {
     if (ConstantSDNode *CLHS = isConstOrConstSplat(Op.getOperand(0))) {
       // We know that the top bits of C-X are clear if X contains less bits
       // than C (i.e. no wrap-around can happen).  For example, 20-X is


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30436.91368.patch
Type: text/x-patch
Size: 1915 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170310/0ea93d1c/attachment.bin>


More information about the llvm-commits mailing list