Fold conditional branches on constants away.
llvm-svn: 19360
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 6ab1d45..e917350 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -727,6 +727,12 @@
}
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);