aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-10-05 06:47:48 +0000
committerChris Lattner <sabre@nondot.org>2005-10-05 06:47:48 +0000
commit3ea0b47f81caeb53f9594dd3f7702ae01c4f2cc6 (patch)
tree94d4a111990e4e5c7b0cb48af83db7e0e6d7fa6f /lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parentad13715ed4068a347452de9a86f5c1a702458f83 (diff)
implement visitBR_CC so that PowerPC/inverted-bool-compares.ll passes
with the dag combiner. This speeds up espresso by 8%, reaching performance parity with the dag-combiner-disabled llc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23636 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/DAGCombiner.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 26504df265..23d9b432c3 100644
--- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -1425,9 +1425,29 @@ SDOperand DAGCombiner::visitBRCONDTWOWAY(SDNode *N) {
return SDOperand();
}
+// Operand List for BR_CC: Chain, CondCC, CondLHS, CondRHS, DestBB.
+//
SDOperand DAGCombiner::visitBR_CC(SDNode *N) {
- // FIXME: come up with a common way between br_cc, brtwoway_cc, and select_cc
- // to canonicalize the condition without calling getnode a bazillion times.
+ CondCodeSDNode *CC = cast<CondCodeSDNode>(N->getOperand(1));
+ SDOperand CondLHS = N->getOperand(2), CondRHS = N->getOperand(3);
+
+ // Use SimplifySetCC to simplify SETCC's.
+ SDOperand Simp = SimplifySetCC(MVT::i1, CondLHS, CondRHS, CC->get());
+ if (Simp.Val) {
+ if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(Simp)) {
+ if (C->getValue() & 1) // Unconditional branch
+ return DAG.getNode(ISD::BR, MVT::Other, N->getOperand(0),
+ N->getOperand(4));
+ else
+ return N->getOperand(0); // Unconditional Fall through
+ } else if (Simp.Val->getOpcode() == ISD::SETCC) {
+ // Folded to a simpler setcc
+ return DAG.getNode(ISD::BR_CC, MVT::Other, N->getOperand(0),
+ Simp.getOperand(2), Simp.getOperand(0),
+ Simp.getOperand(1), N->getOperand(4));
+ }
+ }
+
return SDOperand();
}