summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2018-01-24 11:41:09 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2018-01-24 11:41:09 +0000
commitf26df4783132de2a534572a53847716a89d98339 (patch)
tree3e10a7d996c0b523bc4a9a7a52f1c2fb1682b3db
parenteda222e7beb1b3490a83a77d7ae26493aa180a88 (diff)
downloadbcm5719-llvm-f26df4783132de2a534572a53847716a89d98339.tar.gz
bcm5719-llvm-f26df4783132de2a534572a53847716a89d98339.zip
[X86][SSE] Avoid calls to combineX86ShufflesRecursively that can't combine to target shuffles (PR32037)
Don't bother making recursive calls to combineX86ShufflesRecursively if we have more shuffle source operands than will be combined together with the remaining recursive depth. See https://bugs.llvm.org/show_bug.cgi?id=32037#c26 and https://bugs.llvm.org/show_bug.cgi?id=32037#c27 for the reduction in compile times from this patch. Differential Revision: https://reviews.llvm.org/D42378 llvm-svn: 323320
-rw-r--r--llvm/lib/Target/X86/X86ISelLowering.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 525c097396d..50edb59eb8f 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -29369,12 +29369,13 @@ static SDValue combineX86ShufflesConstants(const SmallVectorImpl<SDValue> &Ops,
/// combining in this recursive walk.
static SDValue combineX86ShufflesRecursively(
ArrayRef<SDValue> SrcOps, int SrcOpIndex, SDValue Root,
- ArrayRef<int> RootMask, ArrayRef<const SDNode *> SrcNodes, int Depth,
+ ArrayRef<int> RootMask, ArrayRef<const SDNode *> SrcNodes, unsigned Depth,
bool HasVariableMask, SelectionDAG &DAG,
TargetLowering::DAGCombinerInfo &DCI, const X86Subtarget &Subtarget) {
// Bound the depth of our recursive combine because this is ultimately
// quadratic in nature.
- if (Depth > 8)
+ const unsigned MaxRecursionDepth = 8;
+ if (Depth > MaxRecursionDepth)
return SDValue();
// Directly rip through bitcasts to find the underlying operand.
@@ -29527,13 +29528,17 @@ static SDValue combineX86ShufflesRecursively(
// See if we can recurse into each shuffle source op (if it's a target
// shuffle). The source op should only be combined if it either has a
// single use (i.e. current Op) or all its users have already been combined.
- for (int i = 0, e = Ops.size(); i < e; ++i)
- if (Ops[i].getNode()->hasOneUse() ||
- SDNode::areOnlyUsersOf(CombinedNodes, Ops[i].getNode()))
- if (SDValue Res = combineX86ShufflesRecursively(
- Ops, i, Root, Mask, CombinedNodes, Depth + 1, HasVariableMask,
- DAG, DCI, Subtarget))
- return Res;
+ // Don't recurse if we already have more source ops than we can combine in
+ // the remaining recursion depth.
+ if (Ops.size() < (MaxRecursionDepth - Depth)) {
+ for (int i = 0, e = Ops.size(); i < e; ++i)
+ if (Ops[i].getNode()->hasOneUse() ||
+ SDNode::areOnlyUsersOf(CombinedNodes, Ops[i].getNode()))
+ if (SDValue Res = combineX86ShufflesRecursively(
+ Ops, i, Root, Mask, CombinedNodes, Depth + 1, HasVariableMask,
+ DAG, DCI, Subtarget))
+ return Res;
+ }
// Attempt to constant fold all of the constant source ops.
if (SDValue Cst = combineX86ShufflesConstants(
OpenPOWER on IntegriCloud