47 #define DEBUG_TYPE "instcombine" 102 if (isa<FPMathOperator>(BO))
125 const APInt *SelTC, *SelFC;
137 bool CreateAnd =
false;
179 bool ExtraBitInTC = TC.
ugt(FC);
204 unsigned ValZeros = ValC.
logBase2();
205 unsigned AndZeros = AndMask.
logBase2();
213 if (ValZeros > AndZeros) {
215 V = Builder.
CreateShl(V, ValZeros - AndZeros);
216 }
else if (ValZeros < AndZeros) {
217 V = Builder.
CreateLShr(V, AndZeros - ValZeros);
246 case Instruction::Mul:
247 case Instruction::And:
248 case Instruction::Or:
249 case Instruction::Xor:
251 case Instruction::Sub:
252 case Instruction::Shl:
253 case Instruction::LShr:
254 case Instruction::AShr:
267 case Instruction::Sub:
268 case Instruction::Or:
269 case Instruction::Xor:
270 case Instruction::Shl:
271 case Instruction::LShr:
272 case Instruction::AShr:
274 case Instruction::And:
276 case Instruction::Mul:
318 if (TI->
getOpcode() != Instruction::BitCast &&
340 Value *NewSel = Builder.CreateSelect(Cond, X, Y, SI.
getName() +
".v", &
SI);
343 if (TI->
getOpcode() != Instruction::FNeg)
345 return UnaryOperator::CreateFNeg(NewSel);
353 (!isa<BinaryOperator>(TI) && !isa<GetElementPtrInst>(TI)) ||
358 Value *MatchOp, *OtherOpT, *OtherOpF;
364 MatchIsOpZero =
true;
369 MatchIsOpZero =
false;
376 MatchIsOpZero =
true;
381 MatchIsOpZero =
true;
394 Value *NewSI = Builder.CreateSelect(Cond, OtherOpT, OtherOpF,
396 Value *Op0 = MatchIsOpZero ? MatchOp : NewSI;
397 Value *Op1 = MatchIsOpZero ? NewSI : MatchOp;
398 if (
auto *BO = dyn_cast<BinaryOperator>(TI)) {
404 if (
auto *TGEP = dyn_cast<GetElementPtrInst>(TI)) {
405 auto *FGEP = cast<GetElementPtrInst>(FI);
406 Type *ElementType = TGEP->getResultElementType();
407 return TGEP->isInBounds() && FGEP->isInBounds()
428 if (
auto *TVI = dyn_cast<BinaryOperator>(TrueVal)) {
429 if (TVI->hasOneUse() && !isa<Constant>(FalseVal)) {
431 unsigned OpToFold = 0;
432 if ((SFO & 1) && FalseVal == TVI->getOperand(0)) {
434 }
else if ((SFO & 2) && FalseVal == TVI->getOperand(1)) {
440 Value *OOp = TVI->getOperand(2-OpToFold);
445 if (!isa<Constant>(OOp) || (OOpIsAPInt &&
isSelect01(CI, *OOpC))) {
459 if (
auto *FVI = dyn_cast<BinaryOperator>(FalseVal)) {
460 if (FVI->hasOneUse() && !isa<Constant>(TrueVal)) {
462 unsigned OpToFold = 0;
463 if ((SFO & 1) && TrueVal == FVI->getOperand(0)) {
465 }
else if ((SFO & 2) && TrueVal == FVI->getOperand(1)) {
471 Value *OOp = FVI->getOperand(2-OpToFold);
476 if (!isa<Constant>(OOp) || (OOpIsAPInt &&
isSelect01(CI, *OOpC))) {
531 return new ZExtInst(ICmpNeZero, SelType);
565 const auto *Ashr = cast<Instruction>(FalseVal);
567 bool IsExact = Ashr->isExact() && cast<Instruction>(TrueVal)->isExact();
633 bool OrOnTrueVal =
false;
638 if (!OrOnFalseVal && !OrOnTrueVal)
641 Value *
Y = OrOnFalseVal ? TrueVal : FalseVal;
645 bool NeedXor = (!IsEqualZero && OrOnFalseVal) || (IsEqualZero && OrOnTrueVal);
646 bool NeedShift = C1Log != C2Log;
651 Value *Or = OrOnFalseVal ? FalseVal : TrueVal;
652 if ((NeedShift + NeedXor + NeedZExtTrunc) >
665 }
else if (C1Log > C2Log) {
681 const Value *TrueVal,
682 const Value *FalseVal,
705 "Unexpected isUnsigned predicate!");
711 bool IsNegative =
false;
825 if (!
match(TrueVal, m_Intrinsic<Intrinsic::ctlz>()))
829 auto *II = cast<IntrinsicInst>(TrueVal);
860 Value *Count = FalseVal;
861 Value *ValueOnZero = TrueVal;
931 if ((CmpLHS == TrueVal && AdjustedRHS == FalseVal) ||
932 (CmpLHS == FalseVal && AdjustedRHS == TrueVal)) {
947 AdjustedRHS = SextRHS;
949 SextRHS == TrueVal) {
951 AdjustedRHS = SextRHS;
960 AdjustedRHS = ZextRHS;
962 ZextRHS == TrueVal) {
964 AdjustedRHS = ZextRHS;
976 CmpRHS = AdjustedRHS;
1031 "Unexpected results from matchSelectPattern");
1060 "Unexpected result from matchSelectPattern");
1067 bool CmpCanonicalized = !CmpUsesNegatedOp &&
1073 if (CmpCanonicalized && RHSCanonicalized)
1082 if (!CmpCanonicalized) {
1085 if (CmpUsesNegatedOp)
1090 if (!RHSCanonicalized) {
1106 assert(FVal == LHS &&
"Unexpected results from matchSelectPattern");
1110 assert(TVal == LHS &&
"Unexpected results from matchSelectPattern");
1125 if (
auto *BO = dyn_cast<BinaryOperator>(V)) {
1126 if (BO->getOperand(0) ==
Op)
1127 return SimplifyBinOp(BO->getOpcode(), ReplaceOp, BO->getOperand(1), Q);
1128 if (BO->getOperand(1) ==
Op)
1129 return SimplifyBinOp(BO->getOpcode(), BO->getOperand(0), ReplaceOp, Q);
1167 if (simplifyWithOpReplaced(FalseVal, CmpLHS, CmpRHS, Q) == TrueVal ||
1168 simplifyWithOpReplaced(FalseVal, CmpRHS, CmpLHS, Q) == TrueVal ||
1169 simplifyWithOpReplaced(TrueVal, CmpLHS, CmpRHS, Q) == FalseVal ||
1170 simplifyWithOpReplaced(TrueVal, CmpRHS, CmpLHS, Q) == FalseVal) {
1171 if (
auto *FalseInst = dyn_cast<Instruction>(FalseVal))
1172 FalseInst->dropPoisonGeneratingFlags();
1209 case ICmpInst::Predicate::ICMP_ULT:
1211 case ICmpInst::Predicate::ICMP_ULE:
1216 case ICmpInst::Predicate::ICMP_UGT:
1227 case ICmpInst::Predicate::ICMP_UGE:
1245 else if (!
match(Cmp00,
1253 Value *ReplacementLow, *ReplacementHigh;
1269 case ICmpInst::Predicate::ICMP_SLT:
1271 case ICmpInst::Predicate::ICMP_SLE:
1276 case ICmpInst::Predicate::ICMP_SGT:
1286 case ICmpInst::Predicate::ICMP_SGE:
1289 std::swap(ReplacementLow, ReplacementHigh);
1313 Value *MaybeReplacedLow =
1314 Builder.
CreateSelect(ShouldReplaceLow, ReplacementLow, X);
1318 return MaybeReplacedHigh;
1356 Value *SelVal0, *SelVal1;
1365 auto MatchesSelectValue = [SelVal0, SelVal1](
Constant *
C) {
1366 return C->isElementWiseEqual(SelVal0) ||
C->isElementWiseEqual(SelVal1);
1370 if (MatchesSelectValue(C0))
1375 if (!FlippedStrictness)
1379 if (!MatchesSelectValue(FlippedStrictness->second))
1383 InstCombiner::BuilderTy::InsertPointGuard Guard(Builder);
1387 Value *NewCmp = Builder.
CreateICmp(Pred, X, FlippedStrictness->second,
1399 if (
Value *V = foldSelectValueEquivalence(SI, *ICI, SQ))
1400 return replaceInstUsesWith(SI, V);
1402 if (
Instruction *NewSel = canonicalizeMinMaxWithConstant(SI, *ICI, Builder))
1405 if (
Instruction *NewAbs = canonicalizeAbsNabs(SI, *ICI, Builder))
1408 if (
Instruction *NewAbs = canonicalizeClampLike(SI, *ICI, Builder))
1412 tryToReuseConstantFromSelectInComparison(SI, *ICI, Builder))
1415 bool Changed = adjustMinMax(SI, *ICI);
1418 return replaceInstUsesWith(SI, V);
1426 if (CmpRHS != CmpLHS && isa<Constant>(CmpRHS)) {
1447 bool IsBitTest =
false;
1455 Y = &MinSignedValue;
1457 TrueWhenUnset =
false;
1460 Y = &MinSignedValue;
1462 TrueWhenUnset =
true;
1467 if (TrueWhenUnset && TrueVal == X &&
1471 else if (!TrueWhenUnset && FalseVal == X &&
1475 else if (TrueWhenUnset && FalseVal == X &&
1479 else if (!TrueWhenUnset && TrueVal == X &&
1484 return replaceInstUsesWith(SI, V);
1492 if (
Instruction *V = foldSelectCtlzToCttz(ICI, TrueVal, FalseVal, Builder))
1496 return replaceInstUsesWith(SI, V);
1499 return replaceInstUsesWith(SI, V);
1501 if (
Value *V = foldSelectCttzCtlz(ICI, TrueVal, FalseVal, Builder))
1502 return replaceInstUsesWith(SI, V);
1505 return replaceInstUsesWith(SI, V);
1508 return replaceInstUsesWith(SI, V);
1510 return Changed ? &
SI :
nullptr;
1522 static bool canSelectOperandBeMappingIntoPredBlock(
const Value *V,
1527 if (!I)
return true;
1533 if (
const PHINode *VP = dyn_cast<PHINode>(I))
1534 if (VP->getParent() == CondPHI->
getParent())
1558 if (C == A || C == B) {
1563 return replaceInstUsesWith(Outer, Inner);
1572 return replaceInstUsesWith(Outer, C);
1576 const APInt *CB, *CC;
1585 return replaceInstUsesWith(Outer, Inner);
1607 return replaceInstUsesWith(Outer, Inner);
1613 return replaceInstUsesWith(Outer, Inner);
1624 return replaceInstUsesWith(Outer, NewSI);
1627 auto IsFreeOrProfitableToInvert =
1628 [&](
Value *V,
Value *&NotV,
bool &ElidesXor) {
1644 Value *NotA, *NotB, *NotC;
1645 bool ElidesXor =
false;
1657 IsFreeOrProfitableToInvert(A, NotA, ElidesXor) &&
1658 IsFreeOrProfitableToInvert(B, NotB, ElidesXor) &&
1659 IsFreeOrProfitableToInvert(C, NotC, ElidesXor) && ElidesXor) {
1671 return replaceInstUsesWith(Outer, NewOuter);
1686 if (!TI || !FI || !TI->
hasOneUse() || !FI->hasOneUse())
1690 if ((TI->
getOpcode() == Instruction::Sub &&
1692 (TI->
getOpcode() == Instruction::FSub &&
1693 FI->getOpcode() == Instruction::FAdd)) {
1696 }
else if ((FI->getOpcode() == Instruction::Sub &&
1698 (FI->getOpcode() == Instruction::FSub &&
1699 TI->
getOpcode() == Instruction::FAdd)) {
1705 Value *OtherAddOp =
nullptr;
1706 if (SubOp->getOperand(0) == AddOp->
getOperand(0)) {
1708 }
else if (SubOp->getOperand(0) == AddOp->
getOperand(1)) {
1717 NegVal = Builder.
CreateFNeg(SubOp->getOperand(1));
1718 if (
Instruction *NegInst = dyn_cast<Instruction>(NegVal)) {
1720 Flags &= SubOp->getFastMathFlags();
1721 NegInst->setFastMathFlags(Flags);
1724 NegVal = Builder.
CreateNeg(SubOp->getOperand(1));
1727 Value *NewTrueOp = OtherAddOp;
1728 Value *NewFalseOp = NegVal;
1736 BinaryOperator::CreateFAdd(SubOp->getOperand(0), NewSel);
1739 Flags &= SubOp->getFastMathFlags();
1768 auto IsSignedSaturateLimit = [&](
Value *Limit,
bool IsAdd) {
1772 Value *TrueVal, *FalseVal, *
Op;
1778 auto IsZeroOrOne = [](
const APInt &
C) {
1781 auto IsMinMax = [&](
Value *Min,
Value *Max) {
1788 if (Op != X && Op != Y)
1797 IsMinMax(TrueVal, FalseVal))
1804 IsMinMax(FalseVal, TrueVal))
1810 IsMinMax(TrueVal, FalseVal))
1815 IsMinMax(FalseVal, TrueVal))
1820 IsMinMax(FalseVal, TrueVal))
1825 IsMinMax(TrueVal, FalseVal))
1836 NewIntrinsicID = Intrinsic::uadd_sat;
1837 else if (II->
getIntrinsicID() == Intrinsic::usub_with_overflow &&
1840 NewIntrinsicID = Intrinsic::usub_sat;
1841 else if (II->
getIntrinsicID() == Intrinsic::sadd_with_overflow &&
1842 IsSignedSaturateLimit(TrueVal,
true))
1851 NewIntrinsicID = Intrinsic::sadd_sat;
1852 else if (II->
getIntrinsicID() == Intrinsic::ssub_with_overflow &&
1853 IsSignedSaturateLimit(TrueVal,
false))
1862 NewIntrinsicID = Intrinsic::ssub_sat;
1883 if (ExtOpcode != Instruction::ZExt && ExtOpcode != Instruction::SExt)
1902 Value *TruncCVal = cast<Value>(TruncC);
1944 for (
unsigned i = 0; i != NumElts; ++i) {
1955 }
else if (isa<UndefValue>(Elt)) {
1974 static Instruction *canonicalizeScalarSelectOfVecs(
2010 if (TVal == A || TVal == B || FVal == A || FVal == B)
2027 if (TSrc == C && FSrc == D) {
2031 }
else if (TSrc == D && FSrc == C) {
2073 if (Extract->getIndices()[0] !=
I)
2088 auto *CmpXchg = isExtractFromCmpXchg(SI.
getCondition(), 1);
2105 if (
X == CmpXchg &&
X->getCompareOperand() == SI.
getTrueValue()) {
2122 const APInt *C1, *C2;
2159 const APInt *MinValue, *MaxValue;
2163 }
else if (
match(&MinMax1,
2172 if (!(*MaxValue + 1).isPowerOf2() || -*MinValue != *MaxValue + 1)
2175 unsigned NewBitWidth = (*MaxValue + 1).logBase2() + 1;
2201 IntrinsicID = Intrinsic::sadd_sat;
2202 else if (AddSub->
getOpcode() == Instruction::Sub)
2203 IntrinsicID = Intrinsic::ssub_sat;
2234 Value *MinMaxOp =
nullptr;
2235 Value *ThirdOp =
nullptr;
2239 if (D == A || C == A) {
2244 }
else if (D == B || C == B) {
2252 if (D == A || D == B) {
2257 }
else if (C == A || C == B) {
2264 if (!MinMaxOp || !ThirdOp)
2288 auto ShiftOpcode0 = cast<BinaryOperator>(Or0)->
getOpcode();
2289 auto ShiftOpcode1 = cast<BinaryOperator>(Or1)->
getOpcode();
2290 if (ShiftOpcode0 == ShiftOpcode1)
2319 bool IsFshl = (ShAmt == SA0 && ShiftOpcode0 == BinaryOperator::Shl) ||
2320 (ShAmt == SA1 && ShiftOpcode1 == BinaryOperator::Shl);
2321 Intrinsic::ID IID = IsFshl ? Intrinsic::fshl : Intrinsic::fshr;
2337 if (isa<UndefValue>(TrueVal) || isa<UndefValue>(FalseVal)) {
2349 SQ.getWithInstruction(&SI)))
2350 return replaceInstUsesWith(SI, V);
2355 if (
Instruction *
I = canonicalizeScalarSelectOfVecs(SI, Builder))
2366 CmpInst *Cond = cast<CmpInst>(CondVal);
2379 return BinaryOperator::CreateOr(CondVal, FalseVal);
2384 return BinaryOperator::CreateAnd(NotCond, FalseVal);
2388 return BinaryOperator::CreateAnd(CondVal, TrueVal);
2393 return BinaryOperator::CreateOr(NotCond, TrueVal);
2398 if (CondVal == TrueVal)
2399 return BinaryOperator::CreateOr(CondVal, FalseVal);
2400 if (CondVal == FalseVal)
2401 return BinaryOperator::CreateAnd(CondVal, TrueVal);
2406 return BinaryOperator::CreateAnd(TrueVal, FalseVal);
2408 return BinaryOperator::CreateOr(TrueVal, FalseVal);
2421 return new ZExtInst(CondVal, SelType);
2425 return new SExtInst(CondVal, SelType);
2430 return new ZExtInst(NotCond, SelType);
2436 return new SExtInst(NotCond, SelType);
2441 if (
FCmpInst *FCI = dyn_cast<FCmpInst>(CondVal)) {
2443 if ((Cmp0 == TrueVal && Cmp1 == FalseVal) ||
2444 (Cmp0 == FalseVal && Cmp1 == TrueVal)) {
2458 return replaceInstUsesWith(SI, NewSel);
2478 return replaceInstUsesWith(SI, Fabs);
2486 return replaceInstUsesWith(SI, Fabs);
2499 return replaceInstUsesWith(SI, Fabs);
2511 return replaceInstUsesWith(SI, Fabs);
2515 if (
ICmpInst *ICI = dyn_cast<ICmpInst>(CondVal))
2516 if (
Instruction *Result = foldSelectInstWithICmp(SI, ICI))
2527 if (TI && FI && TI->
getOpcode() == FI->getOpcode())
2536 if (
Instruction *FoldI = foldSelectIntoOp(SI, TrueVal, FalseVal))
2546 if (
Instruction *R = foldSPFofSPF(cast<Instruction>(LHS), SPF2, LHS2,
2547 RHS2, SI, SPF, RHS))
2550 if (
Instruction *R = foldSPFofSPF(cast<Instruction>(RHS), SPF2, LHS2,
2551 RHS2, SI, SPF, LHS))
2562 bool IsCastNeeded = LHS->
getType() != SelType;
2563 Value *CmpLHS = cast<CmpInst>(CondVal)->getOperand(0);
2564 Value *CmpRHS = cast<CmpInst>(CondVal)->getOperand(1);
2567 ((CmpLHS != LHS && CmpLHS != RHS) ||
2568 (CmpRHS != LHS && CmpRHS != RHS)))) {
2573 Cmp = Builder.
CreateICmp(MinMaxPred, LHS, RHS);
2577 cast<FPMathOperator>(SI.
getCondition())->getFastMathFlags();
2579 Cmp = Builder.
CreateFCmp(MinMaxPred, LHS, RHS);
2584 return replaceInstUsesWith(SI, NewSI);
2587 return replaceInstUsesWith(SI, NewCast);
2605 cast<SelectInst>(NewMinMax)->
setMetadata(LLVMContext::MD_prof, MD);
2608 cast<SelectInst>(NewMinMax)->swapProfMetadata();
2622 if (
Instruction *
I = moveAddAfterMinMax(SPF, LHS, RHS, Builder))
2625 if (
Instruction *
I = factorizeMinMaxTree(SPF, LHS, RHS, Builder))
2637 return replaceInstUsesWith(
2641 return replaceInstUsesWith(
2648 if (canSelectOperandBeMappingIntoPredBlock(TrueVal, SI) &&
2649 canSelectOperandBeMappingIntoPredBlock(FalseVal, SI))
2653 if (
SelectInst *TrueSI = dyn_cast<SelectInst>(TrueVal)) {
2654 if (TrueSI->getCondition()->getType() == CondVal->
getType()) {
2656 if (TrueSI->getCondition() == CondVal) {
2665 if (TrueSI->getFalseValue() == FalseVal && TrueSI->
hasOneUse()) {
2673 if (
SelectInst *FalseSI = dyn_cast<SelectInst>(FalseVal)) {
2674 if (FalseSI->getCondition()->getType() == CondVal->
getType()) {
2676 if (FalseSI->getCondition() == CondVal) {
2683 if (FalseSI->getTrueValue() == TrueVal && FalseSI->
hasOneUse()) {
2684 Value *Or = Builder.
CreateOr(CondVal, FalseSI->getCondition());
2694 switch (BO->getOpcode()) {
2697 case Instruction::SRem:
2698 case Instruction::URem:
2699 case Instruction::SDiv:
2700 case Instruction::UDiv:
2710 canMergeSelectThroughBinop(TrueBO)) {
2711 if (
auto *TrueBOSI = dyn_cast<SelectInst>(TrueBO->
getOperand(0))) {
2712 if (TrueBOSI->getCondition() == CondVal) {
2713 TrueBO->
setOperand(0, TrueBOSI->getTrueValue());
2714 Worklist.Add(TrueBO);
2718 if (
auto *TrueBOSI = dyn_cast<SelectInst>(TrueBO->
getOperand(1))) {
2719 if (TrueBOSI->getCondition() == CondVal) {
2720 TrueBO->
setOperand(1, TrueBOSI->getTrueValue());
2721 Worklist.Add(TrueBO);
2730 canMergeSelectThroughBinop(FalseBO)) {
2731 if (
auto *FalseBOSI = dyn_cast<SelectInst>(FalseBO->
getOperand(0))) {
2732 if (FalseBOSI->getCondition() == CondVal) {
2733 FalseBO->
setOperand(0, FalseBOSI->getFalseValue());
2734 Worklist.Add(FalseBO);
2738 if (
auto *FalseBOSI = dyn_cast<SelectInst>(FalseBO->
getOperand(1))) {
2739 if (FalseBOSI->getCondition() == CondVal) {
2740 FalseBO->
setOperand(1, FalseBOSI->getFalseValue());
2741 Worklist.Add(FalseBO);
2756 if (
VectorType *VecTy = dyn_cast<VectorType>(SelType)) {
2757 unsigned VWidth = VecTy->getNumElements();
2758 APInt UndefElts(VWidth, 0);
2760 if (
Value *V = SimplifyDemandedVectorElts(&SI, AllOnesEltMask, UndefElts)) {
2762 return replaceInstUsesWith(SI, V);
2776 return replaceInstUsesWith(SI, TrueVal);
2778 return replaceInstUsesWith(SI, FalseVal);
2781 if (
Instruction *BitCastSel = foldSelectCmpBitcasts(SI, Builder))
MaxMin_match< ICmpInst, LHS, RHS, umin_pred_ty > m_UMin(const LHS &L, const RHS &R)
cst_pred_ty< icmp_pred_with_threshold > m_SpecificInt_ICMP(ICmpInst::Predicate Predicate, const APInt &Threshold)
Match an integer or vector with every element comparing 'pred' (eg/ne/...) to Threshold.
bool isFPPredicate() const
BinaryOp_match< LHS, RHS, Instruction::And > m_And(const LHS &L, const RHS &R)
void computeKnownBits(const Value *V, KnownBits &Known, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, OptimizationRemarkEmitter *ORE=nullptr, bool UseInstrInfo=true)
Determine which bits of V are known to be either zero or one and return them in the KnownZero/KnownOn...
static bool isSelect01(const APInt &C1I, const APInt &C2I)
static ConstantInt * getFalse(LLVMContext &Context)
static Instruction * foldSelectBinOpIdentity(SelectInst &Sel, const TargetLibraryInfo &TLI)
Replace a select operand based on an equality comparison with the identity constant of a binop...
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
Value * CreateICmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="")
This class is the base class for the comparison instructions.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
void setFastMathFlags(FastMathFlags FMF)
Convenience function for setting multiple fast-math flags on this instruction, which must be an opera...
bool hasNoSignedZeros() const
Determine whether the no-signed-zeros flag is set.
class_match< CmpInst > m_Cmp()
Matches any compare instruction and ignore it.
ThreeOps_match< Cond, LHS, RHS, Instruction::Select > m_Select(const Cond &C, const LHS &L, const RHS &R)
Matches SelectInst.
static APInt getAllOnesValue(unsigned numBits)
Get the all-ones value.
BinaryOp_match< LHS, RHS, Instruction::Sub > m_Sub(const LHS &L, const RHS &R)
is_zero m_Zero()
Match any null constant or a vector with all elements equal to 0.
DiagnosticInfoOptimizationBase::Argument NV
static BinaryOperator * CreateNot(Value *Op, const Twine &Name="", Instruction *InsertBefore=nullptr)
Value * CreateIsNotNull(Value *Arg, const Twine &Name="")
Return an i1 value testing if Arg is not null.
Value * CreateZExtOrTrunc(Value *V, Type *DestTy, const Twine &Name="")
Create a ZExt or Trunc from the integer value V to DestTy.
This class represents lattice values for constants.
BinaryOps getOpcode() const
Represents an op.with.overflow intrinsic.
Value * CreateXor(Value *LHS, Value *RHS, const Twine &Name="")
bool decomposeBitTestICmp(Value *LHS, Value *RHS, CmpInst::Predicate &Pred, Value *&X, APInt &Mask, bool LookThroughTrunc=true)
Decompose an icmp into the form ((X & Mask) pred 0) if possible.
An instruction that atomically checks whether a specified value is in a memory location, and, if it is, stores a new value there.
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
This class represents zero extension of integer types.
void push_back(const T &Elt)
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value *> IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Value * CreateICmpSLT(Value *LHS, Value *RHS, const Twine &Name="")
bool slt(const APInt &RHS) const
Signed less than comparison.
class_match< Constant > m_Constant()
Match an arbitrary Constant and ignore it.
static bool isCanonicalPredicate(CmpInst::Predicate Pred)
Predicate canonicalization reduces the number of patterns that need to be matched by other transforms...
const Value * getTrueValue() const
BinaryOp_match< LHS, RHS, Instruction::AShr > m_AShr(const LHS &L, const RHS &R)
0 1 0 0 True if ordered and less than
This instruction constructs a fixed permutation of two input vectors.
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr="", Instruction *InsertBefore=nullptr, Instruction *MDFrom=nullptr)
LLVMContext & getContext() const
All values hold a context through their type.
static unsigned getSelectFoldableOperands(BinaryOperator *I)
We want to turn code that looks like this: C = or A, B D = select cond, C, A into: C = select cond...
1 1 1 0 True if unordered or not equal
static CastInst * CreateBitOrPointerCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Create a BitCast, a PtrToInt, or an IntToPTr cast instruction.
bool sgt(const APInt &RHS) const
Signed greater than comparison.
static bool isEquality(Predicate P)
Return true if this predicate is either EQ or NE.
Value * CreateSExt(Value *V, Type *DestTy, const Twine &Name="")
void setArgOperand(unsigned i, Value *v)
SelectPatternFlavor getInverseMinMaxFlavor(SelectPatternFlavor SPF)
Return the inverse minimum/maximum flavor of the specified flavor.
This class represents a sign extension of integer types.
BinaryOp_match< LHS, RHS, Instruction::FSub > m_FSub(const LHS &L, const RHS &R)
static Constant * getSub(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
bool isVectorTy() const
True if this is an instance of VectorType.
void reserve(size_type N)
bool sle(const APInt &RHS) const
Signed less or equal comparison.
void copyIRFlags(const Value *V, bool IncludeWrapFlags=true)
Convenience method to copy supported exact, fast-math, and (optionally) wrapping flags from V to this...
AnyBinaryOp_match< LHS, RHS, true > m_c_BinOp(const LHS &L, const RHS &R)
Matches a BinaryOperator with LHS and RHS in either order.
static bool isFreeToInvert(Value *V, bool WillInvertAllUses)
Return true if the specified value is free to invert (apply ~ to).
cst_pred_ty< is_zero_int > m_ZeroInt()
Match an integer 0 or a vector with all elements equal to 0.
bool Ordered
Only applicable if Flavor is SPF_FMINNUM or SPF_FMAXNUM.
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
unsigned getBitWidth() const
Return the number of bits in the APInt.
BinOpPred_match< LHS, RHS, is_logical_shift_op > m_LogicalShift(const LHS &L, const RHS &R)
Matches logical shift operations.
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
Value * CreateNot(Value *V, const Twine &Name="")
Value * getArgOperand(unsigned i) const
static BinaryOperator * CreateNSW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name="")
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
bool match(Val *V, const Pattern &P)
CmpClass_match< LHS, RHS, FCmpInst, FCmpInst::Predicate > m_FCmp(FCmpInst::Predicate &Pred, const LHS &L, const RHS &R)
static Value * foldSelectICmpAnd(SelectInst &Sel, ICmpInst *Cmp, InstCombiner::BuilderTy &Builder)
This folds: select (icmp eq (and X, C1)), TC, FC iff C1 is a power 2 and the difference between TC an...
BinaryOp_match< LHS, RHS, Instruction::Xor > m_Xor(const LHS &L, const RHS &R)
TwoOps_match< Val_t, Idx_t, Instruction::ExtractElement > m_ExtractElement(const Val_t &Val, const Idx_t &Idx)
Matches ExtractElementInst.
This class represents the LLVM 'select' instruction.
Predicate getInversePredicate() const
For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.
static Optional< unsigned > getOpcode(ArrayRef< VPValue *> Values)
Returns the opcode of Values or ~0 if they do not all agree.
static Value * foldSelectICmpLshrAshr(const ICmpInst *IC, Value *TrueVal, Value *FalseVal, InstCombiner::BuilderTy &Builder)
We want to turn: (select (icmp sgt x, C), lshr (X, Y), ashr (X, Y)); iff C s>= -1 (select (icmp slt x...
CastClass_match< OpTy, Instruction::Trunc > m_Trunc(const OpTy &Op)
Matches Trunc.
static Constant * AddOne(Constant *C)
Add one to a Constant.
0 1 0 1 True if ordered and less than or equal
static Constant * getSExt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
This file implements a class to represent arbitrary precision integral constant values and operations...
BinaryOp_match< LHS, RHS, Instruction::Add > m_Add(const LHS &L, const RHS &R)
bind_ty< WithOverflowInst > m_WithOverflowInst(WithOverflowInst *&I)
Match a with overflow intrinsic, capturing it if we match.
static Constant * getZExt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Instruction * clone() const
Create a copy of 'this' instruction that is identical in all ways except the following: ...
OverflowingBinaryOp_match< LHS, RHS, Instruction::Add, OverflowingBinaryOperator::NoUnsignedWrap > m_NUWAdd(const LHS &L, const RHS &R)
bool isNullValue() const
Return true if this is the value that would be returned by getNullValue.
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags, which must be an operator which supports th...
Type * getType() const
All values are typed, get the type of this value.
CastClass_match< OpTy, Instruction::ZExt > m_ZExt(const OpTy &Op)
Matches ZExt.
This instruction compares its operands according to the predicate given to the constructor.
void andIRFlags(const Value *V)
Logical 'and' of any supported wrapping, exact, and fast-math flags of V and this instruction...
MaxMin_match< FCmpInst, LHS, RHS, ofmin_pred_ty > m_OrdFMin(const LHS &L, const RHS &R)
Match an 'ordered' floating point minimum function.
MaxMin_match< ICmpInst, LHS, RHS, smin_pred_ty > m_SMin(const LHS &L, const RHS &R)
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
Value * CreateVectorSplat(unsigned NumElts, Value *V, const Twine &Name="")
Return a vector value that contains.
class_match< ConstantInt > m_ConstantInt()
Match an arbitrary ConstantInt and ignore it.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
cstfp_pred_ty< is_pos_zero_fp > m_PosZeroFP()
Match a floating-point positive zero.
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
CallInst * CreateUnaryIntrinsic(Intrinsic::ID ID, Value *V, Instruction *FMFSource=nullptr, const Twine &Name="")
Create a call to intrinsic ID with 1 operand which is mangled on its type.
static Instruction * foldSelectICmpAndAnd(Type *SelType, const ICmpInst *Cmp, Value *TVal, Value *FVal, InstCombiner::BuilderTy &Builder)
We want to turn: (select (icmp eq (and X, Y), 0), (and (lshr X, Z), 1), 1) into: zext (icmp ne i32 (a...
cst_pred_ty< is_power2 > m_Power2()
Match an integer or vector power-of-2.
void takeName(Value *V)
Transfer the name from V to this value.
Function * getDeclaration(Module *M, ID id, ArrayRef< Type *> Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
static BinaryOperator * CreateAdd(Value *S1, Value *S2, const Twine &Name, Instruction *InsertBefore, Value *FlagsOp)
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block...
Value * getOperand(unsigned i) const
bool CannotBeNegativeZero(const Value *V, const TargetLibraryInfo *TLI, unsigned Depth=0)
Return true if we can prove that the specified FP value is never equal to -0.0.
void replaceUsesOfWith(Value *From, Value *To)
Replace uses of one Value with another.
Value * CreateOr(Value *LHS, Value *RHS, const Twine &Name="")
Constant * getAggregateElement(unsigned Elt) const
For aggregates (struct/array/vector) return the constant that corresponds to the specified element if...
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
MaxMin_match< ICmpInst, LHS, RHS, umin_pred_ty, true > m_c_UMin(const LHS &L, const RHS &R)
Matches a UMin with LHS and RHS in either order.
Value * CreateFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
OneUse_match< T > m_OneUse(const T &SubPattern)
BinaryOp_match< LHS, RHS, Instruction::LShr > m_LShr(const LHS &L, const RHS &R)
bool hasNUsesOrMore(unsigned N) const
Return true if this value has N users or more.
Value * SimplifySelectInst(Value *Cond, Value *TrueVal, Value *FalseVal, const SimplifyQuery &Q)
Given operands for a SelectInst, fold the result or return null.
bool isAllOnesValue() const
Determine if all bits are set.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
MaxMin_match< ICmpInst, LHS, RHS, umax_pred_ty > m_UMax(const LHS &L, const RHS &R)
bool hasNUses(unsigned N) const
Return true if this Value has exactly N users.
apint_match m_APInt(const APInt *&Res)
Match a ConstantInt or splatted ConstantVector, binding the specified pointer to the contained APInt...
Value * CreateAShr(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
BinaryOp_match< LHS, RHS, Instruction::Add, true > m_c_Add(const LHS &L, const RHS &R)
Matches a Add with LHS and RHS in either order.
bool isKnownNegation(const Value *X, const Value *Y, bool NeedNSW=false)
Return true if the two given values are negation.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
The instances of the Type class are immutable: once they are created, they are never changed...
BinaryOp_match< LHS, RHS, Instruction::Or > m_Or(const LHS &L, const RHS &R)
bool ult(const APInt &RHS) const
Unsigned less than comparison.
CastClass_match< OpTy, Instruction::BitCast > m_BitCast(const OpTy &Op)
Matches BitCast.
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Value * CreateSelect(Value *C, Value *True, Value *False, const Twine &Name="", Instruction *MDFrom=nullptr)
BinaryOp_match< LHS, RHS, Instruction::And, true > m_c_And(const LHS &L, const RHS &R)
Matches an And with LHS and RHS in either order.
static BinaryOperator * CreateNUW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name="")
bool isOneValue() const
Determine if this is a value of 1.
APInt ssub_ov(const APInt &RHS, bool &Overflow) const
specific_intval m_SpecificInt(APInt V)
Match a specific integer value or vector with all elements equal to the value.
cst_pred_ty< is_all_ones > m_AllOnes()
Match an integer or vector with all bits set.
static APInt getOneBitSet(unsigned numBits, unsigned BitNo)
Return an APInt with exactly one bit set in the result.
specificval_ty m_Specific(const Value *V)
Match if we have a specific specified value.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
Value * CreateNeg(Value *V, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
This instruction compares its operands according to the predicate given to the constructor.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
static Constant * getBinOpIdentity(unsigned Opcode, Type *Ty, bool AllowRHSConstant=false)
Return the identity constant for a binary opcode.
Value * CreateICmpSGE(Value *LHS, Value *RHS, const Twine &Name="")
MaxMin_match< ICmpInst, LHS, RHS, smax_pred_ty, true > m_c_SMax(const LHS &L, const RHS &R)
Matches an SMax with LHS and RHS in either order.
CmpInst::Predicate getMinMaxPred(SelectPatternFlavor SPF, bool Ordered=false)
Return the canonical comparison predicate for the specified minimum/maximum flavor.
static Constant * getICmp(unsigned short pred, Constant *LHS, Constant *RHS, bool OnlyIfReduced=false)
get* - Return some common constants without having to specify the full Instruction::OPCODE identifier...
class_match< BinaryOperator > m_BinOp()
Match an arbitrary binary operation and ignore it.
Class to represent integer types.
const Value * getCondition() const
C setMetadata(LLVMContext::MD_range, MDNode::get(Context, LowAndHigh))
1 1 0 1 True if unordered, less than, or equal
void swapProfMetadata()
If the instruction has "branch_weights" MD_prof metadata and the MDNode has three operands (including...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LLVM_READONLY APFloat maxnum(const APFloat &A, const APFloat &B)
Implements IEEE maxNum semantics.
deferredval_ty< Value > m_Deferred(Value *const &V)
A commutative-friendly version of m_Specific().
Type * getWithNewBitWidth(unsigned NewBitWidth) const
Given an integer or vector type, change the lane bitwidth to NewBitwidth, whilst keeping the old numb...
CastClass_match< OpTy, Instruction::SExt > m_SExt(const OpTy &Op)
Matches SExt.
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
MaxMin_match< ICmpInst, LHS, RHS, umax_pred_ty, true > m_c_UMax(const LHS &L, const RHS &R)
Matches a UMax with LHS and RHS in either order.
static Value * createMinMax(InstCombiner::BuilderTy &Builder, SelectPatternFlavor SPF, Value *A, Value *B)
0 0 1 0 True if ordered and greater than
static Value * foldSelectICmpAndOr(const ICmpInst *IC, Value *TrueVal, Value *FalseVal, InstCombiner::BuilderTy &Builder)
We want to turn: (select (icmp eq (and X, C1), 0), Y, (or Y, C2)) into: (or (shl (and X...
unsigned getNumOperands() const
SelectPatternFlavor Flavor
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type...
1 1 0 0 True if unordered or less than
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
SelectPatternFlavor
Specific patterns of select instructions we can match.
Instruction * user_back()
Specialize the methods defined in Value, as we know that an instruction can only be used by other ins...
Provides information about what library functions are available for the current target.
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static Constant * getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
static ConstantInt * getTrue(LLVMContext &Context)
bool isCommutative() const
Return true if the instruction is commutative:
Instruction * visitSelectInst(SelectInst &SI)
void setPredicate(Predicate P)
Set the predicate for this instruction to the specified value.
OverflowingBinaryOp_match< LHS, RHS, Instruction::Add, OverflowingBinaryOperator::NoSignedWrap > m_NSWAdd(const LHS &L, const RHS &R)
void setOperand(unsigned i, Value *Val)
unsigned logBase2() const
BinaryOp_match< cst_pred_ty< is_zero_int >, ValTy, Instruction::Sub > m_Neg(const ValTy &V)
Matches a 'Neg' as 'sub 0, V'.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
unsigned getVectorNumElements() const
bool isIntPredicate() const
Class to represent vector types.
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
Class for arbitrary precision integers.
bool ule(const APInt &RHS) const
Unsigned less or equal comparison.
static Value * canonicalizeSaturatedAdd(ICmpInst *Cmp, Value *TVal, Value *FVal, InstCombiner::BuilderTy &Builder)
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
static BinaryOperator * Create(BinaryOps Op, Value *S1, Value *S2, const Twine &Name=Twine(), Instruction *InsertBefore=nullptr)
Construct a binary instruction, given the opcode and the two operands.
bool sge(const APInt &RHS) const
Signed greater or equal comparison.
iterator_range< user_iterator > users()
static Constant * getCast(unsigned ops, Constant *C, Type *Ty, bool OnlyIfReduced=false)
Convenience function for getting a Cast operation.
Value * CreateShl(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
const Value * getFalseValue() const
void setCondition(Value *V)
static BinaryOperator * CreateFNegFMF(Value *Op, Instruction *FMFSource, const Twine &Name="")
static APInt getSelectFoldableConstant(BinaryOperator *I)
For the same transformation as the previous function, return the identity constant that goes into the...
static Constant * getNeg(Constant *C, bool HasNUW=false, bool HasNSW=false)
static CastInst * Create(Instruction::CastOps, Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Provides a way to construct any of the CastInst subclasses using an opcode instead of the subclass's ...
bool ugt(const APInt &RHS) const
Unsigned greater than comparison.
Predicate getPredicate() const
Return the predicate for this instruction.
FNeg_match< OpTy > m_FNeg(const OpTy &X)
Match 'fneg X' as 'fsub -0.0, X'.
static Value * canonicalizeSaturatedSubtract(const ICmpInst *ICI, const Value *TrueVal, const Value *FalseVal, InstCombiner::BuilderTy &Builder)
Transform patterns such as (a > b) ? a - b : 0 into usub.sat(a, b).
void setTrueValue(Value *V)
static IntegerType * getInt32Ty(LLVMContext &C)
unsigned getIntegerBitWidth() const
static bool isMinOrMax(SelectPatternFlavor SPF)
When implementing this min/max pattern as fcmp; select, does the fcmp have to be ordered?
unsigned greater or equal
static bool isUnordered(Predicate predicate)
Determine if the predicate is an unordered operation.
MaxMin_match< ICmpInst, LHS, RHS, smin_pred_ty, true > m_c_SMin(const LHS &L, const RHS &R)
Matches an SMin with LHS and RHS in either order.
StringRef getName() const
Return a constant reference to the value's name.
bool isEquality() const
Return true if this predicate is either EQ or NE.
llvm::Optional< std::pair< CmpInst::Predicate, Constant * > > getFlippedStrictnessPredicateAndConstant(CmpInst::Predicate Pred, Constant *C)
MaxMin_match< ICmpInst, LHS, RHS, smax_pred_ty > m_SMax(const LHS &L, const RHS &R)
void swapValues()
Swap the true and false values of the select instruction.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
void setFalseValue(Value *V)
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value *> Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)
1 0 1 0 True if unordered or greater than
CallInst * CreateBinaryIntrinsic(Intrinsic::ID ID, Value *LHS, Value *RHS, Instruction *FMFSource=nullptr, const Twine &Name="")
Create a call to intrinsic ID with 2 operands which is mangled on the first type. ...
Value * CreateAnd(Value *LHS, Value *RHS, const Twine &Name="")
InstTy * Insert(InstTy *I, const Twine &Name="") const
Insert and return the specified instruction.
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
bool isOneValue() const
Returns true if the value is one.
Value * CreateCast(Instruction::CastOps Op, Value *V, Type *DestTy, const Twine &Name="")
Value * SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, const SimplifyQuery &Q)
Given operands for a BinaryOperator, fold the result or return null.
static GetElementPtrInst * CreateInBounds(Value *Ptr, ArrayRef< Value *> IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Create an "inbounds" getelementptr.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
MaxMin_match< FCmpInst, LHS, RHS, ofmax_pred_ty > m_OrdFMax(const LHS &L, const RHS &R)
Match an 'ordered' floating point maximum function.
0 0 0 1 True if ordered and equal
LLVM Value Representation.
This file provides internal interfaces used to implement the InstCombine.
1 0 1 1 True if unordered, greater than, or equal
SelectPatternResult matchSelectPattern(Value *V, Value *&LHS, Value *&RHS, Instruction::CastOps *CastOp=nullptr, unsigned Depth=0)
Pattern match integer [SU]MIN, [SU]MAX and ABS idioms, returning the kind and providing the out param...
cst_pred_ty< is_one > m_One()
Match an integer 1 or a vector with all elements equal to 1.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
void setFastMathFlags(FastMathFlags NewFMF)
Set the fast-math flags to be used with generated fp-math operators.
void moveBefore(Instruction *MovePos)
Unlink this instruction from its current basic block and insert it into the basic block that MovePos ...
Value * CreateLShr(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
match_combine_and< LTy, RTy > m_CombineAnd(const LTy &L, const RTy &R)
Combine two pattern matchers matching L && R.
cst_pred_ty< is_any_apint > m_AnyIntegralConstant()
Match an integer or vector with any integral constant.
bool hasNoNaNs() const
Determine whether the no-NaNs flag is set.
bool hasOneUse() const
Return true if there is exactly one user of this value.
Convenience struct for specifying and reasoning about fast-math flags.
Predicate getSwappedPredicate() const
For example, EQ->EQ, SLE->SGE, ULT->UGT, OEQ->OEQ, ULE->UGE, OLT->OGT, etc.
static APInt getNullValue(unsigned numBits)
Get the '0' value.
cstfp_pred_ty< is_any_zero_fp > m_AnyZeroFP()
Match a floating-point negative zero or positive zero.
0 0 1 1 True if ordered and greater than or equal
static Constant * get(ArrayRef< Constant *> V)
Value * CreateFNeg(Value *V, const Twine &Name="", MDNode *FPMathTag=nullptr)
LLVM_READONLY APFloat minnum(const APFloat &A, const APFloat &B)
Implements IEEE minNum semantics.
bind_ty< Instruction > m_Instruction(Instruction *&I)
Match an instruction, capturing it if we match.
BinaryOp_match< ValTy, cst_pred_ty< is_all_ones >, Instruction::Xor, true > m_Not(const ValTy &V)
Matches a 'Not' as 'xor V, -1' or 'xor -1, V'.
bool isNullValue() const
Determine if all bits are clear.
A wrapper class for inspecting calls to intrinsic functions.
const BasicBlock * getParent() const
CmpClass_match< LHS, RHS, ICmpInst, ICmpInst::Predicate > m_ICmp(ICmpInst::Predicate &Pred, const LHS &L, const RHS &R)