summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2017-09-14 10:38:30 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2017-09-14 10:38:30 +0000
commit8bd2d8780aa5c916fddf9ffeb43304cf732a9dce (patch)
tree0a4f594b0b1b625b70cf7c6b93d8525f24e9977e /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parentd7201b3a36c71ed0099f5d31ba8031c0482b7245 (diff)
downloadbcm5719-llvm-8bd2d8780aa5c916fddf9ffeb43304cf732a9dce.tar.gz
bcm5719-llvm-8bd2d8780aa5c916fddf9ffeb43304cf732a9dce.zip
[DAGCombine] (shl (or x, c1), c2) -> (or (shl x, c2), c1 << c2)
We already have a combine for this pattern when the input to shl is add, so we just need to enable the transformation when the input is or. Original patch by @tstellar Differential Revision: https://reviews.llvm.org/D19325 llvm-svn: 313251
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index ee237cbf238..f81a144de82 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -5595,16 +5595,18 @@ SDValue DAGCombiner::visitSHL(SDNode *N) {
}
// fold (shl (add x, c1), c2) -> (add (shl x, c2), c1 << c2)
+ // fold (shl (or x, c1), c2) -> (or (shl x, c2), c1 << c2)
// Variant of version done on multiply, except mul by a power of 2 is turned
// into a shift.
- if (N0.getOpcode() == ISD::ADD && N0.getNode()->hasOneUse() &&
+ if ((N0.getOpcode() == ISD::ADD || N0.getOpcode() == ISD::OR) &&
+ N0.getNode()->hasOneUse() &&
isConstantOrConstantVector(N1, /* No Opaques */ true) &&
isConstantOrConstantVector(N0.getOperand(1), /* No Opaques */ true)) {
SDValue Shl0 = DAG.getNode(ISD::SHL, SDLoc(N0), VT, N0.getOperand(0), N1);
SDValue Shl1 = DAG.getNode(ISD::SHL, SDLoc(N1), VT, N0.getOperand(1), N1);
AddToWorklist(Shl0.getNode());
AddToWorklist(Shl1.getNode());
- return DAG.getNode(ISD::ADD, SDLoc(N), VT, Shl0, Shl1);
+ return DAG.getNode(N0.getOpcode(), SDLoc(N), VT, Shl0, Shl1);
}
// fold (shl (mul x, c1), c2) -> (mul x, c1 << c2)
OpenPOWER on IntegriCloud