From: Chris Lattner Date: Fri, 7 Jan 2005 22:49:57 +0000 (+0000) Subject: Fold conditional branches on constants away. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5351e9b172962a4f51e6d3b12018dd2de34b2f97;p=oota-llvm.git Fold conditional branches on constants away. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19360 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 6ab1d459575..e917350f8c9 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -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);