aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2008-11-22 07:24:01 +0000
committerBill Wendling <isanbard@gmail.com>2008-11-22 07:24:01 +0000
commit253174bf50c932abaa680f465e2888c0e5272267 (patch)
treebe3d2341639fa1e8150bce59509971f02b965fec /lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
parent8ac0d4b4fb10406278cd600214cd3ee6d76620cd (diff)
Cleanup of the [SU]ADDO type legalization code. Patch by Duncan!
"It simplifies the type legalization part a bit, and produces better code by teaching SelectionDAG about the extra bits in an i8 SADDO/UADDO node. In essence, I spontaneously decided that on x86 this i8 boolean result would be either 0 or 1, and on other platforms 0/1 or 0/-1, depending on whether the platform likes it's boolean zero extended or sign extended." git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59864 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp30
1 files changed, 12 insertions, 18 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
index cd4524ef48..179329b590 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
@@ -99,8 +99,8 @@ void DAGTypeLegalizer::PromoteIntegerResult(SDNode *N, unsigned ResNo) {
case ISD::UDIV:
case ISD::UREM: Result = PromoteIntRes_UDIV(N); break;
- case ISD::SADDO: Result = PromoteIntRes_SADDO(N, ResNo); break;
- case ISD::UADDO: Result = PromoteIntRes_UADDO(N, ResNo); break;
+ case ISD::SADDO:
+ case ISD::UADDO: Result = PromoteIntRes_XADDO(N, ResNo); break;
case ISD::ATOMIC_LOAD_ADD_8:
case ISD::ATOMIC_LOAD_SUB_8:
@@ -518,26 +518,20 @@ SDValue DAGTypeLegalizer::PromoteIntRes_UDIV(SDNode *N) {
return DAG.getNode(N->getOpcode(), LHS.getValueType(), LHS, RHS);
}
-SDValue DAGTypeLegalizer::PromoteIntRes_XADDO(SDNode *N, unsigned ResNo,
- ISD::NodeType NTy) {
- MVT NewVT = TLI.getTypeToTransformTo(SDValue(N, ResNo).getValueType());
- assert(isTypeLegal(NewVT) && "Illegal XADDO type!");
+SDValue DAGTypeLegalizer::PromoteIntRes_XADDO(SDNode *N, unsigned ResNo) {
+ assert(ResNo == 1 && "Only boolean result promotion currently supported!");
- MVT ValueVTs[] = { N->getOperand(0).getValueType(), NewVT };
+ // Simply change the return type of the boolean result.
+ MVT NVT = TLI.getTypeToTransformTo(N->getValueType(1));
+ MVT ValueVTs[] = { N->getValueType(0), NVT };
SDValue Ops[] = { N->getOperand(0), N->getOperand(1) };
+ SDValue Res = DAG.getNode(N->getOpcode(), DAG.getVTList(ValueVTs, 2), Ops, 2);
- SDValue Res = DAG.getNode(NTy, DAG.getVTList(&ValueVTs[0], 2), &Ops[0], 2);
- ReplaceValueWith(SDValue(N, 0), SDValue(Res.getNode(), 0));
- ReplaceValueWith(SDValue(N, 1), SDValue(Res.getNode(), 1));
- return Res;
-}
-
-SDValue DAGTypeLegalizer::PromoteIntRes_SADDO(SDNode *N, unsigned ResNo) {
- return PromoteIntRes_XADDO(N, ResNo, ISD::SADDO);
-}
+ // Modified the sum result - switch anything that used the old sum to use
+ // the new one.
+ ReplaceValueWith(SDValue(N, 0), Res);
-SDValue DAGTypeLegalizer::PromoteIntRes_UADDO(SDNode *N, unsigned ResNo) {
- return PromoteIntRes_XADDO(N, ResNo, ISD::UADDO);
+ return SDValue(Res.getNode(), 1);
}
SDValue DAGTypeLegalizer::PromoteIntRes_UNDEF(SDNode *N) {