Fix DAGCombiner to avoid folding a sext-in-reg or similar through a shl
[oota-llvm.git] / lib / CodeGen / SelectionDAG / DAGCombiner.cpp
index 7154d9d691c3a848f03b5f0ad9d42e2aa0998e0b..1a0f503378d14900c2617fd26ab9691f4c26ac18 100644 (file)
@@ -4120,6 +4120,7 @@ SDValue DAGCombiner::ReduceLoadWidth(SDNode *N) {
   // we can fold the truncate through the shift.
   unsigned ShLeftAmt = 0;
   if (ShAmt == 0 && N0.getOpcode() == ISD::SHL && N0.hasOneUse() &&
+      ExtVT == VT &&
       TLI.isNarrowingProfitable(N0.getValueType(), VT)) {
     if (ConstantSDNode *N01 = dyn_cast<ConstantSDNode>(N0.getOperand(1))) {
       ShLeftAmt = N01->getZExtValue();