@@ -1784,38 +1784,6 @@ bool TargetLowering::SimplifyDemandedBits(
1784
1784
}
1785
1785
}
1786
1786
1787
- // Narrow shift to lower half - similar to ShrinkDemandedOp.
1788
- // (shl i64:x, K) -> (i64 zero_extend (shl (i32 (trunc i64:x)), K))
1789
- unsigned HalfWidth = BitWidth / 2;
1790
- if ((BitWidth % 2) == 0 && !VT.isVector() && ShAmt < HalfWidth) {
1791
- EVT HalfVT = EVT::getIntegerVT(*TLO.DAG.getContext(), HalfWidth);
1792
- if (isNarrowingProfitable(VT, HalfVT) &&
1793
- isTypeDesirableForOp(ISD::SHL, HalfVT) &&
1794
- isTruncateFree(VT, HalfVT) && isZExtFree(HalfVT, VT) &&
1795
- (!TLO.LegalOperations() || isOperationLegal(ISD::SHL, VT))) {
1796
- // Unless we aren't demanding the upper bits at all, we must ensure
1797
- // that the upper bits of the shift result are known to be zero,
1798
- // which is equivalent to the narrow shift being NUW.
1799
- KnownBits Known0 = TLO.DAG.computeKnownBits(Op0, Depth + 1);
1800
- bool IsNUW = Known0.countMinLeadingZeros() >= (ShAmt + HalfWidth);
1801
- if (IsNUW || DemandedBits.countLeadingZeros() >= HalfWidth) {
1802
- unsigned NumSignBits = TLO.DAG.ComputeNumSignBits(Op0, Depth + 1);
1803
- bool IsNSW = NumSignBits > (ShAmt + HalfWidth);
1804
- SDNodeFlags Flags;
1805
- Flags.setNoSignedWrap(IsNSW);
1806
- Flags.setNoUnsignedWrap(IsNUW);
1807
- SDValue NewOp = TLO.DAG.getNode(ISD::TRUNCATE, dl, HalfVT, Op0);
1808
- SDValue NewShiftAmt = TLO.DAG.getShiftAmountConstant(
1809
- ShAmt, HalfVT, dl, TLO.LegalTypes());
1810
- SDValue NewShift = TLO.DAG.getNode(ISD::SHL, dl, HalfVT, NewOp,
1811
- NewShiftAmt, Flags);
1812
- SDValue NewExt =
1813
- TLO.DAG.getNode(ISD::ZERO_EXTEND, dl, VT, NewShift);
1814
- return TLO.CombineTo(Op, NewExt);
1815
- }
1816
- }
1817
- }
1818
-
1819
1787
APInt InDemandedMask = DemandedBits.lshr(ShAmt);
1820
1788
if (SimplifyDemandedBits(Op0, InDemandedMask, DemandedElts, Known, TLO,
1821
1789
Depth + 1))
0 commit comments