diff options
author | Ulrich Weigand <ulrich.weigand@de.ibm.com> | 2019-12-06 11:02:11 +0100 |
---|---|---|
committer | Ulrich Weigand <ulrich.weigand@de.ibm.com> | 2019-12-06 11:02:11 +0100 |
commit | daee549b1756a7aa0f1560d5460ae580897e4c1a (patch) | |
tree | e34b1a8f26dd3e310da13ac57dad6a69ef6c904b /llvm/lib/CodeGen | |
parent | f69f92344adaada1f8f3cfcd711037227432b062 (diff) | |
download | bcm5719-llvm-daee549b1756a7aa0f1560d5460ae580897e4c1a.tar.gz bcm5719-llvm-daee549b1756a7aa0f1560d5460ae580897e4c1a.zip |
[FPEnv][SelectionDAG] Relax chain requirements
This patch implements the following changes:
1) SelectionDAGBuilder::visitConstrainedFPIntrinsic currently treats
each constrained intrinsic like a global barrier (e.g. a function call)
and fully serializes all pending chains. This is actually not required;
it is allowed for constrained intrinsics to be reordered w.r.t one
another or (nonvolatile) memory accesses. The MI-level scheduler already
allows for that flexibility, so it makes sense to allow it at the DAG
level as well.
This patch therefore changes the way chains for constrained intrisincs
are created, and handles them basically like load operations are handled.
This has the effect that constrained intrinsics are no longer serialized
against one another or (nonvolatile) loads. They are still serialized
against stores, but that seems hard to change with the current DAG chain
setup, and it also doesn't seem to be a big problem preventing DAG
2) The OPC_CheckFoldableChainNode check requires that each of the
intermediate nodes in a multi-node pattern match only has a single use.
This check tends to fail if those intermediate nodes are strict operations
as those have a chain output that typically indeed has another use.
However, we don't really need to consider chains here at all, since they
will all be rewritten anyway by UpdateChains later. Other parts of the
matcher therefore already ignore chains, but this hasOneUse check doesn't.
This patch replaces hasOneUse by a custom test that verifies there is no
more than one use of any non-chain output value.
In theory, this change could affect code unrelated to strict FP nodes,
but at least on SystemZ I could not find any single instance of that
happening
3) The SystemZ back-end currently does not allow matching multiply-and-
extend operations (32x32 -> 64bit or 64x64 -> 128bit FP multiply) for
strict FP operations. This was not possible in the past due to the
problems described under 1) and 2) above.
With those issues fixed, it is now possible to fully support those
instructions in strict mode as well, and this patch does so.
Differential Revision: https://reviews.llvm.org/D70913
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 8 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 18 |
2 files changed, 18 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 0aeb3c14aa3..9952d4d9ac9 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -6888,7 +6888,10 @@ void SelectionDAGBuilder::visitConstrainedFPIntrinsic( ComputeValueVTs(TLI, DAG.getDataLayout(), FPI.getType(), ValueVTs); ValueVTs.push_back(MVT::Other); // Out chain - SDValue Chain = getRoot(); + // We do not need to serialize constrained FP intrinsics against + // each other or against (nonvolatile) loads, so they can be + // chained like loads. + SDValue Chain = DAG.getRoot(); SmallVector<SDValue, 4> Opers; Opers.push_back(Chain); if (FPI.isUnaryOp()) { @@ -6926,8 +6929,9 @@ void SelectionDAGBuilder::visitConstrainedFPIntrinsic( } assert(Result.getNode()->getNumValues() == 2); + // See above -- chain is handled like for loads here. SDValue OutChain = Result.getValue(1); - DAG.setRoot(OutChain); + PendingLoads.push_back(OutChain); SDValue FPResult = Result.getValue(0); setValue(&FPI, FPResult); } diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index a03f7923d71..b16d4af86a6 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -3171,13 +3171,19 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch, case OPC_CheckFoldableChainNode: { assert(NodeStack.size() != 1 && "No parent node"); // Verify that all intermediate nodes between the root and this one have - // a single use. + // a single use (ignoring chains, which are handled in UpdateChains). bool HasMultipleUses = false; - for (unsigned i = 1, e = NodeStack.size()-1; i != e; ++i) - if (!NodeStack[i].getNode()->hasOneUse()) { - HasMultipleUses = true; - break; - } + for (unsigned i = 1, e = NodeStack.size()-1; i != e; ++i) { + unsigned NNonChainUses = 0; + SDNode *NS = NodeStack[i].getNode(); + for (auto UI = NS->use_begin(), UE = NS->use_end(); UI != UE; ++UI) + if (UI.getUse().getValueType() != MVT::Other) + if (++NNonChainUses > 1) { + HasMultipleUses = true; + break; + } + if (HasMultipleUses) break; + } if (HasMultipleUses) break; // Check to see that the target thinks this is profitable to fold and that |