diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2012-01-05 11:05:55 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2012-01-05 11:05:55 +0000 |
commit | e041a30bb9abf8080841991dce5d00e3d663a80a (patch) | |
tree | ae8a6481ef5b0b183a330fb62fd26c08d7d86bf2 /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | |
parent | 6bc151f5d4202e26d344e483b46d235711ffefd7 (diff) | |
download | bcm5719-llvm-e041a30bb9abf8080841991dce5d00e3d663a80a.tar.gz bcm5719-llvm-e041a30bb9abf8080841991dce5d00e3d663a80a.zip |
Prevent a DAGCombine from firing where there are two uses of
a combined-away node and the result of the combine isn't substantially
smaller than the input, it's just canonicalized. This is the first part
of a significant (7%) performance gain for Snappy's hot decompression
loop.
llvm-svn: 147604
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 8a8f0cf2bc7..5b2d86f511d 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -3331,7 +3331,9 @@ SDValue DAGCombiner::visitSHL(SDNode *N) { // fold (shl (srl x, c1), c2) -> (and (shl x, (sub c2, c1), MASK) or // (and (srl x, (sub c1, c2), MASK) - if (N1C && N0.getOpcode() == ISD::SRL && + // Only fold this if the inner shift has no other uses -- if it does, folding + // this will increase the total number of instructions. + if (N1C && N0.getOpcode() == ISD::SRL && N0.hasOneUse() && N0.getOperand(1).getOpcode() == ISD::Constant) { uint64_t c1 = cast<ConstantSDNode>(N0.getOperand(1))->getZExtValue(); if (c1 < VT.getSizeInBits()) { |