reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced

References

lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
  141   if (!I) {
  149   if (Depth != 0 && !I->hasOneUse())
  150     return SimplifyMultipleUseDemandedBits(I, DemandedMask, Known, Depth, CxtI);
  161   switch (I->getOpcode()) {
  163     computeKnownBits(I, Known, Depth, CxtI);
  167     if (SimplifyDemandedBits(I, 1, DemandedMask, RHSKnown, Depth + 1) ||
  168         SimplifyDemandedBits(I, 0, DemandedMask & ~RHSKnown.Zero, LHSKnown,
  170       return I;
  187       return I->getOperand(0);
  189       return I->getOperand(1);
  192     if (ShrinkDemandedConstant(I, 1, DemandedMask & ~LHSKnown.Zero))
  193       return I;
  201     if (SimplifyDemandedBits(I, 1, DemandedMask, RHSKnown, Depth + 1) ||
  202         SimplifyDemandedBits(I, 0, DemandedMask & ~RHSKnown.One, LHSKnown,
  204       return I;
  221       return I->getOperand(0);
  223       return I->getOperand(1);
  226     if (ShrinkDemandedConstant(I, 1, DemandedMask))
  227       return I;
  234     if (SimplifyDemandedBits(I, 1, DemandedMask, RHSKnown, Depth + 1) ||
  235         SimplifyDemandedBits(I, 0, DemandedMask, LHSKnown, Depth + 1))
  236       return I;
  255       return I->getOperand(0);
  257       return I->getOperand(1);
  264         BinaryOperator::CreateOr(I->getOperand(0), I->getOperand(1),
  264         BinaryOperator::CreateOr(I->getOperand(0), I->getOperand(1),
  265                                  I->getName());
  266       return InsertNewInstWith(Or, *I);
  277       Instruction *And = BinaryOperator::CreateAnd(I->getOperand(0), AndC);
  278       return InsertNewInstWith(And, *I);
  283     if (ShrinkDemandedConstant(I, 1, DemandedMask))
  284       return I;
  290     if (Instruction *LHSInst = dyn_cast<Instruction>(I->getOperand(0)))
  292           isa<ConstantInt>(I->getOperand(1)) &&
  296         ConstantInt *XorRHS = cast<ConstantInt>(I->getOperand(1));
  300           ConstantInt::get(I->getType(), NewMask & AndRHS->getValue());
  301         Instruction *NewAnd = BinaryOperator::CreateAnd(I->getOperand(0), AndC);
  302         InsertNewInstWith(NewAnd, *I);
  305           ConstantInt::get(I->getType(), NewMask & XorRHS->getValue());
  307         return InsertNewInstWith(NewXor, *I);
  318     SelectPatternFlavor SPF = matchSelectPattern(I, LHS, RHS).Flavor;
  344     if (SimplifyDemandedBits(I, 2, DemandedMask, RHSKnown, Depth + 1) ||
  345         SimplifyDemandedBits(I, 1, DemandedMask, LHSKnown, Depth + 1))
  346       return I;
  351     if (ShrinkDemandedConstant(I, 1, DemandedMask) ||
  352         ShrinkDemandedConstant(I, 2, DemandedMask))
  353       return I;
  362     unsigned SrcBitWidth = I->getOperand(0)->getType()->getScalarSizeInBits();
  366     if (SimplifyDemandedBits(I, 0, InputDemandedMask, InputKnown, Depth + 1))
  367       return I;
  375     if (!I->getOperand(0)->getType()->isIntOrIntVectorTy())
  378     if (VectorType *DstVTy = dyn_cast<VectorType>(I->getType())) {
  380             dyn_cast<VectorType>(I->getOperand(0)->getType())) {
  387     } else if (I->getOperand(0)->getType()->isVectorTy())
  391     if (SimplifyDemandedBits(I, 0, DemandedMask, Known, Depth + 1))
  392       return I;
  397     unsigned SrcBitWidth = I->getOperand(0)->getType()->getScalarSizeInBits();
  407     if (SimplifyDemandedBits(I, 0, InputDemandedBits, InputKnown, Depth + 1))
  408       return I;
  415       CastInst *NewCast = new ZExtInst(I->getOperand(0), VTy, I->getName());
  415       CastInst *NewCast = new ZExtInst(I->getOperand(0), VTy, I->getName());
  416       return InsertNewInstWith(NewCast, *I);
  433     if (ShrinkDemandedConstant(I, 0, DemandedFromOps) ||
  434         SimplifyDemandedBits(I, 0, DemandedFromOps, LHSKnown, Depth + 1) ||
  435         ShrinkDemandedConstant(I, 1, DemandedFromOps) ||
  436         SimplifyDemandedBits(I, 1, DemandedFromOps, RHSKnown, Depth + 1)) {
  441         BinaryOperator &BinOP = *cast<BinaryOperator>(I);
  445       return I;
  451       return I->getOperand(0);
  454     if ((I->getOpcode() == Instruction::Add ||
  457       return I->getOperand(1);
  460     bool NSW = cast<OverflowingBinaryOperator>(I)->hasNoSignedWrap();
  461     Known = KnownBits::computeForAddSub(I->getOpcode() == Instruction::Add,
  467     if (match(I->getOperand(1), m_APInt(SA))) {
  469       if (match(I->getOperand(0), m_Shr(m_Value(), m_APInt(ShrAmt))))
  470         if (Instruction *Shr = dyn_cast<Instruction>(I->getOperand(0)))
  471           if (Value *R = simplifyShrShlDemandedBits(Shr, *ShrAmt, I, *SA,
  479       ShlOperator *IOp = cast<ShlOperator>(I);
  485       if (SimplifyDemandedBits(I, 0, DemandedMaskIn, Known, Depth + 1))
  486         return I;
  498     if (match(I->getOperand(1), m_APInt(SA))) {
  506       if (cast<LShrOperator>(I)->isExact())
  509       if (SimplifyDemandedBits(I, 0, DemandedMaskIn, Known, Depth + 1))
  510         return I;
  527                         I->getOperand(0), I->getOperand(1), I->getName());
  527                         I->getOperand(0), I->getOperand(1), I->getName());
  527                         I->getOperand(0), I->getOperand(1), I->getName());
  528       return InsertNewInstWith(NewVal, *I);
  534       return I->getOperand(0);
  537     if (match(I->getOperand(1), m_APInt(SA))) {
  549       if (cast<AShrOperator>(I)->isExact())
  552       if (SimplifyDemandedBits(I, 0, DemandedMaskIn, Known, Depth + 1))
  553         return I;
  555       unsigned SignBits = ComputeNumSignBits(I->getOperand(0), Depth + 1, CxtI);
  569         BinaryOperator *LShr = BinaryOperator::CreateLShr(I->getOperand(0),
  570                                                           I->getOperand(1));
  571         LShr->setIsExact(cast<BinaryOperator>(I)->isExact());
  572         return InsertNewInstWith(LShr, *I);
  582     if (match(I->getOperand(1), m_APInt(SA))) {
  584       if (cast<UDivOperator>(I)->isExact())
  591       if (SimplifyDemandedBits(I, 0, DemandedMaskIn, LHSKnown, Depth + 1))
  592         return I;
  601     if (ConstantInt *Rem = dyn_cast<ConstantInt>(I->getOperand(1))) {
  609           return I->getOperand(0);
  613         if (SimplifyDemandedBits(I, 0, Mask2, LHSKnown, Depth + 1))
  614           return I;
  638       computeKnownBits(I->getOperand(0), LHSKnown, Depth + 1, CxtI);
  647     if (SimplifyDemandedBits(I, 0, AllOnes, Known2, Depth + 1) ||
  648         SimplifyDemandedBits(I, 1, AllOnes, Known2, Depth + 1))
  649       return I;
  656     if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) {
  680                     ConstantInt::get(I->getType(), InputBit-ResultBit));
  683                     ConstantInt::get(I->getType(), ResultBit-InputBit));
  684           NewVal->takeName(I);
  685           return InsertNewInstWith(NewVal, *I);
  694         if (!match(I->getOperand(2), m_APInt(SA)))
  705         if (SimplifyDemandedBits(I, 0, DemandedMaskLHS, LHSKnown, Depth + 1) ||
  706             SimplifyDemandedBits(I, 1, DemandedMaskRHS, RHSKnown, Depth + 1))
  707           return I;