summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2016-12-24 12:59:35 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2016-12-24 12:59:35 +0000
commit0d66d29678dc2e4635a38de5e257793b43dc664f (patch)
treef3a49c83072320e803375b0df731d6720827e05f /llvm/lib/CodeGen
parent23dd4c37be1da2ccfe4b953027741b7093ca573b (diff)
downloadbcm5719-llvm-0d66d29678dc2e4635a38de5e257793b43dc664f.tar.gz
bcm5719-llvm-0d66d29678dc2e4635a38de5e257793b43dc664f.zip
[SelectionDAG] Early out from computeKnownBits when we know we will have no common bits.
Avoid extra (recursive) calls to computeKnownBits if we already know that there are no common known bits. llvm-svn: 290490
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp34
1 files changed, 26 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index c80509caf05..b970dc0e5f5 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -2087,7 +2087,10 @@ void SelectionDAG::computeKnownBits(SDValue Op, APInt &KnownZero,
if (M < 0) {
// For UNDEF elements, we don't know anything about the common state of
// the shuffle result.
- KnownZero = KnownOne = APInt(BitWidth, 0);
+ KnownOne.clearAllBits();
+ KnownZero.clearAllBits();
+ DemandedLHS.clearAllBits();
+ DemandedRHS.clearAllBits();
break;
}
@@ -2103,6 +2106,9 @@ void SelectionDAG::computeKnownBits(SDValue Op, APInt &KnownZero,
KnownOne &= KnownOne2;
KnownZero &= KnownZero2;
}
+ // If we don't know any bits, early out.
+ if (!KnownOne && !KnownZero)
+ break;
if (!!DemandedRHS) {
SDValue RHS = Op.getOperand(1);
computeKnownBits(RHS, KnownZero2, KnownOne2, DemandedRHS, Depth + 1);
@@ -2126,6 +2132,9 @@ void SelectionDAG::computeKnownBits(SDValue Op, APInt &KnownZero,
KnownOne &= KnownOne2;
KnownZero &= KnownZero2;
}
+ // If we don't know any bits, early out.
+ if (!KnownOne && !KnownZero)
+ break;
}
break;
}
@@ -2207,6 +2216,9 @@ void SelectionDAG::computeKnownBits(SDValue Op, APInt &KnownZero,
unsigned Offset = (i % SubScale) * BitWidth;
KnownOne &= KnownOne2.lshr(Offset).trunc(BitWidth);
KnownZero &= KnownZero2.lshr(Offset).trunc(BitWidth);
+ // If we don't know any bits, early out.
+ if (!KnownOne && !KnownZero)
+ break;
}
}
break;
@@ -2290,6 +2302,9 @@ void SelectionDAG::computeKnownBits(SDValue Op, APInt &KnownZero,
}
case ISD::SELECT:
computeKnownBits(Op.getOperand(2), KnownZero, KnownOne, Depth+1);
+ // If we don't know any bits, early out.
+ if (!KnownOne && !KnownZero)
+ break;
computeKnownBits(Op.getOperand(1), KnownZero2, KnownOne2, Depth+1);
// Only known if known in both the LHS and RHS.
@@ -2298,6 +2313,9 @@ void SelectionDAG::computeKnownBits(SDValue Op, APInt &KnownZero,
break;
case ISD::SELECT_CC:
computeKnownBits(Op.getOperand(3), KnownZero, KnownOne, Depth+1);
+ // If we don't know any bits, early out.
+ if (!KnownOne && !KnownZero)
+ break;
computeKnownBits(Op.getOperand(2), KnownZero2, KnownOne2, Depth+1);
// Only known if known in both the LHS and RHS.
@@ -2691,15 +2709,15 @@ void SelectionDAG::computeKnownBits(SDValue Op, APInt &KnownZero,
case ISD::SMAX:
case ISD::UMIN:
case ISD::UMAX: {
- APInt Op0Zero, Op0One;
- APInt Op1Zero, Op1One;
- computeKnownBits(Op.getOperand(0), Op0Zero, Op0One, DemandedElts,
+ computeKnownBits(Op.getOperand(0), KnownZero, KnownOne, DemandedElts,
Depth + 1);
- computeKnownBits(Op.getOperand(1), Op1Zero, Op1One, DemandedElts,
+ // If we don't know any bits, early out.
+ if (!KnownOne && !KnownZero)
+ break;
+ computeKnownBits(Op.getOperand(1), KnownZero2, KnownOne2, DemandedElts,
Depth + 1);
-
- KnownZero = Op0Zero & Op1Zero;
- KnownOne = Op0One & Op1One;
+ KnownZero &= KnownZero2;
+ KnownOne &= KnownOne2;
break;
}
case ISD::FrameIndex:
OpenPOWER on IntegriCloud