[TargetLowering] Add depth limit to SimplifyMultipleUseDemandedBits
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 27 Jul 2019 12:23:36 +0000 (12:23 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 27 Jul 2019 12:23:36 +0000 (12:23 +0000)
We're getting reports of massive compile time increases because SimplifyMultipleUseDemandedBits was losing track of the depth and not earlying-out. No repro yet, but consider this a pre-emptive commit.

llvm-svn: 367169

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

index 6bfb388..1173beb 100644 (file)
@@ -569,6 +569,9 @@ bool TargetLowering::SimplifyDemandedBits(SDValue Op, const APInt &DemandedBits,
 SDValue TargetLowering::SimplifyMultipleUseDemandedBits(
     SDValue Op, const APInt &DemandedBits, const APInt &DemandedElts,
     SelectionDAG &DAG, unsigned Depth) const {
+  if (Depth == 6) // Limit search depth.
+    return SDValue();
+
   KnownBits LHSKnown, RHSKnown;
   switch (Op.getOpcode()) {
   case ISD::AND: {