diff options
author | Duncan Sands <baldrick@free.fr> | 2007-10-31 08:57:43 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2007-10-31 08:57:43 +0000 |
commit | d12d06725624645c26540e82d848e4f13b490864 (patch) | |
tree | 6b87f8e6c3541c3c13dc7453442dd0e5d7ec1333 /lib | |
parent | d830533de6017e2a2c2b982b780be3a164fefaa5 (diff) | |
download | external_llvm-d12d06725624645c26540e82d848e4f13b490864.zip external_llvm-d12d06725624645c26540e82d848e4f13b490864.tar.gz external_llvm-d12d06725624645c26540e82d848e4f13b490864.tar.bz2 |
Promotion of sdiv/srem/udiv/urem.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43551 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeDAGTypes.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAGTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAGTypes.cpp index 5ecda48..2c8044c 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAGTypes.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAGTypes.cpp @@ -147,6 +147,8 @@ private: SDOperand PromoteResult_SETCC(SDNode *N); SDOperand PromoteResult_LOAD(LoadSDNode *N); SDOperand PromoteResult_SimpleIntBinOp(SDNode *N); + SDOperand PromoteResult_SDIV(SDNode *N); + SDOperand PromoteResult_UDIV(SDNode *N); SDOperand PromoteResult_SHL(SDNode *N); SDOperand PromoteResult_SRA(SDNode *N); SDOperand PromoteResult_SRL(SDNode *N); @@ -554,6 +556,12 @@ void DAGTypeLegalizer::PromoteResult(SDNode *N, unsigned ResNo) { case ISD::SUB: case ISD::MUL: Result = PromoteResult_SimpleIntBinOp(N); break; + case ISD::SDIV: + case ISD::SREM: Result = PromoteResult_SDIV(N); break; + + case ISD::UDIV: + case ISD::UREM: Result = PromoteResult_UDIV(N); break; + case ISD::SHL: Result = PromoteResult_SHL(N); break; case ISD::SRA: Result = PromoteResult_SRA(N); break; case ISD::SRL: Result = PromoteResult_SRL(N); break; @@ -694,6 +702,30 @@ SDOperand DAGTypeLegalizer::PromoteResult_SimpleIntBinOp(SDNode *N) { return DAG.getNode(N->getOpcode(), LHS.getValueType(), LHS, RHS); } +SDOperand DAGTypeLegalizer::PromoteResult_SDIV(SDNode *N) { + // Sign extend the input. + SDOperand LHS = GetPromotedOp(N->getOperand(0)); + SDOperand RHS = GetPromotedOp(N->getOperand(1)); + MVT::ValueType VT = N->getValueType(0); + LHS = DAG.getNode(ISD::SIGN_EXTEND_INREG, LHS.getValueType(), LHS, + DAG.getValueType(VT)); + RHS = DAG.getNode(ISD::SIGN_EXTEND_INREG, RHS.getValueType(), RHS, + DAG.getValueType(VT)); + + return DAG.getNode(N->getOpcode(), LHS.getValueType(), LHS, RHS); +} + +SDOperand DAGTypeLegalizer::PromoteResult_UDIV(SDNode *N) { + // Zero extend the input. + SDOperand LHS = GetPromotedOp(N->getOperand(0)); + SDOperand RHS = GetPromotedOp(N->getOperand(1)); + MVT::ValueType VT = N->getValueType(0); + LHS = DAG.getZeroExtendInReg(LHS, VT); + RHS = DAG.getZeroExtendInReg(RHS, VT); + + return DAG.getNode(N->getOpcode(), LHS.getValueType(), LHS, RHS); +} + SDOperand DAGTypeLegalizer::PromoteResult_SHL(SDNode *N) { return DAG.getNode(ISD::SHL, TLI.getTypeToTransformTo(N->getValueType(0)), GetPromotedOp(N->getOperand(0)), N->getOperand(1)); |