28#ifndef LLVM_IR_PATTERNMATCH_H
29#define LLVM_IR_PATTERNMATCH_H
54template <
typename Val,
typename Pattern>
bool match(Val *V,
const Pattern &
P) {
60template <
typename Val = const Value,
typename Pattern>
74 template <
typename OpTy>
bool match(
OpTy *V)
const {
89 template <
typename OpTy>
bool match(
OpTy *V)
const {
159 return checkAggregate(CA);
162 template <
typename ITy>
bool match(ITy *V)
const {
return check(V); }
189 template <
typename ITy>
bool match(ITy *V)
const {
191 return C &&
C->containsMatchingVectorElement(
199template <
typename SPTy>
218 auto *
Splat =
C->getSplatValue();
241 template <
typename ITy>
bool match(ITy *V)
const {
return !
M.match(V); }
250 static_assert(std::is_same_v<APTy, APInt> || std::is_same_v<APTy, APFloat>);
260 template <
typename ITy>
bool match(ITy *V)
const {
262 Res = &CI->getValue();
265 if (V->getType()->isVectorTy())
269 Res = &CI->getValue();
311 template <
typename ITy>
bool match(ITy *V)
const {
313 const APInt &CIV = CI->getValue();
315 return CIV ==
static_cast<uint64_t>(Val);
334template <
typename Predicate,
typename ConstantVal,
bool AllowPoison>
337 bool matchVector(
const Value *V)
const {
340 return this->isValue(CV->getValue());
348 unsigned NumElts = FVTy->getNumElements();
349 assert(NumElts != 0 &&
"Constant vector with no elements?");
350 bool HasNonPoisonElements =
false;
351 for (
unsigned i = 0; i != NumElts; ++i) {
352 Constant *Elt =
C->getAggregateElement(i);
358 if (!CV || !this->isValue(CV->getValue()))
360 HasNonPoisonElements =
true;
362 return HasNonPoisonElements;
371 return this->isValue(CV->getValue());
373 return matchVector(V);
377 template <
typename ITy>
bool match(ITy *V)
const {
388template <
typename Predicate,
bool AllowPoison = true>
392template <
typename Predicate>
398template <
typename Predicate>
struct api_pred_ty :
public Predicate {
403 template <
typename ITy>
bool match(ITy *V)
const {
405 if (this->isValue(CI->getValue())) {
406 Res = &CI->getValue();
409 if (V->getType()->isVectorTy())
412 C->getSplatValue(
true)))
413 if (this->isValue(CI->getValue())) {
414 Res = &CI->getValue();
425template <
typename Predicate>
struct apf_pred_ty :
public Predicate {
430 template <
typename ITy>
bool match(ITy *V)
const {
432 if (this->isValue(CI->getValue())) {
433 Res = &CI->getValue();
436 if (V->getType()->isVectorTy())
439 C->getSplatValue(
true)))
440 if (this->isValue(CI->getValue())) {
441 Res = &CI->getValue();
600 template <
typename ITy>
bool match(ITy *V)
const {
730 return C.isInfinity() && IsNegative ==
C.isNegative();
815 return !
C.isDenormal() &&
C.isNonZero();
837template <
typename Pattern>
849template <
typename Pattern>
853template <
typename Pattern>
914 if (CV->getType()->isVectorTy()) {
915 if (
auto *
Splat = CV->getSplatValue(
true)) {
938 template <
typename ITy>
bool match(ITy *V)
const {
958 template <
typename ITy>
bool match(ITy *V)
const {
return V ==
Val; }
982 template <
typename ITy>
bool match(ITy *V)
const {
984 return CFP->isExactlyValue(
Val);
985 if (V->getType()->isVectorTy())
988 return CFP->isExactlyValue(
Val);
1005 template <
typename ITy>
bool match(ITy *V)
const {
1006 const APInt *ConstInt;
1009 std::optional<uint64_t> ZExtVal = ConstInt->
tryZExtValue();
1024 template <
typename ITy>
bool match(ITy *V)
const {
1026 if (!CI && V->getType()->isVectorTy())
1039 template <
typename ITy>
bool match(ITy *V)
const {
1041 if (!CI && V->getType()->isVectorTy())
1045 return CI && CI->getValue() ==
Val;
1077 template <
typename ITy>
bool match(ITy *V)
const {
1079 return BB && BB ==
Val;
1100template <
typename LHS_t,
typename RHS_t,
bool Commutable = false>
1111 return (
L.match(
I->getOperand(0)) &&
R.match(
I->getOperand(1))) ||
1112 (Commutable &&
L.match(
I->getOperand(1)) &&
1113 R.match(
I->getOperand(0)));
1118template <
typename LHS,
typename RHS>
1134 return X.match(
I->getOperand(0));
1147template <
typename LHS_t,
typename RHS_t,
unsigned Opcode,
1148 bool Commutable =
false>
1158 if (V->getValueID() == Value::InstructionVal +
Opc) {
1160 return (
L.match(
I->getOperand(0)) &&
R.match(
I->getOperand(1))) ||
1161 (Commutable &&
L.match(
I->getOperand(1)) &&
1162 R.match(
I->getOperand(0)));
1168 return match(Opcode, V);
1172template <
typename LHS,
typename RHS>
1178template <
typename LHS,
typename RHS>
1184template <
typename LHS,
typename RHS>
1190template <
typename LHS,
typename RHS>
1205 if (FPMO->getOpcode() == Instruction::FNeg)
1206 return X.match(FPMO->getOperand(0));
1208 if (FPMO->getOpcode() == Instruction::FSub) {
1209 if (FPMO->hasNoSignedZeros()) {
1219 return X.match(FPMO->getOperand(1));
1232template <
typename RHS>
1238template <
typename LHS,
typename RHS>
1244template <
typename LHS,
typename RHS>
1250template <
typename LHS,
typename RHS>
1256template <
typename LHS,
typename RHS>
1262template <
typename LHS,
typename RHS>
1268template <
typename LHS,
typename RHS>
1274template <
typename LHS,
typename RHS>
1280template <
typename LHS,
typename RHS>
1286template <
typename LHS,
typename RHS>
1292template <
typename LHS,
typename RHS>
1298template <
typename LHS,
typename RHS>
1304template <
typename LHS,
typename RHS>
1310template <
typename LHS,
typename RHS>
1316template <
typename LHS,
typename RHS>
1330 if (
Op->getOpcode() == Opcode)
1332 L.match(
Op->getOperand(0));
1341template <
typename LHS>
1348template <
typename LHS>
1355template <
typename LHS>
1361template <
typename LHS_t,
typename RHS_t,
unsigned Opcode,
1362 unsigned WrapFlags = 0,
bool Commutable =
false>
1372 if (
Op->getOpcode() != Opcode)
1375 !
Op->hasNoUnsignedWrap())
1378 !
Op->hasNoSignedWrap())
1380 return (
L.match(
Op->getOperand(0)) &&
R.match(
Op->getOperand(1))) ||
1381 (Commutable &&
L.match(
Op->getOperand(1)) &&
1382 R.match(
Op->getOperand(0)));
1388template <
typename LHS,
typename RHS>
1396template <
typename LHS,
typename RHS>
1404template <
typename LHS,
typename RHS>
1412template <
typename LHS,
typename RHS>
1420template <
typename LHS,
typename RHS>
1429template <
typename LHS,
typename RHS>
1438template <
typename LHS,
typename RHS>
1447template <
typename LHS,
typename RHS>
1455template <
typename LHS,
typename RHS>
1463template <
typename LHS,
typename RHS>
1472template <
typename LHS_t,
typename RHS_t,
bool Commutable = false>
1486template <
typename LHS,
typename RHS>
1492template <
typename LHS,
typename RHS,
bool Commutable = false>
1501 assert(PDI->getOpcode() == Instruction::Or &&
"Only or can be disjoint");
1502 if (!PDI->isDisjoint())
1504 return (
L.match(PDI->getOperand(0)) &&
R.match(PDI->getOperand(1))) ||
1505 (Commutable &&
L.match(PDI->getOperand(1)) &&
1506 R.match(PDI->getOperand(0)));
1512template <
typename LHS,
typename RHS>
1517template <
typename LHS,
typename RHS>
1524template <
typename LHS,
typename RHS>
1532template <
typename LHS,
typename RHS>
1542template <
typename LHS,
typename RHS>
1551template <
typename LHS,
typename RHS>
1560 if (
Op->getOpcode() == Instruction::Sub &&
Op->hasNoUnsignedWrap() &&
1563 else if (
Op->getOpcode() != Instruction::Xor)
1565 return (
L.match(
Op->getOperand(0)) &&
R.match(
Op->getOperand(1))) ||
1566 (
L.match(
Op->getOperand(1)) &&
R.match(
Op->getOperand(0)));
1574template <
typename LHS,
typename RHS>
1582template <
typename LHS_t,
typename RHS_t,
typename Predicate,
1583 bool Commutable =
false>
1592 return this->isOpType(
I->getOpcode()) &&
1593 ((
L.match(
I->getOperand(0)) &&
R.match(
I->getOperand(1))) ||
1594 (Commutable &&
L.match(
I->getOperand(1)) &&
1595 R.match(
I->getOperand(0))));
1606 return Opcode == Instruction::LShr || Opcode == Instruction::AShr;
1612 return Opcode == Instruction::LShr || Opcode == Instruction::Shl;
1624 return Opcode == Instruction::SDiv || Opcode == Instruction::UDiv;
1630 return Opcode == Instruction::SRem || Opcode == Instruction::URem;
1635template <
typename LHS,
typename RHS>
1642template <
typename LHS,
typename RHS>
1649template <
typename LHS,
typename RHS>
1656template <
typename LHS,
typename RHS>
1663template <
typename LHS,
typename RHS>
1670template <
typename LHS,
typename RHS>
1677template <
typename LHS,
typename RHS>
1693 return PEO->isExact() &&
SubPattern.match(V);
1706template <
typename LHS_t,
typename RHS_t,
typename Class,
1707 bool Commutable =
false>
1722 if (
L.match(
I->getOperand(0)) &&
R.match(
I->getOperand(1))) {
1727 if (Commutable &&
L.match(
I->getOperand(1)) &&
1728 R.match(
I->getOperand(0))) {
1738template <
typename LHS,
typename RHS>
1744template <
typename LHS,
typename RHS>
1746 const LHS &L,
const RHS &R) {
1750template <
typename LHS,
typename RHS>
1752 const LHS &L,
const RHS &R) {
1756template <
typename LHS,
typename RHS>
1761template <
typename LHS,
typename RHS>
1766template <
typename LHS,
typename RHS>
1773template <
typename LHS_t,
typename RHS_t,
typename Class,
1774 bool Commutable =
false>
1786 L.match(
I->getOperand(0)) &&
R.match(
I->getOperand(1)))
1788 if constexpr (Commutable) {
1791 L.match(
I->getOperand(1)) &&
R.match(
I->getOperand(0)))
1800template <
typename LHS,
typename RHS>
1806template <
typename LHS,
typename RHS>
1812template <
typename LHS,
typename RHS>
1818template <
typename LHS,
typename RHS>
1835 if (V->getValueID() == Value::InstructionVal + Opcode) {
1837 return Op1.match(
I->getOperand(0));
1851 if (V->getValueID() == Value::InstructionVal + Opcode) {
1853 return Op1.match(
I->getOperand(0)) &&
Op2.match(
I->getOperand(1));
1860template <
typename T0,
typename T1,
typename T2,
unsigned Opcode,
1861 bool CommutableOp2Op3 =
false>
1871 if (V->getValueID() == Value::InstructionVal + Opcode) {
1873 if (!
Op1.match(
I->getOperand(0)))
1875 if (
Op2.match(
I->getOperand(1)) &&
Op3.match(
I->getOperand(2)))
1877 return CommutableOp2Op3 &&
Op2.match(
I->getOperand(2)) &&
1878 Op3.match(
I->getOperand(1));
1894 template <
int Idx,
int Last>
1895 std::enable_if_t<Idx != Last, bool>
1900 template <
int Idx,
int Last>
1901 std::enable_if_t<Idx == Last, bool>
1903 return std::get<Idx>(
Operands).match(
I->getOperand(Idx));
1907 if (V->getValueID() == Value::InstructionVal + Opcode) {
1909 return I->getNumOperands() ==
sizeof...(OperandTypes) &&
1917template <
typename Cond,
typename LHS,
typename RHS>
1925template <
int64_t L,
int64_t R,
typename Cond>
1927 Instruction::Select>
1933template <
typename LHS,
typename RHS>
1941template <
typename OpTy>
1947template <
typename Val_t,
typename Elt_t,
typename Idx_t>
1955template <
typename Val_t,
typename Idx_t>
1972 return Op1.match(
I->getOperand(0)) &&
Op2.match(
I->getOperand(1)) &&
1973 Mask.match(
I->getShuffleMask());
1990 return all_of(Mask, [](
int Elem) {
return Elem == 0 || Elem == -1; });
2008 const auto *
First =
find_if(Mask, [](
int Elem) {
return Elem != -1; });
2009 if (
First == Mask.end())
2013 [
First](
int Elem) {
return Elem == *
First || Elem == -1; });
2026 return GEP &&
GEP->getSourceElementType()->isIntegerTy(8) &&
2033template <
typename V1_t,
typename V2_t>
2039template <
typename V1_t,
typename V2_t,
typename Mask_t>
2046template <
typename OpTy>
2057 template <
typename ITy>
bool match(ITy *V)
const {
2062template <
typename OpTy>
2068template <
typename ValueOpTy,
typename Po
interOpTy>
2070m_Store(
const ValueOpTy &ValueOp,
const PointerOpTy &PointerOp) {
2076template <
typename... OperandTypes>
2078 return AnyOps_match<Instruction::GetElementPtr, OperandTypes...>(
Ops...);
2082template <
typename Po
interOpTy,
typename OffsetOpTy>
2099 return O->getOpcode() == Opcode &&
Op.match(O->getOperand(0));
2111 return Op.match(
I->getOperand(0));
2125 return O->getOpcode() == Instruction::PtrToInt &&
2126 DL.getTypeSizeInBits(O->getType()) ==
2127 DL.getTypeSizeInBits(O->getOperand(0)->getType()) &&
2128 Op.match(O->getOperand(0));
2140 return I->hasNonNeg() &&
Op.match(
I->getOperand(0));
2152 return (
I->getNoWrapKind() & WrapFlags) == WrapFlags &&
2153 Op.match(
I->getOperand(0));
2159template <
typename OpTy>
2174 Type *SrcType =
I->getSrcTy();
2175 Type *DstType =
I->getType();
2178 if (SrcType->isVectorTy() != DstType->isVectorTy())
2181 SrcVecTy && SrcVecTy->getElementCount() !=
2184 return Op.match(
I->getOperand(0));
2188template <
typename OpTy>
2194template <
typename OpTy>
2200template <
typename OpTy>
2207template <
typename OpTy>
2219template <
typename OpTy>
2226template <
typename OpTy>
2233template <
typename OpTy>
2239template <
typename OpTy>
2246template <
typename OpTy>
2252template <
typename OpTy>
2259template <
typename OpTy>
2265template <
typename OpTy>
2270template <
typename OpTy>
2275template <
typename OpTy>
2281template <
typename OpTy>
2288template <
typename OpTy>
2294template <
typename OpTy>
2301template <
typename OpTy>
2326 if (V->getType()->isIntOrIntVectorTy(1) &&
2336template <
typename LHS,
typename RHS>
2355 Type *Ty = V->getType();
2356 Value *CondV =
nullptr;
2361 TrueC.match(ConstantInt::get(Ty, 1)) &&
2362 FalseC.match(ConstantInt::get(Ty, 0)))
2369 FalseC.match(ConstantInt::get(Ty, 0)))
2384template <
typename CondTy,
typename LTy,
typename RTy>
2390template <
typename OpTy>
2395template <
typename OpTy>
2400template <
typename OpTy>
2407template <
typename OpTy>
2412template <
typename OpTy>
2417template <
typename OpTy>
2424template <
typename OpTy>
2429template <
typename OpTy>
2445 Succ = BI->getSuccessor();
2454template <
typename Cond_t,
typename TrueBlock_t,
typename FalseBlock_t>
2460 brc_match(
const Cond_t &
C,
const TrueBlock_t &t,
const FalseBlock_t &f)
2465 if (
Cond.match(BI->getCondition()))
2466 return T.match(BI->getSuccessor(0)) &&
F.match(BI->getSuccessor(1));
2471template <
typename Cond_t>
2478template <
typename Cond_t,
typename TrueBlock_t,
typename FalseBlock_t>
2480m_Br(
const Cond_t &
C,
const TrueBlock_t &
T,
const FalseBlock_t &
F) {
2488template <
typename LHS_t,
typename RHS_t,
typename Pred_t>
2508 auto *TrueVal =
SI->getTrueValue();
2509 auto *FalseVal =
SI->getFalseValue();
2510 auto *LHS = Cmp->getOperand(0);
2511 auto *RHS = Cmp->getOperand(1);
2512 if ((TrueVal != LHS || FalseVal != RHS) &&
2513 (TrueVal != RHS || FalseVal != LHS))
2516 LHS == TrueVal ? Cmp->getPredicate() : Cmp->getInversePredicate();
2518 if (!Pred_t::match(Pred))
2521 return L.match(LHS) &&
R.match(RHS);
2562template <
typename LHS,
typename RHS>
2577template <
typename LHS,
typename RHS>
2592template <
typename LHS,
typename RHS>
2607template <
typename LHS,
typename RHS>
2618template <
typename LHS,
typename RHS>
2631template <
typename LHS,
typename RHS>
2642template <
typename ValTy>
2648template <
typename ValTy>
2660template <
typename LHS_t,
typename RHS_t,
typename Sum_t>
2670 Value *ICmpLHS, *ICmpRHS;
2675 Value *AddLHS, *AddRHS;
2680 if (AddExpr.match(ICmpLHS) && (ICmpRHS == AddLHS || ICmpRHS == AddRHS))
2681 return L.match(AddLHS) &&
R.match(AddRHS) &&
S.match(ICmpLHS);
2685 if (AddExpr.match(ICmpRHS) && (ICmpLHS == AddLHS || ICmpLHS == AddRHS))
2686 return L.match(AddLHS) &&
R.match(AddRHS) &&
S.match(ICmpRHS);
2692 if (XorExpr.match(ICmpLHS))
2693 return L.match(Op1) &&
R.match(ICmpRHS) &&
S.match(ICmpLHS);
2697 if (XorExpr.match(ICmpRHS))
2698 return L.match(Op1) &&
R.match(ICmpLHS) &&
S.match(ICmpRHS);
2707 return L.match(AddLHS) &&
R.match(AddRHS) &&
S.match(ICmpLHS);
2712 return L.match(AddLHS) &&
R.match(AddRHS) &&
S.match(ICmpRHS);
2723template <
typename LHS_t,
typename RHS_t,
typename Sum_t>
2738 return Val.match(CI->getArgOperand(
OpI));
2744template <
unsigned OpI,
typename Opnd_t>
2758 return F->getIntrinsicID() ==
ID;
2769 return ((
ID == IntrIDs) || ...);
2776 template <
Intrinsic::ID IntrID,
typename... Ts,
size_t... Is>
2777 static auto impl(std::index_sequence<Is...>,
const Ts &...
Ops) {
2787 std::make_index_sequence<
sizeof...(Ts)>{},
Ops...);
2800template <
typename Opnd0,
typename Opnd1,
typename Opnd2>
2801inline auto m_MaskedLoad(
const Opnd0 &Op0,
const Opnd1 &Op1,
const Opnd2 &Op2) {
2806template <
typename Opnd0,
typename Opnd1,
typename Opnd2>
2813template <
typename Opnd0,
typename Opnd1,
typename Opnd2>
2824template <
typename Opnd0>
inline auto m_BSwap(
const Opnd0 &Op0) {
2827template <
typename Opnd0>
inline auto m_Ctpop(
const Opnd0 &Op0) {
2831template <
typename Opnd0>
inline auto m_FAbs(
const Opnd0 &Op0) {
2839template <
typename Opnd0,
typename Opnd1>
2840inline auto m_Ctlz(
const Opnd0 &Op0,
const Opnd1 &Op1) {
2844template <
typename Opnd0,
typename Opnd1>
2845inline auto m_Cttz(
const Opnd0 &Op0,
const Opnd1 &Op1) {
2849template <
typename Opnd0,
typename Opnd1>
2850inline auto m_SMax(
const Opnd0 &Op0,
const Opnd1 &Op1) {
2854template <
typename Opnd0,
typename Opnd1>
2855inline auto m_SMin(
const Opnd0 &Op0,
const Opnd1 &Op1) {
2859template <
typename Opnd0,
typename Opnd1>
2860inline auto m_UMax(
const Opnd0 &Op0,
const Opnd1 &Op1) {
2864template <
typename Opnd0,
typename Opnd1>
2865inline auto m_UMin(
const Opnd0 &Op0,
const Opnd1 &Op1) {
2869template <
typename Opnd0,
typename Opnd1>
2875template <
typename Opnd0,
typename Opnd1>
2880template <
typename Opnd0,
typename Opnd1>
2885template <
typename Opnd0,
typename Opnd1>
2890template <
typename Opnd0,
typename Opnd1>
2895template <
typename Opnd0,
typename Opnd1>
2900template <
typename Opnd0,
typename Opnd1>
2905template <
typename Opnd0,
typename Opnd1>
2910template <
typename Opnd0,
typename Opnd1>
2915template <
typename Opnd0,
typename Opnd1,
typename Opnd2>
2916inline auto m_FShl(
const Opnd0 &Op0,
const Opnd1 &Op1,
const Opnd2 &Op2) {
2920template <
typename Opnd0,
typename Opnd1,
typename Opnd2>
2921inline auto m_FShr(
const Opnd0 &Op0,
const Opnd1 &Op1,
const Opnd2 &Op2) {
2925template <
typename Opnd0>
inline auto m_Sqrt(
const Opnd0 &Op0) {
2929template <
typename Opnd0,
typename Opnd1>
2938template <
typename Opnd0,
typename Opnd1,
typename Opnd2>
2949template <
typename LHS,
typename RHS>
2956template <
typename LHS,
typename RHS>
2962template <
typename LHS,
typename RHS>
2969template <
typename LHS,
typename RHS>
2976template <
typename LHS,
typename RHS>
2983template <
typename LHS,
typename RHS>
2990template <
typename LHS,
typename RHS>
2997template <
typename LHS,
typename RHS>
3004template <
typename LHS,
typename RHS>
3011template <
typename ValTy>
3018template <
typename ValTy>
3026template <Intrinsic::ID IntrID,
typename LHS,
typename RHS>
3035 if (!
II ||
II->getIntrinsicID() != IntrID)
3037 return (
L.match(
II->getArgOperand(0)) &&
R.match(
II->getArgOperand(1))) ||
3038 (
L.match(
II->getArgOperand(1)) &&
R.match(
II->getArgOperand(0)));
3042template <Intrinsic::ID IntrID,
typename T0,
typename T1>
3049template <
typename LHS,
typename RHS>
3054template <
typename LHS,
typename RHS>
3059template <
typename LHS,
typename RHS>
3064template <
typename LHS,
typename RHS>
3069template <
typename LHS,
typename RHS>
3076template <
typename LHS,
typename RHS>
3083template <
typename LHS,
typename RHS>
3094 unsigned TypeSize = V->getType()->getScalarSizeInBits();
3098 unsigned ShiftWidth =
TypeSize - 1;
3113 auto Signum =
m_c_Or(LHS, RHS);
3115 return Signum.match(V) &&
Val.match(
Op);
3137 !(
I->getNumIndices() == 1 &&
I->getIndices()[0] == (
unsigned)Ind))
3139 return Val.match(
I->getAggregateOperand());
3147template <
int Ind,
typename Val_t>
3154template <
typename Val_t>
3168 return Op0.match(
I->getOperand(0)) &&
Op1.match(
I->getOperand(1)) &&
3169 I->getNumIndices() == 1 && Ind ==
I->getIndices()[0];
3176template <
int Ind,
typename Val_t,
typename Elt_t>
3185template <
typename Opnd0,
typename Opnd1>
3194template <
typename LHS,
typename RHS,
unsigned Opcode,
bool Commutable = false>
3201 template <
typename T>
bool match(
T *V)
const {
3203 if (!
I || !
I->getType()->isIntOrIntVectorTy(1))
3206 if (
I->getOpcode() == Opcode) {
3207 auto *Op0 =
I->getOperand(0);
3208 auto *Op1 =
I->getOperand(1);
3209 return (
L.match(Op0) &&
R.match(Op1)) ||
3210 (Commutable &&
L.match(Op1) &&
R.match(Op0));
3215 auto *TVal =
Select->getTrueValue();
3216 auto *FVal =
Select->getFalseValue();
3223 if (Opcode == Instruction::And) {
3225 if (
C &&
C->isNullValue())
3226 return (
L.match(
Cond) &&
R.match(TVal)) ||
3227 (Commutable &&
L.match(TVal) &&
R.match(
Cond));
3229 assert(Opcode == Instruction::Or);
3231 if (
C &&
C->isOneValue())
3232 return (
L.match(
Cond) &&
R.match(FVal)) ||
3233 (Commutable &&
L.match(FVal) &&
R.match(
Cond));
3243template <
typename LHS,
typename RHS>
3253template <
typename LHS,
typename RHS>
3261template <
typename LHS,
typename RHS>
3271template <
typename LHS,
typename RHS>
3280template <
typename LHS,
typename RHS,
bool Commutable = false>
3291template <
typename LHS,
typename RHS>
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMDGPU Register Bank Select
This file declares a class to represent arbitrary precision floating point values and provide a varie...
This file implements a class to represent arbitrary precision integral constant values and operations...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static constexpr unsigned long long mask(BlockVerifier::State S)
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
std::pair< Instruction::BinaryOps, Value * > OffsetOp
Find all possible pairs (BinOp, RHS) that BinOp V, RHS can be simplified.
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
MachineInstr unsigned OpIdx
uint64_t IntrinsicInst * II
const SmallVectorImpl< MachineOperand > & Cond
Class for arbitrary precision integers.
std::optional< uint64_t > tryZExtValue() const
Get zero extended value if possible.
static bool isSameValue(const APInt &I1, const APInt &I2, bool SignedCompare=false)
Determine if two APInts have the same value, after zero-extending or sign-extending (if SignedCompare...
Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
@ FCMP_OLT
0 1 0 0 True if ordered and less than
@ FCMP_ULE
1 1 0 1 True if unordered, less than, or equal
@ FCMP_OGT
0 0 1 0 True if ordered and greater than
@ FCMP_OGE
0 0 1 1 True if ordered and greater than or equal
@ ICMP_UGT
unsigned greater than
@ FCMP_ULT
1 1 0 0 True if unordered or less than
@ ICMP_ULT
unsigned less than
@ FCMP_UGT
1 0 1 0 True if unordered or greater than
@ FCMP_OLE
0 1 0 1 True if ordered and less than or equal
@ FCMP_UGE
1 0 1 1 True if unordered, greater than, or equal
An abstraction over a floating-point predicate, and a pack of an integer predicate with samesign info...
static LLVM_ABI std::optional< CmpPredicate > getMatching(CmpPredicate A, CmpPredicate B)
Compares two CmpPredicates taking samesign into account and returns the canonicalized CmpPredicate if...
static LLVM_ABI CmpPredicate get(const CmpInst *Cmp)
Do a ICmpInst::getCmpPredicate() or CmpInst::getPredicate(), as appropriate.
static LLVM_ABI CmpPredicate getSwapped(CmpPredicate P)
Get the swapped predicate of a CmpPredicate.
Base class for aggregate constants (with operands).
A constant value that is initialized with an expression using other constant values.
ConstantFP - Floating Point Values [float, double].
This is the shared class of boolean and integer constants.
This is an important base class in LLVM.
static LLVM_ABI Constant * getAllOnesValue(Type *Ty)
static LLVM_ABI Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
A parsed version of the target data layout string in and methods for querying it.
Convenience struct for specifying and reasoning about fast-math flags.
static LLVM_ABI bool compare(const APInt &LHS, const APInt &RHS, ICmpInst::Predicate Pred)
Return result of LHS Pred RHS comparison.
bool isBitwiseLogicOp() const
Return true if this is and/or/xor.
A wrapper class for inspecting calls to intrinsic functions.
The instances of the Type class are immutable: once they are created, they are never changed.
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
'undef' values are things that do not have specified contents.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
Base class of all SIMD vector types.
Represents an op.with.overflow intrinsic.
An efficient, type-erasing, non-owning reference to a callable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
match_isa< To... > m_Isa()
match_combine_or< Ty... > m_CombineOr(const Ty &...Ps)
Combine pattern matchers matching any of Ps patterns.
match_combine_and< Ty... > m_CombineAnd(const Ty &...Ps)
Combine pattern matchers matching all of Ps patterns.
TwoOps_match< ValueOpTy, PointerOpTy, Instruction::Store > m_Store(const ValueOpTy &ValueOp, const PointerOpTy &PointerOp)
Matches StoreInst.
cst_pred_ty< is_all_ones > m_AllOnes()
Match an integer or vector with all bits set.
cst_pred_ty< is_lowbit_mask > m_LowBitMask()
Match an integer or vector with only the low bit(s) set.
match_bind< PHINode > m_Phi(PHINode *&PN)
Match a PHI node, capturing it if we match.
BinaryOp_match< LHS, RHS, Instruction::And > m_And(const LHS &L, const RHS &R)
auto m_BSwap(const Opnd0 &Op0)
PtrAdd_match< PointerOpTy, OffsetOpTy > m_PtrAdd(const PointerOpTy &PointerOp, const OffsetOpTy &OffsetOp)
Matches GEP with i8 source element type.
cst_pred_ty< is_negative > m_Negative()
Match an integer or vector of negative values.
ShiftLike_match< LHS, Instruction::LShr > m_LShrOrSelf(const LHS &L, uint64_t &R)
Matches lshr L, ConstShAmt or L itself (R will be set to zero in this case).
AllowFmf_match< T, FastMathFlags::NoSignedZeros > m_NoSignedZeros(const T &SubPattern)
auto m_Cmp()
Matches any compare instruction and ignore it.
BinaryOp_match< cst_pred_ty< is_all_ones, false >, ValTy, Instruction::Xor, true > m_NotForbidPoison(const ValTy &V)
PtrToIntSameSize_match< OpTy > m_PtrToIntSameSize(const DataLayout &DL, const OpTy &Op)
BinaryOp_match< LHS, RHS, Instruction::Add > m_Add(const LHS &L, const RHS &R)
auto m_BitReverse(const Opnd0 &Op0)
CmpClass_match< LHS, RHS, FCmpInst > m_FCmp(CmpPredicate &Pred, const LHS &L, const RHS &R)
auto m_c_UMax(const LHS &L, const RHS &R)
Matches a UMax with LHS and RHS in either order.
AllowFmf_match< T, FastMathFlags::NoInfs > m_NoInfs(const T &SubPattern)
BinaryOp_match< LHS, RHS, Instruction::FMul, true > m_c_FMul(const LHS &L, const RHS &R)
Matches FMul with LHS and RHS in either order.
cst_pred_ty< is_sign_mask > m_SignMask()
Match an integer or vector with only the sign bit(s) set.
OverflowingBinaryOp_match< LHS, RHS, Instruction::Add, OverflowingBinaryOperator::NoUnsignedWrap > m_NUWAdd(const LHS &L, const RHS &R)
BinaryOp_match< LHS, RHS, Instruction::AShr > m_AShr(const LHS &L, const RHS &R)
auto m_PtrToIntOrAddr(const OpTy &Op)
Matches PtrToInt or PtrToAddr.
cstfp_pred_ty< is_inf > m_Inf()
Match a positive or negative infinity FP constant.
BinaryOp_match< LHS, RHS, Instruction::FSub > m_FSub(const LHS &L, const RHS &R)
cst_pred_ty< is_power2 > m_Power2()
Match an integer or vector power-of-2.
OverflowingBinaryOp_match< LHS, RHS, Instruction::Add, OverflowingBinaryOperator::NoSignedWrap, true > m_c_NSWAdd(const LHS &L, const RHS &R)
BinaryOp_match< cstfp_pred_ty< is_any_zero_fp >, RHS, Instruction::FSub > m_FNegNSZ(const RHS &X)
Match 'fneg X' as 'fsub +-0.0, X'.
BinaryOp_match< LHS, RHS, Instruction::URem > m_URem(const LHS &L, const RHS &R)
match_combine_or< CastInst_match< OpTy, CastInst >, OpTy > m_CastOrSelf(const OpTy &Op)
Matches any cast or self. Used to ignore casts.
match_combine_or< CastInst_match< OpTy, TruncInst >, OpTy > m_TruncOrSelf(const OpTy &Op)
auto m_LogicalOp()
Matches either L && R or L || R where L and R are arbitrary values.
CommutativeBinaryIntrinsic_match< IntrID, T0, T1 > m_c_Intrinsic(const T0 &Op0, const T1 &Op1)
OneOps_match< OpTy, Instruction::Freeze > m_Freeze(const OpTy &Op)
Matches FreezeInst.
auto m_Poison()
Match an arbitrary poison constant.
ap_match< APInt > m_APInt(const APInt *&Res)
Match a ConstantInt or splatted ConstantVector, binding the specified pointer to the contained APInt.
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.
ap_match< APFloat > m_APFloatForbidPoison(const APFloat *&Res)
Match APFloat while forbidding poison in splat vector constants.
cst_pred_ty< is_power2_or_zero > m_Power2OrZero()
Match an integer or vector of 0 or power-of-2 values.
CastInst_match< OpTy, TruncInst > m_Trunc(const OpTy &Op)
Matches Trunc.
BinaryOp_match< LHS, RHS, Instruction::Xor > m_Xor(const LHS &L, const RHS &R)
br_match m_UnconditionalBr(BasicBlock *&Succ)
CastOperator_match< OpTy, Instruction::PtrToAddr > m_PtrToAddr(const OpTy &Op)
Matches PtrToAddr.
auto m_Sqrt(const Opnd0 &Op0)
ap_match< APInt > m_APIntAllowPoison(const APInt *&Res)
Match APInt while allowing poison in splat vector constants.
auto m_ConstantExpr()
Match a constant expression or a constant that contains a constant expression.
OverflowingBinaryOp_match< LHS, RHS, Instruction::Sub, OverflowingBinaryOperator::NoSignedWrap > m_NSWSub(const LHS &L, const RHS &R)
specific_intval< false > m_SpecificInt(const APInt &V)
Match a specific integer value or vector with all elements equal to the value.
BinaryOp_match< LHS, RHS, Instruction::FMul > m_FMul(const LHS &L, const RHS &R)
match_combine_or< CastInst_match< OpTy, ZExtInst >, OpTy > m_ZExtOrSelf(const OpTy &Op)
LoadSimple_match< OpTy > m_LoadSimple(const OpTy &Op)
bool match(Val *V, const Pattern &P)
BinOpPred_match< LHS, RHS, is_idiv_op > m_IDiv(const LHS &L, const RHS &R)
Matches integer division operations.
match_bind< Instruction > m_Instruction(Instruction *&I)
Match an instruction, capturing it if we match.
cst_pred_ty< is_shifted_mask > m_ShiftedMask()
auto m_UMin(const Opnd0 &Op0, const Opnd1 &Op1)
match_deferred< Value > m_Deferred(Value *const &V)
Like m_Specific(), but works if the specific value to match is determined as part of the same match()...
cstval_pred_ty< Predicate, ConstantInt, AllowPoison > cst_pred_ty
specialization of cstval_pred_ty for ConstantInt
cstfp_pred_ty< is_any_zero_fp > m_AnyZeroFP()
Match a floating-point negative zero or positive zero.
specificval_ty m_Specific(const Value *V)
Match if we have a specific specified value.
DisjointOr_match< LHS, RHS > m_DisjointOr(const LHS &L, const RHS &R)
cstfp_pred_ty< is_signed_inf< true > > m_NegInf()
Match a negative infinity FP constant.
BinOpPred_match< LHS, RHS, is_right_shift_op > m_Shr(const LHS &L, const RHS &R)
Matches logical shift operations.
auto m_c_XorLike(const LHS &L, const RHS &R)
Match either (xor L, R), (xor R, L) or (sub nuw R, L) iff R.isMask() Only commutative matcher as the ...
specific_intval< true > m_SpecificIntAllowPoison(const APInt &V)
ap_match< APFloat > m_APFloat(const APFloat *&Res)
Match a ConstantFP or splatted ConstantVector, binding the specified pointer to the contained APFloat...
ap_match< APFloat > m_APFloatAllowPoison(const APFloat *&Res)
Match APFloat while allowing poison in splat vector constants.
CmpClass_match< LHS, RHS, ICmpInst, true > m_c_ICmp(CmpPredicate &Pred, const LHS &L, const RHS &R)
Matches an ICmp with a predicate over LHS and RHS in either order.
auto match_fn(const Pattern &P)
A match functor that can be used as a UnaryPredicate in functional algorithms like all_of.
OverflowingBinaryOp_match< LHS, RHS, Instruction::Add, OverflowingBinaryOperator::NoUnsignedWrap, true > m_c_NUWAdd(const LHS &L, const RHS &R)
OverflowingBinaryOp_match< cst_pred_ty< is_zero_int >, ValTy, Instruction::Sub, OverflowingBinaryOperator::NoSignedWrap > m_NSWNeg(const ValTy &V)
Matches a 'Neg' as 'sub nsw 0, V'.
TwoOps_match< Val_t, Idx_t, Instruction::ExtractElement > m_ExtractElt(const Val_t &Val, const Idx_t &Idx)
Matches ExtractElementInst.
cstfp_pred_ty< is_finite > m_Finite()
Match a finite FP constant, i.e.
FMaxMin_match< LHS, RHS, ofmin_pred_ty > m_OrdFMin(const LHS &L, const RHS &R)
Match an 'ordered' floating point minimum function.
cst_pred_ty< is_nonnegative > m_NonNegative()
Match an integer or vector of non-negative values.
auto m_SMax(const Opnd0 &Op0, const Opnd1 &Op1)
auto m_LogicalOp(const LHS &L, const RHS &R)
Matches either L && R or L || R, either one being in the either binary or logical form.
cst_pred_ty< is_one > m_One()
Match an integer 1 or a vector with all elements equal to 1.
ThreeOps_match< Cond, LHS, RHS, Instruction::Select > m_Select(const Cond &C, const LHS &L, const RHS &R)
Matches SelectInst.
cstfp_pred_ty< is_neg_zero_fp > m_NegZeroFP()
Match a floating-point negative zero.
auto m_BinOp()
Match an arbitrary binary operation and ignore it.
auto m_UMax(const Opnd0 &Op0, const Opnd1 &Op1)
match_combine_or< CastInst_match< OpTy, SExtInst >, OpTy > m_SExtOrSelf(const OpTy &Op)
FMaxMin_match< LHS, RHS, ufmin_pred_ty > m_UnordFMin(const LHS &L, const RHS &R)
Match an 'unordered' floating point minimum function.
InsertValue_match< Ind, Val_t, Elt_t > m_InsertValue(const Val_t &Val, const Elt_t &Elt)
Matches a single index InsertValue instruction.
auto m_BasicBlock()
Match an arbitrary basic block value and ignore it.
specific_fpval m_SpecificFP(double V)
Match a specific floating point value or vector with all elements equal to the value.
auto m_CopySign(const Opnd0 &Op0, const Opnd1 &Op1)
ExtractValue_match< Ind, Val_t > m_ExtractValue(const Val_t &V)
Match a single index ExtractValue instruction.
BinOpPred_match< LHS, RHS, is_logical_shift_op > m_LogicalShift(const LHS &L, const RHS &R)
Matches logical shift operations.
match_combine_or< CastInst_match< OpTy, UIToFPInst >, CastInst_match< OpTy, SIToFPInst > > m_IToFP(const OpTy &Op)
cst_pred_ty< is_any_apint > m_AnyIntegralConstant()
Match an integer or vector with any integral constant.
auto m_FMinimum(const Opnd0 &Op0, const Opnd1 &Op1)
ICmpLike_match< LHS, RHS > m_ICmpLike(CmpPredicate &Pred, const LHS &L, const RHS &R)
CastInst_match< OpTy, FPToUIInst > m_FPToUI(const OpTy &Op)
auto m_Value()
Match an arbitrary value and ignore it.
ShiftLike_match< LHS, Instruction::Shl > m_ShlOrSelf(const LHS &L, uint64_t &R)
Matches shl L, ConstShAmt or L itself (R will be set to zero in this case).
BinaryOp_match< LHS, RHS, Instruction::Xor, true > m_c_Xor(const LHS &L, const RHS &R)
Matches an Xor with LHS and RHS in either order.
BinaryOp_match< LHS, RHS, Instruction::FAdd > m_FAdd(const LHS &L, const RHS &R)
auto m_Ctpop(const Opnd0 &Op0)
auto m_FMaximum(const Opnd0 &Op0, const Opnd1 &Op1)
SpecificCmpClass_match< LHS, RHS, CmpInst > m_SpecificCmp(CmpPredicate MatchPred, const LHS &L, const RHS &R)
BinaryOp_match< LHS, RHS, Instruction::Mul > m_Mul(const LHS &L, const RHS &R)
auto m_UndefValue()
Match an arbitrary UndefValue constant.
cst_pred_ty< is_zero_int > m_ZeroInt()
Match an integer 0 or a vector with all elements equal to 0.
auto m_Constant()
Match an arbitrary Constant and ignore it.
ContainsMatchingVectorElement_match< SPTy > m_ContainsMatchingVectorElement(const SPTy &SubPattern)
Match a vector constant where at least one of its elements matches the subpattern.
NoWrapTrunc_match< OpTy, TruncInst::NoSignedWrap > m_NSWTrunc(const OpTy &Op)
Matches trunc nsw.
match_combine_or< match_combine_or< CastInst_match< OpTy, ZExtInst >, CastInst_match< OpTy, SExtInst > >, OpTy > m_ZExtOrSExtOrSelf(const OpTy &Op)
OneUse_match< T > m_OneUse(const T &SubPattern)
NNegZExt_match< OpTy > m_NNegZExt(const OpTy &Op)
auto m_LogicalOr()
Matches L || R where L and R are arbitrary values.
BinaryOp_match< cst_pred_ty< is_zero_int >, ValTy, Instruction::Sub > m_Neg(const ValTy &V)
Matches a 'Neg' as 'sub 0, V'.
Splat_match< T > m_ConstantSplat(const T &SubPattern)
Match a constant splat. TODO: Extend this to non-constant splats.
TwoOps_match< V1_t, V2_t, Instruction::ShuffleVector > m_Shuffle(const V1_t &v1, const V2_t &v2)
Matches ShuffleVectorInst independently of mask value.
specific_bbval m_SpecificBB(BasicBlock *BB)
Match a specific basic block value.
auto m_GEP(const OperandTypes &...Ops)
Matches GetElementPtrInst.
ap_match< APInt > m_APIntForbidPoison(const APInt *&Res)
Match APInt while forbidding poison in splat vector constants.
AllowFmf_match< T, FastMathFlags::NoNaNs > m_NoNaNs(const T &SubPattern)
cst_pred_ty< is_strictlypositive > m_StrictlyPositive()
Match an integer or vector of strictly positive values.
auto m_MaskedGather(const Opnd0 &Op0, const Opnd1 &Op1, const Opnd2 &Op2)
Matches MaskedGather Intrinsic.
auto m_VScale()
Matches a call to llvm.vscale().
FMaxMin_match< LHS, RHS, ufmax_pred_ty > m_UnordFMax(const LHS &L, const RHS &R)
Match an 'unordered' floating point maximum function.
match_combine_or< CastInst_match< OpTy, FPToUIInst >, CastInst_match< OpTy, FPToSIInst > > m_FPToI(const OpTy &Op)
cst_pred_ty< is_non_zero_int > m_NonZeroInt()
Match a non-zero integer or a vector with all non-zero elements.
ThreeOps_match< decltype(m_Value()), LHS, RHS, Instruction::Select, true > m_c_Select(const LHS &L, const RHS &R)
Match Select(C, LHS, RHS) or Select(C, RHS, LHS)
CastInst_match< OpTy, FPExtInst > m_FPExt(const OpTy &Op)
OverflowingBinaryOp_match< LHS, RHS, Instruction::Shl, OverflowingBinaryOperator::NoSignedWrap > m_NSWShl(const LHS &L, const RHS &R)
match_bind< WithOverflowInst > m_WithOverflowInst(WithOverflowInst *&I)
Match a with overflow intrinsic, capturing it if we match.
cstfp_pred_ty< is_nonnan > m_NonNaN()
Match a non-NaN FP constant.
SpecificCmpClass_match< LHS, RHS, ICmpInst > m_SpecificICmp(CmpPredicate MatchPred, const LHS &L, const RHS &R)
AllowFmf_match< T, FastMathFlags::AllowReassoc > m_AllowReassoc(const T &SubPattern)
OneOps_match< OpTy, Instruction::Load > m_Load(const OpTy &Op)
Matches LoadInst.
CastInst_match< OpTy, ZExtInst > m_ZExt(const OpTy &Op)
Matches ZExt.
OverflowingBinaryOp_match< LHS, RHS, Instruction::Shl, OverflowingBinaryOperator::NoUnsignedWrap > m_NUWShl(const LHS &L, const RHS &R)
auto m_Ctlz(const Opnd0 &Op0, const Opnd1 &Op1)
FMaxMin_match< LHS, RHS, ofmax_pred_ty > m_OrdFMax(const LHS &L, const RHS &R)
Match an 'ordered' floating point maximum function.
auto m_Interleave2(const Opnd0 &Op0, const Opnd1 &Op1)
auto m_AnyIntrinsic()
Matches any intrinsic call and ignore it.
cstfp_pred_ty< is_non_zero_not_denormal_fp > m_NonZeroNotDenormalFP()
Match a floating-point non-zero that is not a denormal.
cst_pred_ty< is_all_ones, false > m_AllOnesForbidPoison()
match_combine_or< FMaxMin_match< LHS, RHS, ofmin_pred_ty >, FMaxMin_match< LHS, RHS, ufmin_pred_ty > > m_OrdOrUnordFMin(const LHS &L, const RHS &R)
Match an 'ordered' or 'unordered' floating point minimum function.
OverflowingBinaryOp_match< LHS, RHS, Instruction::Mul, OverflowingBinaryOperator::NoUnsignedWrap > m_NUWMul(const LHS &L, const RHS &R)
BinaryOp_match< LHS, RHS, Instruction::UDiv > m_UDiv(const LHS &L, const RHS &R)
auto m_FCanonicalize(const Opnd0 &Op0)
BinOpPred_match< LHS, RHS, is_bitwiselogic_op, true > m_c_BitwiseLogic(const LHS &L, const RHS &R)
Matches bitwise logic operations in either order.
auto m_FShl(const Opnd0 &Op0, const Opnd1 &Op1, const Opnd2 &Op2)
AllowFmf_match< T, FastMathFlags::ApproxFunc > m_ApproxFunc(const T &SubPattern)
auto m_FMinNum_or_FMinimumNum(const Opnd0 &Op0, const Opnd1 &Op1)
cstfp_pred_ty< is_signed_inf< false > > m_PosInf()
Match a positive infinity FP constant.
cst_pred_ty< is_negated_power2 > m_NegatedPower2()
Match a integer or vector negated power-of-2.
match_immconstant_ty m_ImmConstant()
Match an arbitrary immediate Constant and ignore it.
cst_pred_ty< is_negated_power2_or_zero > m_NegatedPower2OrZero()
Match a integer or vector negated power-of-2.
auto m_ZExtOrTruncOrSelf(const OpTy &Op)
auto m_c_LogicalOp(const LHS &L, const RHS &R)
Matches either L && R or L || R with LHS and RHS in either order.
NoWrapTrunc_match< OpTy, TruncInst::NoUnsignedWrap > m_NUWTrunc(const OpTy &Op)
Matches trunc nuw.
ShiftLike_match< LHS, Instruction::AShr > m_AShrOrSelf(const LHS &L, uint64_t &R)
Matches ashr L, ConstShAmt or L itself (R will be set to zero in this case).
cst_pred_ty< custom_checkfn< APInt > > m_CheckedInt(function_ref< bool(const APInt &)> CheckFn)
Match an integer or vector where CheckFn(ele) for each element is true.
SelectLike_match< CondTy, LTy, RTy > m_SelectLike(const CondTy &C, const LTy &TrueC, const RTy &FalseC)
Matches a value that behaves like a boolean-controlled select, i.e.
cst_pred_ty< is_lowbit_mask_or_zero > m_LowBitMaskOrZero()
Match an integer or vector with only the low bit(s) set.
specific_fpval m_FPOne()
Match a float 1.0 or vector with all elements equal to 1.0.
DisjointOr_match< LHS, RHS, true > m_c_DisjointOr(const LHS &L, const RHS &R)
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.
SpecificCmpClass_match< LHS, RHS, FCmpInst > m_SpecificFCmp(CmpPredicate MatchPred, const LHS &L, const RHS &R)
match_combine_or< BinaryOp_match< LHS, RHS, Instruction::Add >, DisjointOr_match< LHS, RHS > > m_AddLike(const LHS &L, const RHS &R)
Match either "add" or "or disjoint".
CastInst_match< OpTy, UIToFPInst > m_UIToFP(const OpTy &Op)
CastOperator_match< OpTy, Instruction::BitCast > m_BitCast(const OpTy &Op)
Matches BitCast.
cstval_pred_ty< Predicate, ConstantFP, true > cstfp_pred_ty
specialization of cstval_pred_ty for ConstantFP
auto m_FMinimumNum(const Opnd0 &Op0, const Opnd1 &Op1)
match_combine_or< CastInst_match< OpTy, SExtInst >, NNegZExt_match< OpTy > > m_SExtLike(const OpTy &Op)
Match either "sext" or "zext nneg".
cstfp_pred_ty< is_finitenonzero > m_FiniteNonZero()
Match a finite non-zero FP constant.
CastInst_match< OpTy, FPToSIInst > m_FPToSI(const OpTy &Op)
auto m_Intrinsic(const Ts &...Ops)
Match intrinsic calls like this: m_Intrinsic<Intrinsic::fabs>(m_Value(X))
BinaryOp_match< LHS, RHS, Instruction::SDiv > m_SDiv(const LHS &L, const RHS &R)
auto m_Deinterleave2(const Opnd &Op)
auto m_MaskedStore(const Opnd0 &Op0, const Opnd1 &Op1, const Opnd2 &Op2)
Matches MaskedStore Intrinsic.
auto m_c_MaxOrMin(const LHS &L, const RHS &R)
cstfp_pred_ty< custom_checkfn< APFloat > > m_CheckedFp(function_ref< bool(const APFloat &)> CheckFn)
Match a float or vector where CheckFn(ele) for each element is true.
auto m_FMinNum(const Opnd0 &Op0, const Opnd1 &Op1)
auto m_VectorInsert(const Opnd0 &Op0, const Opnd1 &Op1, const Opnd2 &Op2)
OverflowingBinaryOp_match< LHS, RHS, Instruction::Sub, OverflowingBinaryOperator::NoUnsignedWrap > m_NUWSub(const LHS &L, const RHS &R)
auto m_FMaximumNum(const Opnd0 &Op0, const Opnd1 &Op1)
auto m_SMin(const Opnd0 &Op0, const Opnd1 &Op1)
auto m_MaskedLoad(const Opnd0 &Op0, const Opnd1 &Op1, const Opnd2 &Op2)
Matches MaskedLoad Intrinsic.
cst_pred_ty< is_maxsignedvalue > m_MaxSignedValue()
Match an integer or vector with values having all bits except for the high bit set (0x7f....
auto m_FAbs(const Opnd0 &Op0)
match_combine_or< OverflowingBinaryOp_match< LHS, RHS, Instruction::Add, OverflowingBinaryOperator::NoSignedWrap >, DisjointOr_match< LHS, RHS > > m_NSWAddLike(const LHS &L, const RHS &R)
Match either "add nsw" or "or disjoint".
AnyBinaryOp_match< LHS, RHS, true > m_c_BinOp(const LHS &L, const RHS &R)
Matches a BinaryOperator with LHS and RHS in either order.
Signum_match< Val_t > m_Signum(const Val_t &V)
Matches a signum pattern.
match_combine_or< FMaxMin_match< LHS, RHS, ofmax_pred_ty >, FMaxMin_match< LHS, RHS, ufmax_pred_ty > > m_OrdOrUnordFMax(const LHS &L, const RHS &R)
Match an 'ordered' or 'unordered' floating point maximum function.
OverflowingBinaryOp_match< LHS, RHS, Instruction::Add, OverflowingBinaryOperator::NoSignedWrap > m_NSWAdd(const LHS &L, const RHS &R)
CastInst_match< OpTy, SIToFPInst > m_SIToFP(const OpTy &Op)
BinaryOp_match< LHS, RHS, Instruction::LShr > m_LShr(const LHS &L, const RHS &R)
CmpClass_match< LHS, RHS, ICmpInst > m_ICmp(CmpPredicate &Pred, const LHS &L, const RHS &R)
Argument_match< Opnd_t > m_Argument(const Opnd_t &Op)
Match an argument.
match_combine_or< CastInst_match< OpTy, ZExtInst >, CastInst_match< OpTy, SExtInst > > m_ZExtOrSExt(const OpTy &Op)
Exact_match< T > m_Exact(const T &SubPattern)
FNeg_match< OpTy > m_FNeg(const OpTy &X)
Match 'fneg X' as 'fsub -0.0, X'.
BinOpPred_match< LHS, RHS, is_shift_op > m_Shift(const LHS &L, const RHS &R)
Matches shift operations.
cstfp_pred_ty< is_pos_zero_fp > m_PosZeroFP()
Match a floating-point positive zero.
BinaryOp_match< LHS, RHS, Instruction::FAdd, true > m_c_FAdd(const LHS &L, const RHS &R)
Matches FAdd with LHS and RHS in either order.
auto m_UnOp()
Match an arbitrary unary operation and ignore it.
LogicalOp_match< LHS, RHS, Instruction::And, true > m_c_LogicalAnd(const LHS &L, const RHS &R)
Matches L && R with LHS and RHS in either order.
BinaryOp_match< LHS, RHS, Instruction::Shl > m_Shl(const LHS &L, const RHS &R)
cstfp_pred_ty< is_non_zero_fp > m_NonZeroFP()
Match a floating-point non-zero.
UAddWithOverflow_match< LHS_t, RHS_t, Sum_t > m_UAddWithOverflow(const LHS_t &L, const RHS_t &R, const Sum_t &S)
Match an icmp instruction checking for unsigned overflow on addition.
BinaryOp_match< LHS, RHS, Instruction::FDiv > m_FDiv(const LHS &L, const RHS &R)
BinOpPred_match< LHS, RHS, is_irem_op > m_IRem(const LHS &L, const RHS &R)
Matches integer remainder operations.
auto m_MaxOrMin(const Opnd0 &Op0, const Opnd1 &Op1)
auto m_LogicalAnd()
Matches L && R where L and R are arbitrary values.
brc_match< Cond_t, match_bind< BasicBlock >, match_bind< BasicBlock > > m_Br(const Cond_t &C, BasicBlock *&T, BasicBlock *&F)
auto m_c_UMin(const LHS &L, const RHS &R)
Matches a UMin with LHS and RHS in either order.
ThreeOps_match< Cond, constantint_match< L >, constantint_match< R >, Instruction::Select > m_SelectCst(const Cond &C)
This matches a select of two constants, e.g.: m_SelectCst<-1, 0>(m_Value(V))
auto m_c_SMax(const LHS &L, const RHS &R)
Matches an SMax with LHS and RHS in either order.
BinaryOp_match< LHS, RHS, Instruction::FRem > m_FRem(const LHS &L, const RHS &R)
AllowFmf_match< T, FastMathFlags::AllowContract > m_AllowContract(const T &SubPattern)
CastInst_match< OpTy, FPTruncInst > m_FPTrunc(const OpTy &Op)
BinaryOp_match< LHS, RHS, Instruction::SRem > m_SRem(const LHS &L, const RHS &R)
auto m_Undef()
Match an arbitrary undef constant.
auto m_FMaxNum(const Opnd0 &Op0, const Opnd1 &Op1)
cst_pred_ty< is_nonpositive > m_NonPositive()
Match an integer or vector of non-positive values.
cstfp_pred_ty< is_nan > m_NaN()
Match an arbitrary NaN constant.
auto m_ConstantFP()
Match an arbitrary ConstantFP and ignore it.
BinaryOp_match< cst_pred_ty< is_all_ones >, ValTy, Instruction::Xor, true > m_Not(const ValTy &V)
Matches a 'Not' as 'xor V, -1' or 'xor -1, V'.
auto m_VecReverse(const Opnd0 &Op0)
BinaryOp_match< LHS, RHS, Instruction::Or > m_Or(const LHS &L, const RHS &R)
CastInst_match< OpTy, SExtInst > m_SExt(const OpTy &Op)
Matches SExt.
is_zero m_Zero()
Match any null constant or a vector with all elements equal to 0.
BinaryOp_match< LHS, RHS, Instruction::Or, true > m_c_Or(const LHS &L, const RHS &R)
Matches an Or with LHS and RHS in either order.
match_combine_or< OverflowingBinaryOp_match< LHS, RHS, Instruction::Add, OverflowingBinaryOperator::NoUnsignedWrap >, DisjointOr_match< LHS, RHS > > m_NUWAddLike(const LHS &L, const RHS &R)
Match either "add nuw" or "or disjoint".
CastOperator_match< OpTy, Instruction::IntToPtr > m_IntToPtr(const OpTy &Op)
Matches IntToPtr.
auto m_c_SMin(const LHS &L, const RHS &R)
Matches an SMin with LHS and RHS in either order.
BinOpPred_match< LHS, RHS, is_bitwiselogic_op > m_BitwiseLogic(const LHS &L, const RHS &R)
Matches bitwise logic operations.
LogicalOp_match< LHS, RHS, Instruction::Or, true > m_c_LogicalOr(const LHS &L, const RHS &R)
Matches L || R with LHS and RHS in either order.
ThreeOps_match< Val_t, Elt_t, Idx_t, Instruction::InsertElement > m_InsertElt(const Val_t &Val, const Elt_t &Elt, const Idx_t &Idx)
Matches InsertElementInst.
SpecificCmpClass_match< LHS, RHS, ICmpInst, true > m_c_SpecificICmp(CmpPredicate MatchPred, const LHS &L, const RHS &R)
ElementWiseBitCast_match< OpTy > m_ElementWiseBitCast(const OpTy &Op)
BinaryOp_match< LHS, RHS, Instruction::Mul, true > m_c_Mul(const LHS &L, const RHS &R)
Matches a Mul with LHS and RHS in either order.
CastOperator_match< OpTy, Instruction::PtrToInt > m_PtrToInt(const OpTy &Op)
Matches PtrToInt.
AllowFmf_match< T, FastMathFlags::AllowReciprocal > m_AllowReciprocal(const T &SubPattern)
OverflowingBinaryOp_match< LHS, RHS, Instruction::Mul, OverflowingBinaryOperator::NoSignedWrap > m_NSWMul(const LHS &L, const RHS &R)
auto m_Cttz(const Opnd0 &Op0, const Opnd1 &Op1)
BinaryOp_match< LHS, RHS, Instruction::Sub > m_Sub(const LHS &L, const RHS &R)
auto m_FShr(const Opnd0 &Op0, const Opnd1 &Op1, const Opnd2 &Op2)
cstfp_pred_ty< is_noninf > m_NonInf()
Match a non-infinity FP constant, i.e.
match_unless< Ty > m_Unless(const Ty &M)
Match if the inner matcher does NOT match.
auto m_FMaxNum_or_FMaximumNum(const Opnd0 &Op0, const Opnd1 &Op1)
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.
auto m_ConstantInt()
Match an arbitrary ConstantInt and ignore it.
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
constexpr auto bind_back(FnT &&Fn, BindArgsT &&...BindArgs)
C++23 bind_back.
auto dyn_cast_or_null(const Y &Val)
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
bool all_equal(std::initializer_list< T > Values)
Returns true if all Values in the initializer lists are equal or the list.
Matcher to bind the captured value.
Matching or combinator leaf case.
Matcher for a specific value, but stores a reference to the value, not the value itself.
AllowFmf_match(const SubPattern_t &SP)
bool match(OpTy *V) const
AnyBinaryOp_match(const LHS_t &LHS, const RHS_t &RHS)
bool match(OpTy *V) const
Matches instructions with Opcode and any number of operands.
bool match(OpTy *V) const
std::enable_if_t< Idx==Last, bool > match_operands(const Instruction *I) const
std::enable_if_t< Idx !=Last, bool > match_operands(const Instruction *I) const
std::tuple< OperandTypes... > Operands
AnyOps_match(const OperandTypes &...Ops)
AnyUnaryOp_match(const OP_t &X)
bool match(OpTy *V) const
Argument_match(unsigned OpIdx, const Opnd_t &V)
bool match(OpTy *V) const
BinOpPred_match(const LHS_t &LHS, const RHS_t &RHS)
bool match(OpTy *V) const
BinaryOp_match(const LHS_t &LHS, const RHS_t &RHS)
bool match(OpTy *V) const
bool match(unsigned Opc, OpTy *V) const
CastInst_match(const Op_t &OpMatch)
bool match(OpTy *V) const
CastOperator_match(const Op_t &OpMatch)
bool match(OpTy *V) const
bool match(OpTy *V) const
CmpClass_match(CmpPredicate &Pred, const LHS_t &LHS, const RHS_t &RHS)
CmpClass_match(const LHS_t &LHS, const RHS_t &RHS)
bool match(OpTy *V) const
CommutativeBinaryIntrinsic_match(const LHS &L, const RHS &R)
ContainsMatchingVectorElement_match(const SPTy &SP)
DisjointOr_match(const LHS &L, const RHS &R)
bool match(OpTy *V) const
bool match(OpTy *V) const
ElementWiseBitCast_match(const Op_t &OpMatch)
Exact_match(const SubPattern_t &SP)
bool match(OpTy *V) const
bool match(OpTy *V) const
FMaxMin_match(const LHS_t &LHS, const RHS_t &RHS)
FNeg_match(const Op_t &Op)
bool match(OpTy *V) const
ICmpLike_match(CmpPredicate &P, const LHS_t &Left, const RHS_t &Right)
bool match(OpTy *V) const
Matcher for a single index InsertValue instruction.
InsertValue_match(const T0 &Op0, const T1 &Op1)
bool match(OpTy *V) const
IntrinsicID_match(Intrinsic::ID IntrID)
bool match(OpTy *V) const
Match intrinsic calls with any of the given IDs.
bool match(OpTy *V) const
static auto impl(std::index_sequence< Is... >, const Ts &...Ops)
Matches a simple (non-volatile, non-atomic) LoadInst.
OneOps_match< OpTy, Instruction::Load > Base
LoadSimple_match(const OpTy &Op)
LogicalOp_match(const LHS &L, const RHS &R)
NNegZExt_match(const Op_t &OpMatch)
bool match(OpTy *V) const
NoWrapTrunc_match(const Op_t &OpMatch)
bool match(OpTy *V) const
Matches instructions with Opcode and three operands.
bool match(OpTy *V) const
OneOps_match(const T0 &Op1)
bool match(OpTy *V) const
OneUse_match(const SubPattern_t &SP)
bool match(OpTy *V) const
OverflowingBinaryOp_match(const LHS_t &LHS, const RHS_t &RHS)
bool match(OpTy *V) const
PtrAdd_match(const PointerOpTy &PointerOp, const OffsetOpTy &OffsetOp)
PtrToIntSameSize_match(const DataLayout &DL, const Op_t &OpMatch)
bool match(OpTy *V) const
SelectLike_match(const CondTy &C, const LTy &TC, const RTy &FC)
bool match(OpTy *V) const
ShiftLike_match(const LHS_t &LHS, uint64_t &RHS)
bool match(OpTy *V) const
Shuffle_match(const T0 &Op1, const T1 &Op2, const T2 &Mask)
bool match(OpTy *V) const
bool match(OpTy *V) const
Signum_match(const Opnd_t &V)
bool match(OpTy *V) const
SpecificBinaryOp_match(unsigned Opcode, const LHS_t &LHS, const RHS_t &RHS)
bool match(OpTy *V) const
SpecificCmpClass_match(CmpPredicate Pred, const LHS_t &LHS, const RHS_t &RHS)
const CmpPredicate Predicate
bool match(OpTy *V) const
Splat_match(const SubPattern_t &SP)
Matches instructions with Opcode and three operands.
ThreeOps_match(const T0 &Op1, const T1 &Op2, const T2 &Op3)
bool match(OpTy *V) const
Matches instructions with Opcode and three operands.
TwoOps_match(const T0 &Op1, const T1 &Op2)
bool match(OpTy *V) const
bool match(OpTy *V) const
UAddWithOverflow_match(const LHS_t &L, const RHS_t &R, const Sum_t &S)
XorLike_match(const LHS &L, const RHS &R)
bool match(OpTy *V) const
ap_match(const APTy *&Res, bool AllowPoison)
std::conditional_t< std::is_same_v< APTy, APInt >, ConstantInt, ConstantFP > ConstantTy
This helper class is used to match scalar and vector constants that satisfy a specified predicate,...
apf_pred_ty(const APFloat *&R)
This helper class is used to match scalar and vector constants that satisfy a specified predicate,...
api_pred_ty(const APInt *&R)
bind_const_intval_ty(uint64_t &V)
bind_immconstant_ty(Constant *&V)
bool match(OpTy *V) const
br_match(BasicBlock *&Succ)
brc_match(const Cond_t &C, const TrueBlock_t &t, const FalseBlock_t &f)
bool match(OpTy *V) const
This helper class is used to match constant scalars, vector splats, and fixed width vectors that sati...
bool match_impl(ITy *V) const
bool isValue(const APTy &C) const
function_ref< bool(const APTy &)> CheckFn
bool isValue(const APInt &C) const
static bool isImmConstant(ITy *V)
bool isValue(const APInt &C) const
bool isValue(const APInt &C) const
bool isValue(const APFloat &C) const
bool isOpType(unsigned Opcode) const
bool isValue(const APFloat &C) const
bool isValue(const APFloat &C) const
bool isOpType(unsigned Opcode) const
bool isValue(const APFloat &C) const
bool isOpType(unsigned Opcode) const
bool isOpType(unsigned Opcode) const
bool isValue(const APInt &C) const
bool isValue(const APInt &C) const
bool isValue(const APInt &C) const
bool isValue(const APFloat &C) const
bool isValue(const APFloat &C) const
bool isValue(const APInt &C) const
bool isValue(const APInt &C) const
bool isValue(const APInt &C) const
bool isValue(const APFloat &C) const
bool isValue(const APInt &C) const
bool isValue(const APFloat &C) const
bool isValue(const APFloat &C) const
bool isValue(const APFloat &C) const
bool isValue(const APInt &C) const
bool isValue(const APInt &C) const
bool isValue(const APInt &C) const
bool isValue(const APFloat &C) const
bool isValue(const APInt &C) const
bool isValue(const APInt &C) const
bool isOpType(unsigned Opcode) const
bool isOpType(unsigned Opcode) const
bool isValue(const APInt &C) const
bool isValue(const APInt &C) const
bool isValue(const APFloat &C) const
bool isValue(const APInt &C) const
bool isValue(const APInt &C) const
ArrayRef< int > & MaskRef
m_Mask(ArrayRef< int > &MaskRef)
bool match(ArrayRef< int > Mask) const
bool match(ArrayRef< int > Mask) const
m_SpecificMask(ArrayRef< int > Val)
bool match(ArrayRef< int > Mask) const
bool match(ArrayRef< int > Mask) const
m_SplatOrPoisonMask(int &SplatIndex)
bool match(ArrayRef< int > Mask) const
match_unless(const Ty &Matcher)
Helper class for identifying ordered max predicates.
static bool match(FCmpInst::Predicate Pred)
Helper class for identifying ordered min predicates.
static bool match(FCmpInst::Predicate Pred)
Match a specified basic block value.
specific_bbval(BasicBlock *Val)
Match a specified floating point value or vector of all elements of that value.
specific_intval64(uint64_t V)
Match a specified integer value or vector of all elements of that value.
specific_intval(const APInt &V)
Matcher for specified Value*.
specificval_ty(const Value *V)
Helper class for identifying unordered max predicates.
static bool match(FCmpInst::Predicate Pred)
Helper class for identifying unordered min predicates.
static bool match(FCmpInst::Predicate Pred)
static bool check(const Value *V)