Lines Matching defs:TLO

517                                             TargetLoweringOpt &TLO) const {
527 if (targetShrinkDemandedConstant(Op, DemandedBits, DemandedElts, TLO))
528 return TLO.New.getNode();
548 SDValue NewC = TLO.DAG.getConstant(DemandedBits & C, DL, VT);
549 SDValue NewOp = TLO.DAG.getNode(Opcode, DL, VT, Op.getOperand(0), NewC,
551 return TLO.CombineTo(Op, NewOp);
563 TargetLoweringOpt &TLO) const {
568 return ShrinkDemandedConstant(Op, DemandedBits, DemandedElts, TLO);
577 TargetLoweringOpt &TLO) const {
584 SelectionDAG &DAG = TLO.DAG;
619 return TLO.CombineTo(Op, Z);
628 TargetLoweringOpt TLO(DAG, !DCI.isBeforeLegalize(),
632 bool Simplified = SimplifyDemandedBits(Op, DemandedBits, Known, TLO);
635 DCI.CommitTargetLoweringOpt(TLO);
644 TargetLoweringOpt TLO(DAG, !DCI.isBeforeLegalize(),
649 SimplifyDemandedBits(Op, DemandedBits, DemandedElts, Known, TLO);
652 DCI.CommitTargetLoweringOpt(TLO);
659 TargetLoweringOpt &TLO,
670 return SimplifyDemandedBits(Op, DemandedBits, DemandedElts, Known, TLO, Depth,
988 TargetLowering::TargetLoweringOpt &TLO,
1042 SelectionDAG &DAG = TLO.DAG;
1100 if (TLO.LegalTypes() && !TLI.isOperationLegal(AVGOpc, NVT)) {
1103 if (TLO.LegalOperations() && !TLI.isOperationLegal(AVGOpc, VT))
1136 const APInt &OriginalDemandedElts, KnownBits &Known, TargetLoweringOpt &TLO,
1146 bool IsLE = TLO.DAG.getDataLayout().isLittleEndian();
1189 return TLO.CombineTo(Op, TLO.DAG.getUNDEF(VT));
1201 return TLO.CombineTo(Op, TLO.DAG.getUNDEF(VT));
1207 if (SimplifyDemandedBits(Src, SrcDemandedBits, SrcKnown, TLO, Depth + 1))
1219 Known = TLO.DAG.computeKnownBits(Op, DemandedElts, Depth);
1225 if (SimplifyDemandedBits(Scl, DemandedSclBits, KnownScl, TLO, Depth + 1))
1236 Known = TLO.DAG.computeKnownBits(Op, DemandedElts, Depth);
1265 return TLO.CombineTo(Op, Vec);
1271 if (SimplifyDemandedBits(Scl, DemandedSclBits, KnownScl, TLO, Depth + 1))
1277 if (SimplifyDemandedBits(Vec, DemandedBits, DemandedVecElts, KnownVec, TLO,
1300 if (SimplifyDemandedBits(Sub, DemandedBits, DemandedSubElts, KnownSub, TLO,
1303 if (SimplifyDemandedBits(Src, DemandedBits, DemandedSrcElts, KnownSrc, TLO,
1318 Sub, DemandedBits, DemandedSubElts, TLO.DAG, Depth + 1);
1320 Src, DemandedBits, DemandedSrcElts, TLO.DAG, Depth + 1);
1324 SDValue NewOp = TLO.DAG.getNode(Op.getOpcode(), dl, VT, NewSrc, NewSub,
1326 return TLO.CombineTo(Op, NewOp);
1342 if (SimplifyDemandedBits(Src, DemandedBits, DemandedSrcElts, Known, TLO,
1349 Src, DemandedBits, DemandedSrcElts, TLO.DAG, Depth + 1);
1351 SDValue NewOp = TLO.DAG.getNode(Op.getOpcode(), dl, VT, DemandedSrc,
1353 return TLO.CombineTo(Op, NewOp);
1370 Known2, TLO, Depth + 1))
1395 if (SimplifyDemandedBits(Op0, DemandedBits, DemandedLHS, Known2, TLO,
1401 if (SimplifyDemandedBits(Op1, DemandedBits, DemandedRHS, Known2, TLO,
1409 Op0, DemandedBits, DemandedLHS, TLO.DAG, Depth + 1);
1411 Op1, DemandedBits, DemandedRHS, TLO.DAG, Depth + 1);
1415 SDValue NewOp = TLO.DAG.getVectorShuffle(VT, dl, Op0, Op1, ShuffleMask);
1416 return TLO.CombineTo(Op, NewOp);
1431 KnownBits LHSKnown = TLO.DAG.computeKnownBits(Op0, DemandedElts, Depth);
1435 return TLO.CombineTo(Op, Op0);
1440 DemandedElts, TLO))
1450 SDValue Xor = TLO.DAG.getNode(ISD::XOR, dl, VT, Op0.getOperand(0), Op1);
1451 return TLO.CombineTo(Op, Xor);
1467 TLO.DAG.computeKnownBits(Op1, DemandedSub & DemandedElts, Depth + 1);
1470 TLO.DAG.getNode(ISD::AND, dl, VT, Op0.getOperand(0), Op1);
1472 TLO.DAG.getNode(ISD::INSERT_SUBVECTOR, dl, VT, NewAnd,
1474 return TLO.CombineTo(Op, NewInsert);
1478 if (SimplifyDemandedBits(Op1, DemandedBits, DemandedElts, Known, TLO,
1482 Known2, TLO, Depth + 1))
1488 return TLO.CombineTo(Op, Op0);
1490 return TLO.CombineTo(Op, Op1);
1493 return TLO.CombineTo(Op, TLO.DAG.getConstant(0, dl, VT));
1496 TLO))
1499 if (ShrinkDemandedOp(Op, BitWidth, DemandedBits, TLO))
1505 Op0, DemandedBits, DemandedElts, TLO.DAG, Depth + 1);
1507 Op1, DemandedBits, DemandedElts, TLO.DAG, Depth + 1);
1511 SDValue NewOp = TLO.DAG.getNode(Op.getOpcode(), dl, VT, Op0, Op1);
1512 return TLO.CombineTo(Op, NewOp);
1522 if (SimplifyDemandedBits(Op1, DemandedBits, DemandedElts, Known, TLO,
1529 Known2, TLO, Depth + 1)) {
1537 return TLO.CombineTo(Op, Op0);
1539 return TLO.CombineTo(Op, Op1);
1541 if (ShrinkDemandedConstant(Op, DemandedBits, DemandedElts, TLO))
1544 if (ShrinkDemandedOp(Op, BitWidth, DemandedBits, TLO))
1550 Op0, DemandedBits, DemandedElts, TLO.DAG, Depth + 1);
1552 Op1, DemandedBits, DemandedElts, TLO.DAG, Depth + 1);
1556 SDValue NewOp = TLO.DAG.getNode(Op.getOpcode(), dl, VT, Op0, Op1);
1557 return TLO.CombineTo(Op, NewOp);
1575 if (SDValue C12 = TLO.DAG.FoldConstantArithmetic(ISD::OR, dl, VT,
1577 SDValue MaskX = TLO.DAG.getNode(ISD::AND, dl, VT, X, C12);
1578 SDValue MaskY = TLO.DAG.getNode(ISD::AND, dl, VT, Y, C2);
1579 return TLO.CombineTo(
1580 Op, TLO.DAG.getNode(ISD::OR, dl, VT, MaskX, MaskY));
1595 if (SimplifyDemandedBits(Op1, DemandedBits, DemandedElts, Known, TLO,
1598 if (SimplifyDemandedBits(Op0, DemandedBits, DemandedElts, Known2, TLO,
1605 return TLO.CombineTo(Op, Op0);
1607 return TLO.CombineTo(Op, Op1);
1609 if (ShrinkDemandedOp(Op, BitWidth, DemandedBits, TLO))
1616 return TLO.CombineTo(Op, TLO.DAG.getNode(ISD::OR, dl, VT, Op0, Op1));
1627 TLO.DAG.getConstant(~C->getAPIntValue() & DemandedBits, dl, VT);
1628 return TLO.CombineTo(Op, TLO.DAG.getNode(ISD::AND, dl, VT, Op0, ANDC));
1636 SDValue New = TLO.DAG.getNOT(dl, Op0, VT);
1637 return TLO.CombineTo(Op, New);
1657 SDValue Not = TLO.DAG.getNOT(dl, Op0.getOperand(0), VT);
1658 return TLO.CombineTo(Op, TLO.DAG.getNode(Op0Opcode, dl, VT, Not,
1668 if (ShrinkDemandedConstant(Op, DemandedBits, DemandedElts, TLO))
1674 Op0, DemandedBits, DemandedElts, TLO.DAG, Depth + 1);
1676 Op1, DemandedBits, DemandedElts, TLO.DAG, Depth + 1);
1680 SDValue NewOp = TLO.DAG.getNode(Op.getOpcode(), dl, VT, Op0, Op1);
1681 return TLO.CombineTo(Op, NewOp);
1690 Known, TLO, Depth + 1))
1693 Known2, TLO, Depth + 1))
1697 if (ShrinkDemandedConstant(Op, DemandedBits, DemandedElts, TLO))
1705 Known, TLO, Depth + 1))
1708 Known2, TLO, Depth + 1))
1716 Known, TLO, Depth + 1))
1719 Known2, TLO, Depth + 1))
1723 if (ShrinkDemandedConstant(Op, DemandedBits, DemandedElts, TLO))
1746 return TLO.CombineTo(Op, Op0);
1763 TLO.DAG.getValidShiftAmount(Op, DemandedElts, Depth + 1)) {
1766 return TLO.CombineTo(Op, Op0);
1775 TLO.DAG.getValidShiftAmount(Op0, DemandedElts, Depth + 2)) {
1783 SDValue NewSA = TLO.DAG.getConstant(Diff, dl, ShiftVT);
1784 return TLO.CombineTo(
1785 Op, TLO.DAG.getNode(Opc, dl, VT, Op0.getOperand(0), NewSA));
1799 SDValue NarrowShl = TLO.DAG.getNode(
1801 TLO.DAG.getShiftAmountConstant(ShAmt, InnerVT, dl));
1802 return TLO.CombineTo(
1803 Op, TLO.DAG.getNode(ISD::ANY_EXTEND, dl, VT, NarrowShl));
1814 if (std::optional<uint64_t> SA2 = TLO.DAG.getValidShiftAmount(
1822 TLO.DAG.getConstant(ShAmt - InnerShAmt, dl, ShiftVT);
1823 SDValue NewExt = TLO.DAG.getNode(ISD::ANY_EXTEND, dl, VT,
1825 return TLO.CombineTo(
1826 Op, TLO.DAG.getNode(ISD::SHL, dl, VT, NewExt, NewSA));
1833 if (SimplifyDemandedBits(Op0, InDemandedMask, DemandedElts, Known, TLO,
1848 Op0, InDemandedMask, DemandedElts, TLO.DAG, Depth + 1);
1850 SDValue NewOp = TLO.DAG.getNode(ISD::SHL, dl, VT, DemandedOp0, Op1);
1851 return TLO.CombineTo(Op, NewOp);
1865 EVT SmallVT = EVT::getIntegerVT(*TLO.DAG.getContext(), SmallVTBits);
1869 (!TLO.LegalOperations() || isOperationLegal(ISD::SHL, SmallVT))) {
1873 SDValue NarrowShl = TLO.DAG.getNode(
1875 TLO.DAG.getNode(ISD::TRUNCATE, dl, SmallVT, Op.getOperand(0)),
1876 TLO.DAG.getShiftAmountConstant(ShAmt, SmallVT, dl));
1877 return TLO.CombineTo(
1878 Op, TLO.DAG.getNode(ISD::ANY_EXTEND, dl, VT, NarrowShl));
1889 EVT HalfVT = EVT::getIntegerVT(*TLO.DAG.getContext(), HalfWidth);
1893 (!TLO.LegalOperations() || isOperationLegal(ISD::SHL, HalfVT))) {
1902 SDValue NewOp = TLO.DAG.getNode(ISD::TRUNCATE, dl, HalfVT, Op0);
1904 TLO.DAG.getShiftAmountConstant(ShAmt, HalfVT, dl);
1905 SDValue NewShift = TLO.DAG.getNode(ISD::SHL, dl, HalfVT, NewOp,
1908 TLO.DAG.getNode(ISD::ZERO_EXTEND, dl, VT, NewShift);
1909 return TLO.CombineTo(Op, NewExt);
1919 if (SimplifyDemandedBits(Op0, DemandedFromOp, DemandedElts, Known, TLO,
1933 TLO.DAG.getValidMaximumShiftAmount(Op, DemandedElts, Depth + 1)) {
1936 TLO.DAG.ComputeNumSignBits(Op0, DemandedElts, Depth + 1);
1939 return TLO.CombineTo(Op, Op0);
1949 TLO.DAG.getValidShiftAmount(Op, DemandedElts, Depth + 1)) {
1952 return TLO.CombineTo(Op, Op0);
1961 TLO.DAG.getValidShiftAmount(Op0, DemandedElts, Depth + 2)) {
1969 SDValue NewSA = TLO.DAG.getConstant(Diff, dl, ShiftVT);
1970 return TLO.CombineTo(
1971 Op, TLO.DAG.getNode(Opc, dl, VT, Op0.getOperand(0), NewSA));
1981 TLO.DAG.getValidShiftAmount(Op0, DemandedElts, Depth + 2)) {
1985 SDValue NewSA = TLO.DAG.getConstant(Combined, dl, ShiftVT);
1986 return TLO.CombineTo(Op, TLO.DAG.getNode(ISD::SRA, dl, VT,
2003 EVT HalfVT = EVT::getIntegerVT(*TLO.DAG.getContext(), BitWidth / 2);
2007 (!TLO.LegalOperations() || isOperationLegal(ISD::SRL, HalfVT)) &&
2009 TLO.DAG.MaskedValueIsZero(Op0, HiBits))) {
2010 SDValue NewOp = TLO.DAG.getNode(ISD::TRUNCATE, dl, HalfVT, Op0);
2012 TLO.DAG.getShiftAmountConstant(ShAmt, HalfVT, dl);
2014 TLO.DAG.getNode(ISD::SRL, dl, HalfVT, NewOp, NewShiftAmt);
2015 return TLO.CombineTo(
2016 Op, TLO.DAG.getNode(ISD::ZERO_EXTEND, dl, VT, NewShift));
2021 if (SimplifyDemandedBits(Op0, InDemandedMask, DemandedElts, Known, TLO,
2032 Op0, InDemandedMask, DemandedElts, TLO.DAG, Depth + 1);
2034 SDValue NewOp = TLO.DAG.getNode(ISD::SRL, dl, VT, DemandedOp0, Op1);
2035 return TLO.CombineTo(Op, NewOp);
2041 Known = TLO.DAG.computeKnownBits(Op, DemandedElts, Depth);
2047 TLO.DAG.getValidMaximumShiftAmount(Op, DemandedElts, Depth + 1)) {
2053 TLO.DAG.ComputeNumSignBits(Op0, DemandedElts, Depth + 1);
2055 return TLO.CombineTo(Op, Op0);
2060 if (SDValue AVG = combineShiftToAVG(Op, TLO, *this, DemandedBits,
2062 return TLO.CombineTo(Op, AVG);
2074 if (TLO.DAG.ComputeNumSignBits(Op0, DemandedElts, Depth + 1) >=
2076 return TLO.CombineTo(Op, Op0);
2083 return TLO.CombineTo(Op, TLO.DAG.getNode(ISD::SRL, dl, VT, Op0, Op1));
2086 TLO.DAG.getValidShiftAmount(Op, DemandedElts, Depth + 1)) {
2089 return TLO.CombineTo(Op, Op0);
2095 TLO.DAG.getValidShiftAmount(Op0, DemandedElts, Depth + 2)) {
2097 EVT ExtVT = EVT::getIntegerVT(*TLO.DAG.getContext(), LowBits);
2099 ExtVT = EVT::getVectorVT(*TLO.DAG.getContext(), ExtVT,
2103 if (!TLO.LegalOperations() ||
2105 return TLO.CombineTo(
2106 Op, TLO.DAG.getNode(ISD::SIGN_EXTEND_INREG, dl, VT,
2108 TLO.DAG.getValueType(ExtVT)));
2113 TLO.DAG.ComputeNumSignBits(Op0.getOperand(0), DemandedElts);
2115 return TLO.CombineTo(Op, Op0.getOperand(0));
2132 if (SimplifyDemandedBits(Op0, InDemandedMask, DemandedElts, Known, TLO,
2144 return TLO.CombineTo(
2145 Op, TLO.DAG.getNode(ISD::SRL, dl, VT, Op0, Op1, Flags));
2151 SDValue NewSA = TLO.DAG.getConstant(BitWidth - 1 - Log2, dl, ShiftVT);
2152 return TLO.CombineTo(Op, TLO.DAG.getNode(ISD::SRL, dl, VT, Op0, NewSA));
2162 Op0, InDemandedMask, DemandedElts, TLO.DAG, Depth + 1);
2164 SDValue NewOp = TLO.DAG.getNode(ISD::SRA, dl, VT, DemandedOp0, Op1);
2165 return TLO.CombineTo(Op, NewOp);
2171 if (SDValue AVG = combineShiftToAVG(Op, TLO, *this, DemandedBits,
2173 return TLO.CombineTo(Op, AVG);
2191 Known, TLO, Depth + 1))
2200 if (SimplifyDemandedBits(Op0, Demanded0, DemandedElts, Known2, TLO,
2203 if (SimplifyDemandedBits(Op1, Demanded1, DemandedElts, Known, TLO,
2217 Op0, Demanded0, DemandedElts, TLO.DAG, Depth + 1);
2219 Op1, Demanded1, DemandedElts, TLO.DAG, Depth + 1);
2223 SDValue NewOp = TLO.DAG.getNode(Op.getOpcode(), dl, VT, DemandedOp0,
2225 return TLO.CombineTo(Op, NewOp);
2234 Known2, TLO, Depth + 1))
2246 if (BitWidth == TLO.DAG.ComputeNumSignBits(Op0, DemandedElts, Depth + 1))
2247 return TLO.CombineTo(Op, Op0);
2256 if (SimplifyDemandedBits(Op0, Demanded0, DemandedElts, Known2, TLO,
2262 return TLO.CombineTo(Op, Op0);
2265 if ((!TLO.LegalOperations() || isOperationLegal(ISD::SHL, VT)) &&
2267 Op1 = TLO.DAG.getConstant(IsROTL ? Amt : RevAmt, dl, Op1.getValueType());
2268 return TLO.CombineTo(Op, TLO.DAG.getNode(ISD::SHL, dl, VT, Op0, Op1));
2270 if ((!TLO.LegalOperations() || isOperationLegal(ISD::SRL, VT)) &&
2272 Op1 = TLO.DAG.getConstant(IsROTL ? RevAmt : Amt, dl, Op1.getValueType());
2273 return TLO.CombineTo(Op, TLO.DAG.getNode(ISD::SRL, dl, VT, Op0, Op1));
2280 if (SimplifyDemandedBits(Op1, DemandedAmtBits, DemandedElts, Known2, TLO,
2298 std::min(TLO.DAG.ComputeNumSignBits(Op0, DemandedElts, Depth + 1),
2299 TLO.DAG.ComputeNumSignBits(Op1, DemandedElts, Depth + 1));
2302 return TLO.CombineTo(Op, TLO.DAG.getNode(BitOp, SDLoc(Op), VT, Op0, Op1));
2305 KnownBits Known0 = TLO.DAG.computeKnownBits(Op0, DemandedElts, Depth + 1);
2306 KnownBits Known1 = TLO.DAG.computeKnownBits(Op1, DemandedElts, Depth + 1);
2310 return TLO.CombineTo(Op, *IsSLE ? Op0 : Op1);
2312 return TLO.CombineTo(Op, *IsSLT ? Op0 : Op1);
2317 return TLO.CombineTo(Op, *IsSGE ? Op0 : Op1);
2319 return TLO.CombineTo(Op, *IsSGT ? Op0 : Op1);
2324 return TLO.CombineTo(Op, *IsULE ? Op0 : Op1);
2326 return TLO.CombineTo(Op, *IsULT ? Op0 : Op1);
2331 return TLO.CombineTo(Op, *IsUGE ? Op0 : Op1);
2333 return TLO.CombineTo(Op, *IsUGT ? Op0 : Op1);
2342 if (SimplifyDemandedBits(Src, DemandedSrcBits, DemandedElts, Known2, TLO,
2367 if (!TLO.LegalOperations() || isOperationLegal(ShiftOpcode, VT)) {
2369 SDValue ShAmt = TLO.DAG.getShiftAmountConstant(ShiftAmount, VT, dl);
2370 SDValue NewOp = TLO.DAG.getNode(ShiftOpcode, dl, VT, Src, ShAmt);
2371 return TLO.CombineTo(Op, NewOp);
2376 if (SimplifyDemandedBits(Src, DemandedSrcBits, DemandedElts, Known2, TLO,
2387 if (DemandedBits.isOne() && !TLO.LegalOps && !VT.isVector())
2388 return TLO.CombineTo(Op, TLO.DAG.getNode(ISD::PARITY, dl, VT,
2391 Known = TLO.DAG.computeKnownBits(Op, DemandedElts, Depth);
2402 TLO.DAG.ComputeMaxSignificantBits(Op0, DemandedElts, Depth + 1);
2410 TLO.DAG.getShiftAmountConstant(BitWidth - ExVTBits, VT, dl);
2411 return TLO.CombineTo(Op,
2412 TLO.DAG.getNode(ISD::SHL, dl, VT, Op0, ShiftAmt));
2418 return TLO.CombineTo(Op, Op0);
2426 if (SimplifyDemandedBits(Op0, InputDemandedBits, DemandedElts, Known, TLO,
2435 return TLO.CombineTo(Op, TLO.DAG.getZeroExtendInReg(Op0, dl, ExVT));
2456 if (SimplifyDemandedBits(Op.getOperand(0), MaskLo, KnownLo, TLO, Depth + 1))
2459 if (SimplifyDemandedBits(Op.getOperand(1), MaskHi, KnownHi, TLO, Depth + 1))
2482 return TLO.CombineTo(Op, TLO.DAG.getBitcast(VT, Src));
2486 if (!TLO.LegalOperations() || isOperationLegal(Opc, VT))
2487 return TLO.CombineTo(Op, TLO.DAG.getNode(Opc, dl, VT, Src));
2492 if (SimplifyDemandedBits(Src, InDemandedBits, InDemandedElts, Known, TLO,
2502 Src, InDemandedBits, InDemandedElts, TLO.DAG, Depth + 1))
2503 return TLO.CombineTo(Op, TLO.DAG.getNode(Op.getOpcode(), dl, VT, NewSrc));
2530 return TLO.CombineTo(Op, TLO.DAG.getBitcast(VT, Src));
2534 TLO.DAG.ComputeNumSignBits(Src, InDemandedElts, Depth + 1) !=
2538 if (!TLO.LegalOperations() || isOperationLegal(Opc, VT))
2539 return TLO.CombineTo(Op, TLO.DAG.getNode(Opc, dl, VT, Src));
2543 if (SimplifyDemandedBits(Src, InDemandedBits, InDemandedElts, Known, TLO,
2555 if (!TLO.LegalOperations() || isOperationLegal(Opc, VT)) {
2559 return TLO.CombineTo(Op, TLO.DAG.getNode(Opc, dl, VT, Src, Flags));
2565 Src, InDemandedBits, InDemandedElts, TLO.DAG, Depth + 1))
2566 return TLO.CombineTo(Op, TLO.DAG.getNode(Op.getOpcode(), dl, VT, NewSrc));
2584 return TLO.CombineTo(Op, TLO.DAG.getBitcast(VT, Src));
2588 if (SimplifyDemandedBits(Src, InDemandedBits, InDemandedElts, Known, TLO,
2596 Src, InDemandedBits, InDemandedElts, TLO.DAG, Depth + 1))
2597 return TLO.CombineTo(Op, TLO.DAG.getNode(Op.getOpcode(), dl, VT, NewSrc));
2607 if (SimplifyDemandedBits(Src, TruncMask, DemandedElts, Known, TLO,
2618 Src, TruncMask, DemandedElts, TLO.DAG, Depth + 1))
2619 return TLO.CombineTo(Op, TLO.DAG.getNode(ISD::TRUNCATE, dl, VT, NewSrc));
2629 if (TLO.LegalTypes() && !isTypeDesirableForOp(ISD::SRL, VT))
2647 TLO.DAG.getValidShiftAmount(Src, DemandedElts, Depth + 2);
2659 SDValue NewShAmt = TLO.DAG.getShiftAmountConstant(ShVal, VT, dl);
2661 TLO.DAG.getNode(ISD::TRUNCATE, dl, VT, Src.getOperand(0));
2662 return TLO.CombineTo(
2663 Op, TLO.DAG.getNode(ISD::SRL, dl, VT, NewTrunc, NewShAmt));
2677 TLO, Depth + 1))
2706 if (SimplifyDemandedBits(Src, DemandedSrcBits, DemandedSrcElts, Known2, TLO,
2713 Src, DemandedSrcBits, DemandedSrcElts, TLO.DAG, Depth + 1)) {
2715 TLO.DAG.getNode(Op.getOpcode(), dl, VT, DemandedSrc, Idx);
2716 return TLO.CombineTo(Op, NewOp);
2734 if (!TLO.LegalOperations() && !VT.isVector() && !SrcVT.isVector() &&
2745 SDValue Sign = TLO.DAG.getNode(ISD::FGETSIGN, dl, Ty, Src);
2748 Sign = TLO.DAG.getNode(ISD::ZERO_EXTEND, dl, VT, Sign);
2750 SDValue ShAmt = TLO.DAG.getConstant(ShVal, dl, VT);
2751 return TLO.CombineTo(Op,
2752 TLO.DAG.getNode(ISD::SHL, dl, VT, Sign, ShAmt));
2777 KnownSrcZero, TLO, Depth + 1))
2782 KnownSrcBits, TLO, Depth + 1))
2800 KnownSrcZero, TLO, Depth + 1))
2806 KnownSrcBits, TLO, Depth + 1))
2812 Src, DemandedSrcBits, DemandedSrcElts, TLO.DAG, Depth + 1)) {
2813 SDValue NewOp = TLO.DAG.getBitcast(VT, DemandedSrc);
2814 return TLO.CombineTo(Op, NewOp);
2822 Known = TLO.DAG.computeKnownBits(Op, DemandedElts, Depth);
2835 SDValue AmtC = TLO.DAG.getShiftAmountConstant(CTZ, VT, dl);
2836 SDValue Shl = TLO.DAG.getNode(ISD::SHL, dl, VT, Op.getOperand(0), AmtC);
2837 return TLO.CombineTo(Op, Shl);
2844 SDValue One = TLO.DAG.getConstant(1, dl, VT);
2845 SDValue And1 = TLO.DAG.getNode(ISD::AND, dl, VT, Op.getOperand(0), One);
2846 return TLO.CombineTo(Op, And1);
2864 if (SimplifyDemandedBits(Op1, LoMask, DemandedElts, KnownOp1, TLO,
2867 DemandedElts, KnownOp0, TLO, Depth + 1) ||
2869 ShrinkDemandedOp(Op, BitWidth, DemandedBits, TLO)) {
2879 return TLO.CombineTo(Op, Op1);
2884 Op0, LoMask, DemandedElts, TLO.DAG, Depth + 1);
2886 Op1, LoMask, DemandedElts, TLO.DAG, Depth + 1);
2890 SDValue NewOp = TLO.DAG.getNode(Op.getOpcode(), dl, VT, Op0, Op1,
2892 return TLO.CombineTo(Op, NewOp);
2905 SDValue Neg1 = TLO.DAG.getAllOnesConstant(dl, VT);
2908 SDValue NewOp = TLO.DAG.getNode(Op.getOpcode(), dl, VT, Op0, Neg1,
2910 return TLO.CombineTo(Op, NewOp);
2934 SDValue ShlAmtC = TLO.DAG.getShiftAmountConstant(ShlAmt, VT, dl);
2935 SDValue Shl = TLO.DAG.getNode(ISD::SHL, dl, VT, X, ShlAmtC);
2936 SDValue Res = TLO.DAG.getNode(NT, dl, VT, Y, Shl);
2937 return TLO.CombineTo(Op, Res);
2974 Known, TLO, Depth))
2980 Known = TLO.DAG.computeKnownBits(Op, DemandedElts, Depth);
2995 return TLO.CombineTo(Op, TLO.DAG.getConstant(Known.One, dl, VT));
2997 return TLO.CombineTo(
2998 Op, TLO.DAG.getConstantFP(APFloat(VT.getFltSemantics(), Known.One),
3006 Known = TLO.DAG.computeKnownBits(Op, OriginalDemandedElts, Depth);
3015 TargetLoweringOpt TLO(DAG, !DCI.isBeforeLegalize(),
3020 SimplifyDemandedVectorElts(Op, DemandedElts, KnownUndef, KnownZero, TLO);
3023 DCI.CommitTargetLoweringOpt(TLO);
3079 APInt &KnownZero, TargetLoweringOpt &TLO, unsigned Depth,
3089 if (!shouldSimplifyDemandedVectorElts(Op, TLO))
3112 return TLO.CombineTo(Op, TLO.DAG.getUNDEF(VT));
3121 bool IsLE = TLO.DAG.getDataLayout().isLittleEndian();
3127 TLO.DAG, Depth + 1);
3129 TLO.DAG, Depth + 1);
3132 TLO.DAG.getNode(Opcode, SDLoc(Op), VT, NewOp0 ? NewOp0 : Op0,
3134 return TLO.CombineTo(Op, NewOp);
3143 return TLO.CombineTo(Op, TLO.DAG.getUNDEF(VT));
3162 TLO, Depth + 1))
3182 KnownZero, TLO, Depth + 1);
3192 TLO, Depth + 1))
3209 TLO, Depth + 1))
3247 TLO, Depth + 1))
3265 if (TLO.DAG.isGuaranteedNotToBeUndefOrPoison(N0, DemandedElts,
3267 return TLO.CombineTo(Op, N0);
3272 return TLO.CombineTo(
3273 Op, TLO.DAG.getNode(ISD::SCALAR_TO_VECTOR, DL, VT,
3274 TLO.DAG.getFreeze(N0.getOperand(0))));
3287 Ops[i] = TLO.DAG.getUNDEF(Ops[0].getValueType());
3293 return TLO.CombineTo(Op, TLO.DAG.getBuildVector(VT, DL, Ops));
3315 if (SimplifyDemandedVectorElts(SubOp, SubElts, SubUndef, SubZero, TLO,
3330 SubOp, SubElts, TLO.DAG, Depth + 1);
3336 TLO.DAG.getNode(Op.getOpcode(), SDLoc(Op), VT, DemandedSubOps);
3337 return TLO.CombineTo(Op, NewOp);
3354 if (SimplifyDemandedVectorElts(Sub, DemandedSubElts, SubUndef, SubZero, TLO,
3360 return TLO.CombineTo(Op, TLO.DAG.getNode(ISD::INSERT_SUBVECTOR, DL, VT,
3361 TLO.DAG.getUNDEF(VT), Sub,
3365 TLO, Depth + 1))
3373 Src, DemandedSrcElts, TLO.DAG, Depth + 1);
3375 Sub, DemandedSubElts, TLO.DAG, Depth + 1);
3379 SDValue NewOp = TLO.DAG.getNode(Op.getOpcode(), SDLoc(Op), VT, NewSrc,
3381 return TLO.CombineTo(Op, NewOp);
3396 if (SimplifyDemandedVectorElts(Src, DemandedSrcElts, SrcUndef, SrcZero, TLO,
3405 Src, DemandedSrcElts, TLO.DAG, Depth + 1);
3407 SDValue NewOp = TLO.DAG.getNode(Op.getOpcode(), SDLoc(Op), VT, NewSrc,
3409 return TLO.CombineTo(Op, NewOp);
3424 return TLO.CombineTo(Op, Vec);
3429 KnownZero, TLO, Depth + 1))
3439 if (SimplifyDemandedVectorElts(Vec, DemandedElts, VecUndef, VecZero, TLO,
3453 if (SimplifyDemandedVectorElts(Sel, DemandedElts, UndefSel, ZeroSel, TLO,
3462 if (SimplifyDemandedVectorElts(LHS, DemandedLHS, UndefLHS, ZeroLHS, TLO,
3465 if (SimplifyDemandedVectorElts(RHS, DemandedRHS, UndefRHS, ZeroRHS, TLO,
3476 if (SimplifyDemandedVectorElts(Sel, DemandedSel, UndefSel, ZeroSel, TLO,
3504 if (SimplifyDemandedVectorElts(LHS, DemandedLHS, UndefLHS, ZeroLHS, TLO,
3507 if (SimplifyDemandedVectorElts(RHS, DemandedRHS, UndefRHS, ZeroRHS, TLO,
3530 if (Updated && !IdentityLHS && !IdentityRHS && !TLO.LegalOps) {
3532 buildLegalVectorShuffle(VT, DL, LHS, RHS, NewMask, TLO.DAG);
3534 return TLO.CombineTo(Op, LegalShuffle);
3563 if (SimplifyDemandedVectorElts(Src, DemandedSrcElts, SrcUndef, SrcZero, TLO,
3573 return TLO.CombineTo(Op, TLO.DAG.getBitcast(VT, Src));
3579 return TLO.CombineTo(Op, TLO.DAG.getConstant(0, SDLoc(Op), VT));
3591 MaskElts.push_back(TLO.DAG.getAllOnesConstant(DL, SrcSVT));
3592 MaskElts.append(NumSrcElts - 1, TLO.DAG.getConstant(0, DL, SrcSVT));
3593 SDValue Mask = TLO.DAG.getBuildVector(SrcVT, DL, MaskElts);
3594 if (SDValue Fold = TLO.DAG.FoldConstantArithmetic(
3596 Fold = TLO.DAG.getNode(ISD::AND, DL, SrcVT, Src.getOperand(0), Fold);
3597 return TLO.CombineTo(Op, TLO.DAG.getBitcast(VT, Fold));
3611 if (SimplifyDemandedVectorElts(Op0, DemandedElts, UndefLHS, ZeroLHS, TLO,
3633 if (SimplifyDemandedVectorElts(Op1, DemandedElts, UndefRHS, ZeroRHS, TLO,
3637 if (SimplifyDemandedVectorElts(Op0, DemandedElts, UndefLHS, ZeroLHS, TLO,
3642 KnownUndef = getKnownUndefForVectorBinop(Op, TLO.DAG, UndefLHS, UndefRHS);
3660 if (SimplifyDemandedVectorElts(Op1, DemandedElts, UndefRHS, ZeroRHS, TLO,
3664 if (SimplifyDemandedVectorElts(Op0, DemandedElts, UndefLHS, ZeroLHS, TLO,
3686 if (SimplifyDemandedVectorElts(Op1, DemandedElts, SrcUndef, SrcZero, TLO,
3693 TLO, Depth + 1))
3703 return TLO.CombineTo(Op, TLO.DAG.getConstant(0, SDLoc(Op), VT));
3723 KnownZero, TLO, Depth + 1))
3728 Op.getOperand(0), DemandedElts, TLO.DAG, Depth + 1))
3729 return TLO.CombineTo(Op, TLO.DAG.getNode(Opcode, SDLoc(Op), VT, NewOp));
3734 return TLO.CombineTo(Op, TLO.DAG.getConstant(0, SDLoc(Op), VT));
3743 KnownZero, TLO, Depth + 1))
3750 KnownZero, TLO, Depth))
3756 TLO, Depth, AssumeSingleUse))
3767 return TLO.CombineTo(Op, TLO.DAG.getUNDEF(VT));
3830 TargetLoweringOpt &TLO, unsigned Depth) const {
3842 KnownBits &Known, TargetLoweringOpt &TLO, unsigned Depth) const {
3849 computeKnownBitsForTargetNode(Op, Known, DemandedElts, TLO.DAG, Depth);