diff options
author | Chris Lattner <sabre@nondot.org> | 2005-05-12 00:17:04 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-05-12 00:17:04 +0000 |
commit | 88de6e77bfadea8962b017f372658204ab71448c (patch) | |
tree | c24af01c12f009c35494487aa5417ad145d004d8 /lib/CodeGen/SelectionDAG/SelectionDAG.cpp | |
parent | e066d68eb4c2fe227fb60f4836247e3b03320e7e (diff) |
Make legalize a bit more efficient, and canonicalize sub X, C -> add X, -C
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21882 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 3c3de2d437..dbb933eda9 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -916,7 +916,7 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT, break; case ISD::SUB: if (!C2) return N1; // sub X, 0 -> X - break; + return getNode(ISD::ADD, VT, N1, getConstant(-C2, VT)); case ISD::MUL: if (!C2) return N2; // mul X, 0 -> 0 if (N2C->isAllOnesValue()) // mul X, -1 -> 0-X @@ -1194,13 +1194,13 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT, // Memoize this node if possible. SDNode *N; - if (Opcode != ISD::ADJCALLSTACKDOWN) { + if (Opcode != ISD::ADJCALLSTACKDOWN && Opcode != ISD::ADJCALLSTACKUP) { SDNode *&BON = BinaryOps[std::make_pair(Opcode, std::make_pair(N1, N2))]; if (BON) return SDOperand(BON, 0); BON = N = new SDNode(Opcode, N1, N2); } else { - N = new SDNode(ISD::ADJCALLSTACKDOWN, N1, N2); + N = new SDNode(Opcode, N1, N2); } @@ -1213,11 +1213,12 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT, return SDOperand(N, 0); } -// setAdjCallChain - This method changes the token chain of an ADJCALLSTACKDOWN -// node to be the specified operand. +// setAdjCallChain - This method changes the token chain of an +// ADJCALLSTACKDOWN/UP node to be the specified operand. void SDNode::setAdjCallChain(SDOperand N) { assert(N.getValueType() == MVT::Other); - assert(getOpcode() == ISD::ADJCALLSTACKDOWN && "Cannot adjust this node!"); + assert((getOpcode() == ISD::ADJCALLSTACKDOWN || + getOpcode() == ISD::ADJCALLSTACKUP) && "Cannot adjust this node!"); Operands[0].Val->removeUser(this); Operands[0] = N; |