Fold conditional branches on constants away.
authorChris Lattner <sabre@nondot.org>
Fri, 7 Jan 2005 22:49:57 +0000 (22:49 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 7 Jan 2005 22:49:57 +0000 (22:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19360 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/SelectionDAG.cpp

index 6ab1d4595755bbebbc0484185f9504811a2371ac..e917350f8c9709e573af31ff3938ff215fb76984 100644 (file)
@@ -727,6 +727,12 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
     }
 
     break;
+  case ISD::BRCOND:
+    if (N2C)
+      if (N2C->getValue()) // Unconditional branch
+        return getNode(ISD::BR, MVT::Other, N1, N3);
+      else
+        return N1;         // Never-taken branch
   }
 
   SDNode *N = new SDNode(Opcode, N1, N2, N3);