diff options
author | Chris Lattner <sabre@nondot.org> | 2005-10-27 05:06:38 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-10-27 05:06:38 +0000 |
commit | 731d348166792bb9846022a82f7712c7bcec8f30 (patch) | |
tree | ffe1ecee9af37ea99e7f1b19c80707e64cd0a20b | |
parent | 53c13b15ece8a97e2abb15f7724ef22fbfa3b0e6 (diff) |
Add a simple xform that is useful for bitfield operations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24029 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 0ccd0383ea..30c8d98405 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -1103,7 +1103,16 @@ SDOperand DAGCombiner::visitOR(SDNode *N) { if (N01C) return DAG.getNode(ISD::OR, VT, N0.getOperand(0), DAG.getConstant(N1C->getValue()|N01C->getValue(), VT)); + } else if (N1C && N0.getOpcode() == ISD::AND && N0.Val->hasOneUse() && + isa<ConstantSDNode>(N0.getOperand(1))) { + // Canonicalize (or (and X, c1), c2) -> (and (or X, c2), c1|c2) + ConstantSDNode *C1 = cast<ConstantSDNode>(N0.getOperand(1)); + return DAG.getNode(ISD::AND, VT, DAG.getNode(ISD::OR, VT, N0.getOperand(0), + N1), + DAG.getConstant(N1C->getValue() | C1->getValue(), VT)); } + + // fold (or (setcc x), (setcc y)) -> (setcc (or x, y)) if (isSetCCEquivalent(N0, LL, LR, CC0) && isSetCCEquivalent(N1, RL, RR, CC1)){ ISD::CondCode Op0 = cast<CondCodeSDNode>(CC0)->get(); |