diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/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; } diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp --- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp +++ b/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; } diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/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) {