[llvm] r304409 - Only generate addcarry node when it is legal.
Amaury Sechet via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 1 05:03:16 PDT 2017
Author: deadalnix
Date: Thu Jun 1 07:03:16 2017
New Revision: 304409
URL: http://llvm.org/viewvc/llvm-project?rev=304409&view=rev
Log:
Only generate addcarry node when it is legal.
Summary:
This is a problem uncovered by stage2 testing. ADDCARRY end up being generated on target that do not support it.
The patch that introduced the problem has other patches layed on top of it, so we want to fix the issue rather than revert it to avoid creating a lor of churn.
A regression test will be added shortly, but this is committed as this in order to get the build back to green promptly.
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D33770
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=304409&r1=304408&r2=304409&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Thu Jun 1 07:03:16 2017
@@ -2058,10 +2058,11 @@ SDValue DAGCombiner::visitADDLike(SDValu
N0, N1.getOperand(0), N1.getOperand(2));
// (add X, Carry) -> (addcarry X, 0, Carry)
- if (SDValue Carry = getAsCarry(TLI, N1))
- return DAG.getNode(ISD::ADDCARRY, DL,
- DAG.getVTList(VT, Carry.getValueType()), N0,
- DAG.getConstant(0, DL, VT), Carry);
+ if (TLI.isOperationLegalOrCustom(ISD::ADDCARRY, VT))
+ if (SDValue Carry = getAsCarry(TLI, N1))
+ return DAG.getNode(ISD::ADDCARRY, DL,
+ DAG.getVTList(VT, Carry.getValueType()), N0,
+ DAG.getConstant(0, DL, VT), Carry);
return SDValue();
}
@@ -2136,6 +2137,8 @@ SDValue DAGCombiner::visitUADDO(SDNode *
}
SDValue DAGCombiner::visitUADDOLike(SDValue N0, SDValue N1, SDNode *N) {
+ auto VT = N0.getValueType();
+
// (uaddo X, (addcarry Y, 0, Carry)) -> (addcarry X, Y, Carry)
// If Y + 1 cannot overflow.
if (N1.getOpcode() == ISD::ADDCARRY && isNullConstant(N1.getOperand(1))) {
@@ -2147,9 +2150,10 @@ SDValue DAGCombiner::visitUADDOLike(SDVa
}
// (uaddo X, Carry) -> (addcarry X, 0, Carry)
- if (SDValue Carry = getAsCarry(TLI, N1))
- return DAG.getNode(ISD::ADDCARRY, SDLoc(N), N->getVTList(), N0,
- DAG.getConstant(0, SDLoc(N), N0.getValueType()), Carry);
+ if (TLI.isOperationLegalOrCustom(ISD::ADDCARRY, VT))
+ if (SDValue Carry = getAsCarry(TLI, N1))
+ return DAG.getNode(ISD::ADDCARRY, SDLoc(N), N->getVTList(), N0,
+ DAG.getConstant(0, SDLoc(N), VT), Carry);
return SDValue();
}
More information about the llvm-commits
mailing list