Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 9052f33

Browse files
committed
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@323129 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent f3c5f2b commit 9052f33

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

lib/Target/SystemZ/SystemZISelLowering.cpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5484,6 +5484,23 @@ static bool combineCCMask(SDValue &Glue, int &CCValid, int &CCMask) {
54845484
return true;
54855485
}
54865486

5487+
static bool combineMergeChains(SDValue &Chain, SDValue Glue) {
5488+
// We are about to glue an instruction with input chain Chain to the
5489+
// instruction Glue. Verify that this would not create an invalid
5490+
// topological sort due to intervening chain nodes.
5491+
5492+
SDNode *Node = Glue.getNode();
5493+
for (int ResNo = Node->getNumValues() - 1; ResNo >= 0; --ResNo)
5494+
if (Node->getValueType(ResNo) == MVT::Other) {
5495+
SDValue OutChain = SDValue(Node, ResNo);
5496+
// FIXME: We should be able to at least handle an intervening
5497+
// TokenFactor node by swapping chains around a bit ...
5498+
return Chain == OutChain;
5499+
}
5500+
5501+
return true;
5502+
}
5503+
54875504
SDValue SystemZTargetLowering::combineBR_CCMASK(
54885505
SDNode *N, DAGCombinerInfo &DCI) const {
54895506
SelectionDAG &DAG = DCI.DAG;
@@ -5496,11 +5513,13 @@ SDValue SystemZTargetLowering::combineBR_CCMASK(
54965513

54975514
int CCValidVal = CCValid->getZExtValue();
54985515
int CCMaskVal = CCMask->getZExtValue();
5516+
SDValue Chain = N->getOperand(0);
54995517
SDValue Glue = N->getOperand(4);
55005518

5501-
if (combineCCMask(Glue, CCValidVal, CCMaskVal))
5519+
if (combineCCMask(Glue, CCValidVal, CCMaskVal)
5520+
&& combineMergeChains(Chain, Glue))
55025521
return DAG.getNode(SystemZISD::BR_CCMASK, SDLoc(N), N->getValueType(0),
5503-
N->getOperand(0),
5522+
Chain,
55045523
DAG.getConstant(CCValidVal, SDLoc(N), MVT::i32),
55055524
DAG.getConstant(CCMaskVal, SDLoc(N), MVT::i32),
55065525
N->getOperand(3), Glue);

0 commit comments

Comments
 (0)