summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-10-27 05:06:38 +0000
committerChris Lattner <sabre@nondot.org>2005-10-27 05:06:38 +0000
commitd8c5c066a161b544d47c804251c6eda9ff97899f (patch)
treec56874765ceab044ceb1ccb08b1a8deef7b06fe8 /llvm/lib
parent97cbaf5c89ffe68998abaf135ab427100f38867c (diff)
downloadbcm5719-llvm-d8c5c066a161b544d47c804251c6eda9ff97899f.tar.gz
bcm5719-llvm-d8c5c066a161b544d47c804251c6eda9ff97899f.zip
Add a simple xform that is useful for bitfield operations.
llvm-svn: 24029
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 0ccd0383ea7..30c8d98405f 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/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();
OpenPOWER on IntegriCloud