aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-04-09 03:27:28 +0000
committerChris Lattner <sabre@nondot.org>2005-04-09 03:27:28 +0000
commitef847df0870b9e3407bdc24ccb9db9ba2df817e6 (patch)
tree79b5ce1b80472f3a21ee3576eb29f244ba11f104 /lib/CodeGen/SelectionDAG/SelectionDAG.cpp
parentda4d4694a8d87833155779a4dd2879b1404d138d (diff)
print and fold BRCONDTWOWAY correctly
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21165 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAG.cpp36
1 files changed, 25 insertions, 11 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 93ef3726ad..8918c45562 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -992,18 +992,31 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
case 1: return getNode(Opcode, VT, Children[0]);
case 2: return getNode(Opcode, VT, Children[0], Children[1]);
case 3: return getNode(Opcode, VT, Children[0], Children[1], Children[2]);
- default:
- // FIXME: MEMOIZE!!
- SDNode *N = new SDNode(Opcode, Children);
- if (Opcode != ISD::ADD_PARTS && Opcode != ISD::SUB_PARTS) {
- N->setValueTypes(VT);
- } else {
- std::vector<MVT::ValueType> V(N->getNumOperands()/2, VT);
- N->setValueTypes(V);
- }
- AllNodes.push_back(N);
- return SDOperand(N, 0);
+ default: break;
+ }
+
+ ConstantSDNode *N1C = dyn_cast<ConstantSDNode>(Children[1].Val);
+ switch (Opcode) {
+ default: break;
+ case ISD::BRCONDTWOWAY:
+ if (N1C)
+ if (N1C->getValue()) // Unconditional branch to true dest.
+ return getNode(ISD::BR, MVT::Other, Children[0], Children[2]);
+ else // Unconditional branch to false dest.
+ return getNode(ISD::BR, MVT::Other, Children[0], Children[3]);
+ break;
+ }
+
+ // FIXME: MEMOIZE!!
+ SDNode *N = new SDNode(Opcode, Children);
+ if (Opcode != ISD::ADD_PARTS && Opcode != ISD::SUB_PARTS) {
+ N->setValueTypes(VT);
+ } else {
+ std::vector<MVT::ValueType> V(N->getNumOperands()/2, VT);
+ N->setValueTypes(V);
}
+ AllNodes.push_back(N);
+ return SDOperand(N, 0);
}
SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,SDOperand N1,
@@ -1243,6 +1256,7 @@ const char *SDNode::getOperationName() const {
// Control flow instructions
case ISD::BR: return "br";
case ISD::BRCOND: return "brcond";
+ case ISD::BRCONDTWOWAY: return "brcondtwoway";
case ISD::RET: return "ret";
case ISD::CALL: return "call";
case ISD::ADJCALLSTACKDOWN: return "adjcallstackdown";