Home | History | Annotate | Download | only in SelectionDAG

Lines Matching refs:Op

265 bool TargetLowering::TargetLoweringOpt::ShrinkDemandedConstant(SDValue Op,
267 SDLoc dl(Op);
270 switch (Op.getOpcode()) {
275 ConstantSDNode *C = dyn_cast<ConstantSDNode>(Op.getOperand(1));
278 if (Op.getOpcode() == ISD::XOR &&
284 EVT VT = Op.getValueType();
285 SDValue New = DAG.getNode(Op.getOpcode(), dl, VT, Op.getOperand(0),
289 return CombineTo(Op, New);
304 TargetLowering::TargetLoweringOpt::ShrinkDemandedOp(SDValue Op,
308 assert(Op.getNumOperands() == 2 &&
310 assert(Op.getNode()->getNumValues() == 1 &&
315 if (!Op.getNode()->hasOneUse())
319 // Op's type. For expedience, just check power-of-2 integer types.
327 if (TLI.isTruncateFree(Op.getValueType(), SmallVT) &&
328 TLI.isZExtFree(SmallVT, Op.getValueType())) {
330 SDValue X = DAG.getNode(Op.getOpcode(), dl, SmallVT,
332 Op.getNode()->getOperand(0)),
334 Op.getNode()->getOperand(1)));
337 dl, Op.getValueType(), X);
338 return CombineTo(Op, Z);
344 /// SimplifyDemandedBits - Look at Op. At this point, we know that only the
345 /// DemandedMask bits of the result of Op are ever used downstream. If we can
346 /// use this information to simplify Op, create a new simplified DAG node and
351 bool TargetLowering::SimplifyDemandedBits(SDValue Op,
358 assert(Op.getValueType().getScalarType().getSizeInBits() == BitWidth &&
361 SDLoc dl(Op);
367 if (!Op.getNode()->hasOneUse()) {
371 TLO.DAG.ComputeMaskedBits(Op, KnownZero, KnownOne, Depth);
378 // Not demanding any bits from Op.
379 if (Op.getOpcode() != ISD::UNDEF)
380 return TLO.CombineTo(Op, TLO.DAG.getUNDEF(Op.getValueType()));
387 switch (Op.getOpcode()) {
390 KnownOne = cast<ConstantSDNode>(Op)->getAPIntValue();
398 if (ConstantSDNode *RHSC = dyn_cast<ConstantSDNode>(Op.getOperand(1))) {
401 TLO.DAG.ComputeMaskedBits(Op.getOperand(0), LHSZero, LHSOne, Depth);
404 return TLO.CombineTo(Op, Op.getOperand(0));
407 if (TLO.ShrinkDemandedConstant(Op, ~LHSZero & NewMask))
411 if (SimplifyDemandedBits(Op.getOperand(1), NewMask, KnownZero,
415 if (SimplifyDemandedBits(Op.getOperand(0), ~KnownZero & NewMask,
423 return TLO.CombineTo(Op, Op.getOperand(0));
425 return TLO.CombineTo(Op, Op.getOperand(1));
428 return TLO.CombineTo(Op, TLO.DAG.getConstant(0, Op.getValueType()));
430 if (TLO.ShrinkDemandedConstant(Op, ~KnownZero2 & NewMask))
433 if (TLO.ShrinkDemandedOp(Op, BitWidth, NewMask, dl))
442 if (SimplifyDemandedBits(Op.getOperand(1), NewMask, KnownZero,
446 if (SimplifyDemandedBits(Op.getOperand(0), ~KnownOne & NewMask,
454 return TLO.CombineTo(Op, Op.getOperand(0));
456 return TLO.CombineTo(Op, Op.getOperand(1));
460 return TLO.CombineTo(Op, Op.getOperand(0));
462 return TLO.CombineTo(Op, Op.getOperand(1));
464 if (TLO.ShrinkDemandedConstant(Op, NewMask))
467 if (TLO.ShrinkDemandedOp(Op, BitWidth, NewMask, dl))
476 if (SimplifyDemandedBits(Op.getOperand(1), NewMask, KnownZero,
480 if (SimplifyDemandedBits(Op.getOperand(0), NewMask, KnownZero2,
488 return TLO.CombineTo(Op, Op.getOperand(0));
490 return TLO.CombineTo(Op, Op.getOperand(1));
492 if (TLO.ShrinkDemandedOp(Op, BitWidth, NewMask, dl))
499 return TLO.CombineTo(Op, TLO.DAG.getNode(ISD::OR, dl, Op.getValueType(),
500 Op.getOperand(0),
501 Op.getOperand(1)));
515 EVT VT = Op.getValueType();
517 return TLO.CombineTo(Op, TLO.DAG.getNode(ISD::AND, dl, VT,
518 Op.getOperand(0), ANDC));
525 if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(Op.getOperand(1))) {
530 EVT VT = Op.getValueType();
531 SDValue New = TLO.DAG.getNode(Op.getOpcode(), dl,VT, Op.getOperand(0),
533 return TLO.CombineTo(Op, New);
537 } else if (TLO.ShrinkDemandedConstant(Op, NewMask)) {
546 if (SimplifyDemandedBits(Op.getOperand(2), NewMask, KnownZero,
549 if (SimplifyDemandedBits(Op.getOperand(1), NewMask, KnownZero2,
556 if (TLO.ShrinkDemandedConstant(Op, NewMask))
564 if (SimplifyDemandedBits(Op.getOperand(3), NewMask, KnownZero,
567 if (SimplifyDemandedBits(Op.getOperand(2), NewMask, KnownZero2,
574 if (TLO.ShrinkDemandedConstant(Op, NewMask))
582 if (ConstantSDNode *SA = dyn_cast<ConstantSDNode>(Op.getOperand(1))) {
584 SDValue InOp = Op.getOperand(0);
605 TLO.DAG.getConstant(Diff, Op.getOperand(1).getValueType());
606 EVT VT = Op.getValueType();
607 return TLO.CombineTo(Op, TLO.DAG.getNode(Opc, dl, VT,
631 TLO.CombineTo(Op,
632 TLO.DAG.getNode(ISD::ANY_EXTEND, dl, Op.getValueType(),
644 if (ConstantSDNode *SA = dyn_cast<ConstantSDNode>(Op.getOperand(1))) {
645 EVT VT = Op.getValueType();
648 SDValue InOp = Op.getOperand(0);
669 TLO.DAG.getConstant(Diff, Op.getOperand(1).getValueType());
670 return TLO.CombineTo(Op, TLO.DAG.getNode(Opc, dl, VT,
693 return TLO.CombineTo(Op,
694 TLO.DAG.getNode(ISD::SRL, dl, Op.getValueType(),
695 Op.getOperand(0), Op.getOperand(1)));
697 if (ConstantSDNode *SA = dyn_cast<ConstantSDNode>(Op.getOperand(1))) {
698 EVT VT = Op.getValueType();
713 if (SimplifyDemandedBits(Op.getOperand(0), InDemandedMask,
726 return TLO.CombineTo(Op, TLO.DAG.getNode(ISD::SRL, dl, VT,
727 Op.getOperand(0),
728 Op.getOperand(1)));
735 EVT ExVT = cast<VTSDNode>(Op.getOperand(1))->getVT();
741 SDValue InOp = Op.getOperand(0);
745 EVT ShiftAmtTy = Op.getValueType();
750 return TLO.CombineTo(Op, TLO.DAG.getNode(ISD::SHL, dl,
751 Op.getValueType(), InOp, ShiftAmt));
762 return TLO.CombineTo(Op, Op.getOperand(0));
775 if (SimplifyDemandedBits(Op.getOperand(0), InputDemandedBits,
785 return TLO.CombineTo(Op,
786 TLO.DAG.getZeroExtendInReg(Op.getOperand(0),dl,ExVT));
799 Op.getOperand(0).getValueType().getScalarType().getSizeInBits();
806 return TLO.CombineTo(Op, TLO.DAG.getNode(ISD::ANY_EXTEND, dl,
807 Op.getValueType(),
808 Op.getOperand(0)));
810 if (SimplifyDemandedBits(Op.getOperand(0), InMask,
820 EVT InVT = Op.getOperand(0).getValueType();
828 return TLO.CombineTo(Op,TLO.DAG.getNode(ISD::ANY_EXTEND, dl,
829 Op.getValueType(),
830 Op.getOperand(0)));
838 if (SimplifyDemandedBits(Op.getOperand(0), InDemandedBits, KnownZero,
846 return TLO.CombineTo(Op, TLO.DAG.getNode(ISD::ZERO_EXTEND, dl,
847 Op.getValueType(),
848 Op.getOperand(0)));
862 Op.getOperand(0).getValueType().getScalarType().getSizeInBits();
864 if (SimplifyDemandedBits(Op.getOperand(0), InMask,
876 Op.getOperand(0).getValueType().getScalarType().getSizeInBits();
878 if (SimplifyDemandedBits(Op.getOperand(0), TruncMask,
886 if (Op.getOperand(0).getNode()->hasOneUse()) {
887 SDValue In = Op.getOperand(0);
894 !isTypeDesirableForOp(ISD::SRL, Op.getValueType()))
905 TLO.DAG.getConstant(ShVal, getShiftAmountTy(Op.getValueType()));
916 Op.getValueType(),
918 return TLO.CombineTo(Op, TLO.DAG.getNode(ISD::SRL, dl,
919 Op.getValueType(),
933 EVT VT = cast<VTSDNode>(Op.getOperand(1))->getVT();
936 if (SimplifyDemandedBits(Op.getOperand(0), ~InMask | NewMask,
948 !Op.getValueType().isVector() &&
949 !Op.getOperand(0).getValueType().isVector() &&
950 NewMask == APInt::getSignBit(Op.getValueType().getSizeInBits()) &&
951 Op.getOperand(0).getValueType().isFloatingPoint()) {
952 bool OpVTLegal = isOperationLegalOrCustom(ISD::FGETSIGN, Op.getValueType());
954 if ((OpVTLegal || i32Legal) && Op.getValueType().isSimple()) {
955 EVT Ty = OpVTLegal ? Op.getValueType() : MVT::i32;
958 SDValue Sign = TLO.DAG.getNode(ISD::FGETSIGN, dl, Ty, Op.getOperand(0));
959 unsigned OpVTSizeInBits = Op.getValueType().getSizeInBits();
961 Sign = TLO.DAG.getNode(ISD::ZERO_EXTEND, dl, Op.getValueType(), Sign);
962 unsigned ShVal = Op.getValueType().getSizeInBits()-1;
963 SDValue ShAmt = TLO.DAG.getConstant(ShVal, Op.getValueType());
964 return TLO.CombineTo(Op, TLO.DAG.getNode(ISD::SHL, dl,
965 Op.getValueType(),
977 if (SimplifyDemandedBits(Op.getOperand(0), LoMask, KnownZero2,
980 if (SimplifyDemandedBits(Op.getOperand(1), LoMask, KnownZero2,
984 if (TLO.ShrinkDemandedOp(Op, BitWidth, NewMask, dl))
990 TLO.DAG.ComputeMaskedBits(Op, KnownZero, KnownOne, Depth);
997 return TLO.CombineTo(Op, TLO.DAG.getConstant(KnownOne, Op.getValueType()));
1005 void TargetLowering::computeMaskedBitsForTargetNode(const SDValue Op,
1010 assert((Op.getOpcode() >= ISD::BUILTIN_OP_END ||
1011 Op.getOpcode() == ISD::INTRINSIC_WO_CHAIN ||
1012 Op.getOpcode() == ISD::INTRINSIC_W_CHAIN ||
1013 Op.getOpcode() == ISD::INTRINSIC_VOID) &&
1014 "Should use MaskedValueIsZero if you don't know whether Op"
1022 unsigned TargetLowering::ComputeNumSignBitsForTargetNode(SDValue Op,
1024 assert((Op.getOpcode() >= ISD::BUILTIN_OP_END ||
1025 Op.getOpcode() == ISD::INTRINSIC_WO_CHAIN ||
1026 Op.getOpcode() == ISD::INTRINSIC_W_CHAIN ||
1027 Op.getOpcode() == ISD::INTRINSIC_VOID) &&
1028 "Should use ComputeNumSignBits if you don't know whether Op"
1653 // If X op Y == Y op X, try other combinations.
1928 void TargetLowering::LowerAsmOperandForConstraint(SDValue Op,
1939 if (Op.getOpcode() == ISD::BasicBlock) {
1940 Ops.push_back(Op);
1950 ConstantSDNode *C = dyn_cast<ConstantSDNode>(Op);
1951 GlobalAddressSDNode *GA = dyn_cast<GlobalAddressSDNode>(Op);
1954 if (Op.getOpcode() == ISD::ADD) {
1955 C = dyn_cast<ConstantSDNode>(Op.getOperand(1));
1956 GA = dyn_cast<GlobalAddressSDNode>(Op.getOperand(0));
1958 C = dyn_cast<ConstantSDNode>(Op.getOperand(0));
1959 GA = dyn_cast<GlobalAddressSDNode>(Op.getOperand(1));
1973 Op.getValueType(), Offs));
2359 SDValue Op, SelectionDAG *DAG) {
2374 if (CType == TargetLowering::C_Other && Op.getNode()) {
2378 TLI.LowerAsmOperandForConstraint(Op, OpInfo.Codes[i],
2409 SDValue Op,
2418 ChooseConstraint(OpInfo, *this, Op, DAG);