diff options
| author | Tim Northover <tnorthover@apple.com> | 2015-01-21 23:17:19 +0000 |
|---|---|---|
| committer | Tim Northover <tnorthover@apple.com> | 2015-01-21 23:17:19 +0000 |
| commit | 3007ba0ab357e18d998654898c0d2e2d95207624 (patch) | |
| tree | de0a594d54d1b3fb9777823685416008b2e4668f /llvm/lib | |
| parent | 7a08488ca67c591af8318dae63872481d29080fd (diff) | |
| download | bcm5719-llvm-3007ba0ab357e18d998654898c0d2e2d95207624.tar.gz bcm5719-llvm-3007ba0ab357e18d998654898c0d2e2d95207624.zip | |
DAGCombine: fold (or (and X, M), (and X, N)) -> (and X, (or M, N))
It can help with argument juggling on some targets, and is generally a good
idea.
llvm-svn: 226740
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 11 |
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); |

