Prevent a DAGCombine from firing where there are two uses of
[oota-llvm.git] / lib / CodeGen / SelectionDAG / DAGCombiner.cpp
index 8a8f0cf2bc75fce8659121771b585f69a87dc75c..5b2d86f511ddc13e9658934d2c6e371d9aa073c4 100644 (file)
@@ -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()) {