diff options
| author | Ulrich Weigand <ulrich.weigand@de.ibm.com> | 2018-01-22 15:41:49 +0000 |
|---|---|---|
| committer | Ulrich Weigand <ulrich.weigand@de.ibm.com> | 2018-01-22 15:41:49 +0000 |
| commit | 145d63f1ada934f82af0c0796d3ba21461270e47 (patch) | |
| tree | c96104aacb2d9b83f33b161b0cee2bab0bb95fcf /llvm/lib/Target/SystemZ | |
| parent | 811523cc08b5b17768ff9427691dfb70a068dbbf (diff) | |
| download | bcm5719-llvm-145d63f1ada934f82af0c0796d3ba21461270e47.tar.gz bcm5719-llvm-145d63f1ada934f82af0c0796d3ba21461270e47.zip | |
[SystemZ] Fix bootstrap failure due to invalid DAG loop
The change in r322988 caused a failure in the bootstrap build bot.
The problem was that directly gluing a BR_CCMASK node to a
compare-and-swap could lead to issues if other nodes were
chained in between. There is then no way to create a topological
sort that respects both the chain sequence and the glue property.
Fixed for now by rejecting the optimization in this case. As a
future enhancement, we may be able to handle additional cases
by swapping chain links around.
llvm-svn: 323129
Diffstat (limited to 'llvm/lib/Target/SystemZ')
| -rw-r--r-- | llvm/lib/Target/SystemZ/SystemZISelLowering.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp index f7fc061473a..0d29676f500 100644 --- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp +++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp @@ -5484,6 +5484,23 @@ static bool combineCCMask(SDValue &Glue, int &CCValid, int &CCMask) { return true; } +static bool combineMergeChains(SDValue &Chain, SDValue Glue) { + // We are about to glue an instruction with input chain Chain to the + // instruction Glue. Verify that this would not create an invalid + // topological sort due to intervening chain nodes. + + SDNode *Node = Glue.getNode(); + for (int ResNo = Node->getNumValues() - 1; ResNo >= 0; --ResNo) + if (Node->getValueType(ResNo) == MVT::Other) { + SDValue OutChain = SDValue(Node, ResNo); + // FIXME: We should be able to at least handle an intervening + // TokenFactor node by swapping chains around a bit ... + return Chain == OutChain; + } + + return true; +} + SDValue SystemZTargetLowering::combineBR_CCMASK( SDNode *N, DAGCombinerInfo &DCI) const { SelectionDAG &DAG = DCI.DAG; @@ -5496,11 +5513,13 @@ SDValue SystemZTargetLowering::combineBR_CCMASK( int CCValidVal = CCValid->getZExtValue(); int CCMaskVal = CCMask->getZExtValue(); + SDValue Chain = N->getOperand(0); SDValue Glue = N->getOperand(4); - if (combineCCMask(Glue, CCValidVal, CCMaskVal)) + if (combineCCMask(Glue, CCValidVal, CCMaskVal) + && combineMergeChains(Chain, Glue)) return DAG.getNode(SystemZISD::BR_CCMASK, SDLoc(N), N->getValueType(0), - N->getOperand(0), + Chain, DAG.getConstant(CCValidVal, SDLoc(N), MVT::i32), DAG.getConstant(CCMaskVal, SDLoc(N), MVT::i32), N->getOperand(3), Glue); |

