summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2015-01-21 15:43:28 +0000
committerTim Northover <tnorthover@apple.com>2015-01-21 15:43:28 +0000
commit85cd2791c9f478fb8b0150185e5c2cf617a46f25 (patch)
tree496f255dcbaad97a5393fcda03eff3bbaf4a6301 /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parent6d1178ca409ce738543604053f23a463ad2b3aa2 (diff)
downloadbcm5719-llvm-85cd2791c9f478fb8b0150185e5c2cf617a46f25.tar.gz
bcm5719-llvm-85cd2791c9f478fb8b0150185e5c2cf617a46f25.zip
DAGCombine: fold (or (and X, M), (and X, N)) -> (and X, (or M, N))
llvm-svn: 226663
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 3bde9918793..849508891d3 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -3527,6 +3527,17 @@ SDValue DAGCombiner::visitOR(SDNode *N) {
}
}
+ // (or (and X, M), (and X, N)) -> (and X, (or M, N))
+ if (N0.getOpcode() == ISD::AND &&
+ N1.getOpcode() == ISD::AND &&
+ N0.getOperand(0) == N1.getOperand(0) &&
+ // Don't increase # computations.
+ (N0.getNode()->hasOneUse() || N1.getNode()->hasOneUse())) {
+ SDValue X = DAG.getNode(ISD::OR, SDLoc(N0), VT,
+ N0.getOperand(1), N1.getOperand(1));
+ return DAG.getNode(ISD::AND, SDLoc(N), VT, N0.getOperand(0), X);
+ }
+
// See if this is some rotate idiom.
if (SDNode *Rot = MatchRotate(N0, N1, SDLoc(N)))
return SDValue(Rot, 0);
OpenPOWER on IntegriCloud