Teach legalize how to handle condbranches
authorChris Lattner <sabre@nondot.org>
Fri, 7 Jan 2005 08:19:42 +0000 (08:19 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 7 Jan 2005 08:19:42 +0000 (08:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19339 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

index 748ad3f2879684a66be11ec8b7de8360aa277658..c8369aa1c61e9037ace4db1a5248dd15bae8330c 100644 (file)
@@ -305,6 +305,16 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
     }
     break;
 
+  case ISD::BRCOND:
+    Tmp1 = LegalizeOp(Node->getOperand(0));  // Legalize the chain.
+    // FIXME: booleans might not be legal!
+    Tmp2 = LegalizeOp(Node->getOperand(1));  // Legalize the condition.
+    // Basic block destination (Op#2) is always legal.
+    if (Tmp1 != Node->getOperand(0) || Tmp2 != Node->getOperand(1))
+      Result = DAG.getNode(ISD::BRCOND, MVT::Other, Tmp1, Tmp2,
+                           Node->getOperand(2));
+    break;
+
   case ISD::LOAD:
     Tmp1 = LegalizeOp(Node->getOperand(0));  // Legalize the chain.
     Tmp2 = LegalizeOp(Node->getOperand(1));  // Legalize the pointer.