[PATCH] D89964: [WIP][SDag] Allow targets to simplify generic nodes using demanded bits info

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 22 07:35:27 PDT 2020


foad created this revision.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
foad requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89964

Files:
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp


Index: llvm/lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- llvm/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -34058,12 +34058,6 @@
   unsigned NumElts = DemandedElts.getBitWidth();
   unsigned Opc = Op.getOpcode();
   EVT VT = Op.getValueType();
-  assert((Opc >= ISD::BUILTIN_OP_END ||
-          Opc == ISD::INTRINSIC_WO_CHAIN ||
-          Opc == ISD::INTRINSIC_W_CHAIN ||
-          Opc == ISD::INTRINSIC_VOID) &&
-         "Should use MaskedValueIsZero if you don't know whether Op"
-         " is a target node!");
 
   Known.resetAll();
   switch (Opc) {
Index: llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
===================================================================
--- llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -6831,7 +6831,8 @@
 
   // Intrinsic CC result is returned in the two low bits.
   unsigned tmp0, tmp1; // not used
-  if (Op.getResNo() == 1 && isIntrinsicWithCC(Op, tmp0, tmp1)) {
+  if (Op.getResNo() == 1 && Op.getOpcode() == ISD::INTRINSIC_WO_CHAIN &&
+      isIntrinsicWithCC(Op, tmp0, tmp1)) {
     Known.Zero.setBitsFrom(2);
     return;
   }
Index: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -945,6 +945,11 @@
     return false;
   }
 
+  // Give the target a chance, even for generic opcodes.
+  if (SimplifyDemandedBitsForTargetNode(Op, DemandedBits, DemandedElts, Known,
+                                        TLO, Depth))
+    return true;
+
   KnownBits Known2;
   switch (Op.getOpcode()) {
   case ISD::TargetConstant:
@@ -2236,13 +2241,6 @@
     LLVM_FALLTHROUGH;
   }
   default:
-    if (Op.getOpcode() >= ISD::BUILTIN_OP_END) {
-      if (SimplifyDemandedBitsForTargetNode(Op, DemandedBits, DemandedElts,
-                                            Known, TLO, Depth))
-        return true;
-      break;
-    }
-
     // Just use computeKnownBits to compute output bits.
     Known = TLO.DAG.computeKnownBits(Op, DemandedElts, Depth);
     break;
@@ -2906,12 +2904,6 @@
                                                    const APInt &DemandedElts,
                                                    const SelectionDAG &DAG,
                                                    unsigned Depth) const {
-  assert((Op.getOpcode() >= ISD::BUILTIN_OP_END ||
-          Op.getOpcode() == ISD::INTRINSIC_WO_CHAIN ||
-          Op.getOpcode() == ISD::INTRINSIC_W_CHAIN ||
-          Op.getOpcode() == ISD::INTRINSIC_VOID) &&
-         "Should use MaskedValueIsZero if you don't know whether Op"
-         " is a target node!");
   Known.resetAll();
 }
 
@@ -2970,12 +2962,6 @@
 bool TargetLowering::SimplifyDemandedBitsForTargetNode(
     SDValue Op, const APInt &DemandedBits, const APInt &DemandedElts,
     KnownBits &Known, TargetLoweringOpt &TLO, unsigned Depth) const {
-  assert((Op.getOpcode() >= ISD::BUILTIN_OP_END ||
-          Op.getOpcode() == ISD::INTRINSIC_WO_CHAIN ||
-          Op.getOpcode() == ISD::INTRINSIC_W_CHAIN ||
-          Op.getOpcode() == ISD::INTRINSIC_VOID) &&
-         "Should use SimplifyDemandedBits if you don't know whether Op"
-         " is a target node!");
   computeKnownBitsForTargetNode(Op, Known, DemandedElts, TLO.DAG, Depth);
   return false;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89964.299970.patch
Type: text/x-patch
Size: 3480 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201022/b1a8ab5b/attachment.bin>


More information about the llvm-commits mailing list