LLVM 23.0.0git
VPlanPatternMatch.h
Go to the documentation of this file.
1//===- VPlanPatternMatch.h - Match on VPValues and recipes ------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file provides a simple and efficient mechanism for performing general
10// tree-based pattern matches on the VPlan values and recipes, based on
11// LLVM's IR pattern matchers.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_TRANSFORM_VECTORIZE_VPLANPATTERNMATCH_H
16#define LLVM_TRANSFORM_VECTORIZE_VPLANPATTERNMATCH_H
17
18#include "VPlan.h"
20
21using namespace llvm::PatternMatchHelpers;
22
24
25template <typename Val, typename Pattern> bool match(Val *V, const Pattern &P) {
26 return P.match(V);
27}
28
29/// A match functor that can be used as a UnaryPredicate in functional
30/// algorithms like all_of.
31template <typename Val, typename Pattern> auto match_fn(const Pattern &P) {
33}
34
35template <typename Pattern> bool match(VPUser *U, const Pattern &P) {
36 auto *R = dyn_cast<VPRecipeBase>(U);
37 return R && match(R, P);
38}
39
40/// Match functor for VPUser.
41template <typename Pattern> auto match_fn(const Pattern &P) {
43}
44
45template <typename Pattern> bool match(VPSingleDefRecipe *R, const Pattern &P) {
46 return P.match(static_cast<const VPRecipeBase *>(R));
47}
48
49/// Match an arbitrary VPValue and ignore it.
50inline auto m_VPValue() { return m_Isa<VPValue>(); }
51
52/// Match a specified VPValue.
54 const VPValue *Val;
55
56 specificval_ty(const VPValue *V) : Val(V) {}
57
58 bool match(const VPValue *VPV) const { return VPV == Val; }
59};
60
61inline specificval_ty m_Specific(const VPValue *VPV) { return VPV; }
62
63/// Like m_Specific(), but works if the specific value to match is determined
64/// as part of the same match() expression. For example:
65/// m_Mul(m_VPValue(X), m_Specific(X)) is incorrect, because m_Specific() will
66/// bind X before the pattern match starts.
67/// m_Mul(m_VPValue(X), m_Deferred(X)) is correct, and will check against
68/// whichever value m_VPValue(X) populated.
69inline match_deferred<VPValue> m_Deferred(VPValue *const &V) { return V; }
70
71/// Match an integer constant if Pred::isValue returns true for the APInt. \p
72/// BitWidth optionally specifies the bitwidth the matched constant must have.
73/// If it is 0, the matched constant can have any bitwidth.
74template <typename Pred, unsigned BitWidth = 0> struct int_pred_ty {
75 Pred P;
76
77 int_pred_ty(Pred P) : P(std::move(P)) {}
78 int_pred_ty() : P() {}
79
80 bool match(const VPValue *VPV) const {
81 auto *VPI = dyn_cast<VPInstruction>(VPV);
82 if (VPI && VPI->getOpcode() == VPInstruction::Broadcast)
83 VPV = VPI->getOperand(0);
84 auto *CI = dyn_cast<VPConstantInt>(VPV);
85 if (!CI)
86 return false;
87
88 if (BitWidth != 0 && CI->getBitWidth() != BitWidth)
89 return false;
90 return P.isValue(CI->getAPInt());
91 }
92};
93
94/// Match a specified signed or unsigned integer value.
98
101
102 bool isValue(const APInt &C) const {
104 }
105};
106
107template <unsigned Bitwidth = 0>
109
113
115 return specific_intval<0>(
116 is_specific_int(APInt(64, V, /*isSigned=*/true), /*IsSigned=*/true));
117}
118
122
126
128 bool isValue(const APInt &C) const { return C.isAllOnes(); }
129};
130
131/// Match an integer or vector with all bits set.
132/// For vectors, this includes constants with undefined elements.
136
138 bool isValue(const APInt &C) const { return C.isZero(); }
139};
140
141struct is_one {
142 bool isValue(const APInt &C) const { return C.isOne(); }
143};
144
145/// Match an integer 0 or a vector with all elements equal to 0.
146/// For vectors, this includes constants with undefined elements.
150
151/// Match an integer 1 or a vector with all elements equal to 1.
152/// For vectors, this includes constants with undefined elements.
154
156 const APInt *&Res;
157
158 bind_apint(const APInt *&Res) : Res(Res) {}
159
160 bool match(const VPValue *VPV) const {
161 auto *CI = dyn_cast<VPConstantInt>(VPV);
162 if (!CI)
163 return false;
164 Res = &CI->getAPInt();
165 return true;
166 }
167};
168
169inline bind_apint m_APInt(const APInt *&C) { return C; }
170
173
175
176 bool match(const VPValue *VPV) const {
177 const APInt *APConst;
178 if (!bind_apint(APConst).match(VPV))
179 return false;
180 if (auto C = APConst->tryZExtValue()) {
181 Res = *C;
182 return true;
183 }
184 return false;
185 }
186};
187
189 bool match(const VPValue *V) const {
190 return isa<VPIRValue>(V) &&
191 isa<PoisonValue>(cast<VPIRValue>(V)->getValue());
192 }
193};
194
195/// Match a VPIRValue that's poison.
196inline match_poison m_Poison() { return match_poison(); }
197
198/// Match a plain integer constant no wider than 64-bits, capturing it if we
199/// match.
201
202/// Match a VPValue, capturing it if we match.
203inline match_bind<VPValue> m_VPValue(VPValue *&V) { return V; }
204
205/// Match a VPIRValue.
207
208/// Match a VPSingleDefRecipe, capturing if we match.
211 return V;
212}
213
214/// Match a VPInstruction, capturing if we match.
218
219template <typename Ops_t, unsigned Opcode, bool Commutative,
220 typename... RecipeTys>
222 Ops_t Ops;
223
224 template <typename... OpTy> Recipe_match(OpTy... Ops) : Ops(Ops...) {
225 static_assert(std::tuple_size<Ops_t>::value == sizeof...(Ops) &&
226 "number of operands in constructor doesn't match Ops_t");
227 static_assert((!Commutative || std::tuple_size<Ops_t>::value == 2) &&
228 "only binary ops can be commutative");
229 }
230
231 bool match(const VPValue *V) const {
232 auto *DefR = V->getDefiningRecipe();
233 return DefR && match(DefR);
234 }
235
236 bool match(const VPSingleDefRecipe *R) const {
237 return match(static_cast<const VPRecipeBase *>(R));
238 }
239
240 bool match(const VPRecipeBase *R) const {
241 if (std::tuple_size_v<Ops_t> == 0) {
242 auto *VPI = dyn_cast<VPInstruction>(R);
243 return VPI && VPI->getOpcode() == Opcode;
244 }
245
246 if ((!matchRecipeAndOpcode<RecipeTys>(R) && ...))
247 return false;
248
249 if (R->getNumOperands() < std::tuple_size<Ops_t>::value) {
250 [[maybe_unused]] auto *RepR = dyn_cast<VPReplicateRecipe>(R);
252 cast<VPInstruction>(R)->getNumOperandsForOpcode() == -1u) ||
253 (RepR && std::tuple_size_v<Ops_t> ==
254 RepR->getNumOperands() - RepR->isPredicated())) &&
255 "non-variadic recipe with matched opcode does not have the "
256 "expected number of operands");
257 return false;
258 }
259
260 // If the recipe has more operands than expected, we only support matching
261 // masked VPInstructions where the number of operands of the matcher is the
262 // same as the number of operands excluding mask.
263 if (R->getNumOperands() > std::tuple_size<Ops_t>::value) {
264 auto *VPI = dyn_cast<VPInstruction>(R);
265 if (!VPI || !VPI->isMasked() ||
266 VPI->getNumOperandsWithoutMask() != std::tuple_size<Ops_t>::value)
267 return false;
268 }
269
270 auto IdxSeq = std::make_index_sequence<std::tuple_size<Ops_t>::value>();
271 if (all_of_tuple_elements(IdxSeq, [R](auto Op, unsigned Idx) {
272 return Op.match(R->getOperand(Idx));
273 }))
274 return true;
275
276 return Commutative &&
277 all_of_tuple_elements(IdxSeq, [R](auto Op, unsigned Idx) {
278 return Op.match(R->getOperand(R->getNumOperands() - Idx - 1));
279 });
280 }
281
282private:
283 template <typename RecipeTy>
284 static bool matchRecipeAndOpcode(const VPRecipeBase *R) {
285 auto *DefR = dyn_cast<RecipeTy>(R);
286 // Check for recipes that do not have opcodes.
287 if constexpr (std::is_same_v<RecipeTy, VPScalarIVStepsRecipe> ||
288 std::is_same_v<RecipeTy, VPDerivedIVRecipe> ||
289 std::is_same_v<RecipeTy, VPVectorEndPointerRecipe>)
290 return DefR;
291 else
292 return DefR && DefR->getOpcode() == Opcode;
293 }
294
295 /// Helper to check if predicate \p P holds on all tuple elements in Ops using
296 /// the provided index sequence.
297 template <typename Fn, std::size_t... Is>
298 bool all_of_tuple_elements(std::index_sequence<Is...>, Fn P) const {
299 return (P(std::get<Is>(Ops), Is) && ...);
300 }
301};
302
303template <unsigned Opcode, typename... OpTys>
305 Recipe_match<std::tuple<OpTys...>, Opcode, /*Commutative*/ false,
308
309template <unsigned Opcode, typename... OpTys>
311 Recipe_match<std::tuple<OpTys...>, Opcode, /*Commutative*/ true,
313
314template <unsigned Opcode, typename... OpTys>
315using VPInstruction_match = Recipe_match<std::tuple<OpTys...>, Opcode,
316 /*Commutative*/ false, VPInstruction>;
317
318template <unsigned Opcode, typename... OpTys>
320 Recipe_match<std::tuple<OpTys...>, Opcode,
321 /*Commutative*/ true, VPInstruction>;
322
323template <unsigned Opcode, typename... OpTys>
324inline VPInstruction_match<Opcode, OpTys...>
325m_VPInstruction(const OpTys &...Ops) {
326 return VPInstruction_match<Opcode, OpTys...>(Ops...);
327}
328
329template <unsigned Opcode, typename Op0_t, typename Op1_t>
331m_c_VPInstruction(const Op0_t &Op0, const Op1_t &Op1) {
333}
334
335/// BuildVector is matches only its opcode, w/o matching its operands as the
336/// number of operands is not fixed.
340
341/// BuildStructVector matches only its opcode, w/o matching its operands as the
342/// number of operands is not fixed.
347
348template <typename Op0_t>
350m_Freeze(const Op0_t &Op0) {
352}
353
357
358template <typename Op0_t>
360m_BranchOnCond(const Op0_t &Op0) {
362}
363
368
369template <typename Op0_t, typename Op1_t>
371m_BranchOnTwoConds(const Op0_t &Op0, const Op1_t &Op1) {
373}
374
375template <typename Op0_t>
377m_Broadcast(const Op0_t &Op0) {
379}
380
381template <typename Op0_t>
383m_EVL(const Op0_t &Op0) {
385}
386
387template <typename Op0_t>
392
393template <typename Op0_t, typename Op1_t>
395m_ExtractElement(const Op0_t &Op0, const Op1_t &Op1) {
397}
398
399template <typename Op0_t, typename Op1_t, typename Op2_t>
401m_InsertElement(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
403}
404
405template <typename Op0_t, typename Op1_t>
407m_ExtractLane(const Op0_t &Op0, const Op1_t &Op1) {
409}
410
411template <typename Op0_t>
416
417template <typename Op0_t>
423}
424
425template <typename Op0_t>
430
431template <typename Op0_t, typename Op1_t, typename Op2_t>
433m_ActiveLaneMask(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
435}
436
440
441template <typename Op0_t, typename Op1_t>
443m_BranchOnCount(const Op0_t &Op0, const Op1_t &Op1) {
445}
446
450
451template <typename Op0_t>
453m_AnyOf(const Op0_t &Op0) {
455}
456
457template <typename Op0_t>
462
463template <typename Op0_t>
465m_LastActiveLane(const Op0_t &Op0) {
467}
468
469template <typename Op0_t, typename Op1_t, typename Op2_t>
471 Op2_t>
472m_ExtractLastActive(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
474}
475
476template <typename Op0_t>
481
482/// Match FindIV result pattern:
483/// select(icmp ne ComputeReductionResult(ReducedIV), Sentinel),
484/// ComputeReductionResult(ReducedIV), Start.
485template <typename Op0_t, typename Op1_t>
486inline bool matchFindIVResult(VPInstruction *VPI, Op0_t ReducedIV, Op1_t Start) {
488 m_ComputeReductionResult(ReducedIV),
489 m_VPValue()),
490 m_ComputeReductionResult(ReducedIV), Start));
491}
492
493template <typename Op0_t>
495m_Reverse(const Op0_t &Op0) {
497}
498
502
503template <typename Op0_t>
505m_ExitingIVValue(const Op0_t &Op0) {
507}
508
509template <unsigned Opcode, typename Op0_t>
510inline AllRecipe_match<Opcode, Op0_t> m_Unary(const Op0_t &Op0) {
512}
513
514template <typename Op0_t>
518
519template <typename Op0_t>
521m_TruncOrSelf(const Op0_t &Op0) {
522 return m_CombineOr(m_Trunc(Op0), Op0);
523}
524
525template <typename Op0_t>
529
530template <typename Op0_t>
534
535template <typename Op0_t>
539
540template <typename Op0_t>
543m_ZExtOrSExt(const Op0_t &Op0) {
544 return m_CombineOr(m_ZExt(Op0), m_SExt(Op0));
545}
546
547template <typename Op0_t> inline auto m_WidenAnyExtend(const Op0_t &Op0) {
549}
550
551template <typename Op0_t>
553m_ZExtOrSelf(const Op0_t &Op0) {
554 return m_CombineOr(m_ZExt(Op0), Op0);
555}
556
557template <typename Op0_t> inline auto m_ZExtOrTruncOrSelf(const Op0_t &Op0) {
558 return m_CombineOr(m_ZExt(Op0), m_Trunc(Op0), Op0);
559}
560
561template <unsigned Opcode, typename Op0_t, typename Op1_t>
563 const Op1_t &Op1) {
565}
566
567template <unsigned Opcode, typename Op0_t, typename Op1_t>
569m_c_Binary(const Op0_t &Op0, const Op1_t &Op1) {
571}
572
573template <typename Op0_t, typename Op1_t>
575 const Op1_t &Op1) {
577}
578
579template <typename Op0_t, typename Op1_t>
581m_c_Add(const Op0_t &Op0, const Op1_t &Op1) {
583}
584
585template <typename Op0_t, typename Op1_t>
587 const Op1_t &Op1) {
589}
590
591template <typename Op0_t, typename Op1_t>
593 const Op1_t &Op1) {
595}
596
597template <typename Op0_t, typename Op1_t>
599m_c_Mul(const Op0_t &Op0, const Op1_t &Op1) {
601}
602
603template <typename Op0_t, typename Op1_t>
605m_FMul(const Op0_t &Op0, const Op1_t &Op1) {
607}
608
609template <typename Op0_t, typename Op1_t>
611m_FAdd(const Op0_t &Op0, const Op1_t &Op1) {
613}
614
615template <typename Op0_t, typename Op1_t>
617m_c_FAdd(const Op0_t &Op0, const Op1_t &Op1) {
619}
620
621template <typename Op0_t, typename Op1_t>
623m_UDiv(const Op0_t &Op0, const Op1_t &Op1) {
625}
626
627/// Match a binary AND operation.
628template <typename Op0_t, typename Op1_t>
630m_c_BinaryAnd(const Op0_t &Op0, const Op1_t &Op1) {
632}
633
634/// Match a binary OR operation. Note that while conceptually the operands can
635/// be matched commutatively, \p Commutative defaults to false in line with the
636/// IR-based pattern matching infrastructure. Use m_c_BinaryOr for a commutative
637/// version of the matcher.
638template <typename Op0_t, typename Op1_t>
640m_BinaryOr(const Op0_t &Op0, const Op1_t &Op1) {
642}
643
644template <typename Op0_t, typename Op1_t>
646m_c_BinaryOr(const Op0_t &Op0, const Op1_t &Op1) {
648}
649
650/// Cmp_match is a variant of BinaryRecipe_match that also binds the comparison
651/// predicate. Opcodes must either be Instruction::ICmp or Instruction::FCmp, or
652/// both.
653template <typename Op0_t, typename Op1_t, unsigned... Opcodes>
654struct Cmp_match {
655 static_assert((sizeof...(Opcodes) == 1 || sizeof...(Opcodes) == 2) &&
656 "Expected one or two opcodes");
657 static_assert(
658 ((Opcodes == Instruction::ICmp || Opcodes == Instruction::FCmp) && ...) &&
659 "Expected a compare instruction opcode");
660
662 Op0_t Op0;
664
665 Cmp_match(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1)
666 : Predicate(&Pred), Op0(Op0), Op1(Op1) {}
667 Cmp_match(const Op0_t &Op0, const Op1_t &Op1) : Op0(Op0), Op1(Op1) {}
668
669 bool match(const VPValue *V) const {
670 auto *DefR = V->getDefiningRecipe();
671 return DefR && match(DefR);
672 }
673
674 bool match(const VPRecipeBase *V) const {
675 if ((m_Binary<Opcodes>(Op0, Op1).match(V) || ...)) {
676 if (Predicate)
677 *Predicate = cast<VPRecipeWithIRFlags>(V)->getPredicate();
678 return true;
679 }
680 return false;
681 }
682};
683
684/// SpecificCmp_match is a variant of Cmp_match that matches the comparison
685/// predicate, instead of binding it.
686template <typename Op0_t, typename Op1_t, unsigned... Opcodes>
689 Op0_t Op0;
691
692 SpecificCmp_match(CmpPredicate Pred, const Op0_t &LHS, const Op1_t &RHS)
693 : Predicate(Pred), Op0(LHS), Op1(RHS) {}
694
695 bool match(const VPValue *V) const {
696 auto *DefR = V->getDefiningRecipe();
697 return DefR && match(DefR);
698 }
699
700 bool match(const VPRecipeBase *V) const {
701 CmpPredicate CurrentPred;
702 return Cmp_match<Op0_t, Op1_t, Opcodes...>(CurrentPred, Op0, Op1)
703 .match(V) &&
705 }
706};
707
708template <typename Op0_t, typename Op1_t>
710 const Op1_t &Op1) {
712}
713
714template <typename Op0_t, typename Op1_t>
715inline Cmp_match<Op0_t, Op1_t, Instruction::ICmp>
716m_ICmp(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1) {
717 return Cmp_match<Op0_t, Op1_t, Instruction::ICmp>(Pred, Op0, Op1);
718}
719
720template <typename Op0_t, typename Op1_t>
721inline SpecificCmp_match<Op0_t, Op1_t, Instruction::ICmp>
722m_SpecificICmp(CmpPredicate MatchPred, const Op0_t &Op0, const Op1_t &Op1) {
724 Op1);
725}
726
727template <typename Op0_t, typename Op1_t>
728inline Cmp_match<Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp>
729m_Cmp(const Op0_t &Op0, const Op1_t &Op1) {
731 Op1);
732}
733
734template <typename Op0_t, typename Op1_t>
735inline Cmp_match<Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp>
736m_Cmp(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1) {
738 Pred, Op0, Op1);
739}
740
741template <typename Op0_t, typename Op1_t>
742inline SpecificCmp_match<Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp>
743m_SpecificCmp(CmpPredicate MatchPred, const Op0_t &Op0, const Op1_t &Op1) {
745 MatchPred, Op0, Op1);
746}
747
748template <typename Op0_t, typename Op1_t>
749inline auto m_GetElementPtr(const Op0_t &Op0, const Op1_t &Op1) {
750 return m_CombineOr(
751 Recipe_match<std::tuple<Op0_t, Op1_t>, Instruction::GetElementPtr,
752 /*Commutative*/ false, VPReplicateRecipe, VPWidenGEPRecipe>(
753 Op0, Op1),
756}
757
758template <typename Op0_t, typename Op1_t, typename Op2_t>
760m_Select(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
762 {Op0, Op1, Op2});
763}
764
765template <typename Op0_t> inline auto m_Not(const Op0_t &Op0) {
768}
769
770template <typename Op0_t, typename Op1_t, typename Op2_t>
771inline auto m_c_Select(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
772 return m_CombineOr(m_Select(Op0, Op1, Op2), m_Select(m_Not(Op0), Op2, Op1));
773}
774
775template <typename Op0_t, typename Op1_t>
776inline auto m_LogicalAnd(const Op0_t &Op0, const Op1_t &Op1) {
777 return m_CombineOr(
779 m_Select(Op0, Op1, m_False()));
780}
781
782template <typename Op0_t, typename Op1_t>
783inline auto m_c_LogicalAnd(const Op0_t &Op0, const Op1_t &Op1) {
784 return m_CombineOr(
786 m_c_Select(Op0, Op1, m_False()));
787}
788
789template <typename Op0_t, typename Op1_t>
790inline auto m_LogicalOr(const Op0_t &Op0, const Op1_t &Op1) {
791 return m_CombineOr(
793 m_Select(Op0, m_True(), Op1));
794}
795
796template <typename Op0_t, typename Op1_t>
797inline auto m_c_LogicalOr(const Op0_t &Op0, const Op1_t &Op1) {
798 return m_c_Select(Op0, m_True(), Op1);
799}
800
801/// Match the canonical induction variable (IV) of any loop region.
803 template <typename ArgTy> bool match(const ArgTy *V) const {
804 const auto *RV = dyn_cast<VPRegionValue>(V);
805 return RV && RV->getDefiningRegion()->getCanonicalIV() == RV;
806 }
807};
808
809inline canonical_iv_match m_CanonicalIV() { return {}; }
810
811template <typename Op0_t, typename Op1_t, typename Op2_t>
812inline auto m_ScalarIVSteps(const Op0_t &Op0, const Op1_t &Op1,
813 const Op2_t &Op2) {
815 VPScalarIVStepsRecipe>({Op0, Op1, Op2});
816}
817
818template <typename Op0_t, typename Op1_t, typename Op2_t>
819inline auto m_DerivedIV(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
821 VPDerivedIVRecipe>({Op0, Op1, Op2});
822}
823
824template <typename Addr_t, typename Mask_t> struct Load_match {
825 Addr_t Addr;
826 Mask_t Mask;
827
828 Load_match(Addr_t Addr, Mask_t Mask) : Addr(Addr), Mask(Mask) {}
829
830 template <typename OpTy> bool match(const OpTy *V) const {
831 auto *Load = dyn_cast<VPWidenLoadRecipe>(V);
832 if (!Load || !Addr.match(Load->getAddr()) || !Load->isMasked() ||
833 !Mask.match(Load->getMask()))
834 return false;
835 return true;
836 }
837};
838
839/// Match a (possibly reversed) masked load.
840template <typename Addr_t, typename Mask_t>
841inline Load_match<Addr_t, Mask_t> m_MaskedLoad(const Addr_t &Addr,
842 const Mask_t &Mask) {
843 return Load_match<Addr_t, Mask_t>(Addr, Mask);
844}
845
846template <typename Addr_t, typename Val_t, typename Mask_t> struct Store_match {
847 Addr_t Addr;
848 Val_t Val;
849 Mask_t Mask;
850
851 Store_match(Addr_t Addr, Val_t Val, Mask_t Mask)
852 : Addr(Addr), Val(Val), Mask(Mask) {}
853
854 template <typename OpTy> bool match(const OpTy *V) const {
855 auto *Store = dyn_cast<VPWidenStoreRecipe>(V);
856 if (!Store || !Addr.match(Store->getAddr()) ||
857 !Val.match(Store->getStoredValue()) || !Store->isMasked() ||
858 !Mask.match(Store->getMask()))
859 return false;
860 return true;
861 }
862};
863
864/// Match a (possibly reversed) masked store.
865template <typename Addr_t, typename Val_t, typename Mask_t>
866inline Store_match<Addr_t, Val_t, Mask_t>
867m_MaskedStore(const Addr_t &Addr, const Val_t &Val, const Mask_t &Mask) {
868 return Store_match<Addr_t, Val_t, Mask_t>(Addr, Val, Mask);
869}
870
871template <typename Op0_t, typename Op1_t>
874 /*Commutative*/ false, VPVectorEndPointerRecipe>;
875
876template <typename Op0_t, typename Op1_t>
881
882/// Match a call argument at a given argument index.
883template <typename Opnd_t> struct Argument_match {
884 /// Call argument index to match.
885 unsigned OpI;
886 Opnd_t Val;
887
888 Argument_match(unsigned OpIdx, const Opnd_t &V) : OpI(OpIdx), Val(V) {}
889
890 template <typename OpTy> bool match(OpTy *V) const {
891 if (const auto *R = dyn_cast<VPWidenIntrinsicRecipe>(V))
892 return Val.match(R->getOperand(OpI));
893 if (const auto *R = dyn_cast<VPWidenCallRecipe>(V))
894 return Val.match(R->getOperand(OpI));
895 if (const auto *R = dyn_cast<VPReplicateRecipe>(V))
896 if (R->getOpcode() == Instruction::Call)
897 return Val.match(R->getOperand(OpI));
898 if (const auto *R = dyn_cast<VPInstruction>(V))
899 if (R->getOpcode() == Instruction::Call)
900 return Val.match(R->getOperand(OpI));
901 return false;
902 }
903};
904
905/// Match a call argument.
906template <unsigned OpI, typename Opnd_t>
907inline Argument_match<Opnd_t> m_Argument(const Opnd_t &Op) {
908 return Argument_match<Opnd_t>(OpI, Op);
909}
910
911/// Intrinsic matchers.
913 unsigned ID;
914
915 IntrinsicID_match(Intrinsic::ID IntrID) : ID(IntrID) {}
916
917 template <typename OpTy> bool match(OpTy *V) const {
918 if (const auto *R = dyn_cast<VPWidenIntrinsicRecipe>(V))
919 return R->getVectorIntrinsicID() == ID;
920 if (const auto *R = dyn_cast<VPWidenCallRecipe>(V))
921 return R->getCalledScalarFunction()->getIntrinsicID() == ID;
922
923 auto MatchCalleeIntrinsic = [&](VPValue *CalleeOp) {
924 if (!isa<VPIRValue>(CalleeOp))
925 return false;
926 auto *F = cast<Function>(CalleeOp->getLiveInIRValue());
927 return F->getIntrinsicID() == ID;
928 };
929 if (const auto *R = dyn_cast<VPReplicateRecipe>(V))
930 if (R->getOpcode() == Instruction::Call) {
931 // The mask is always the last operand if predicated.
932 return MatchCalleeIntrinsic(
933 R->getOperand(R->getNumOperands() - 1 - R->isPredicated()));
934 }
935 if (const auto *R = dyn_cast<VPInstruction>(V))
936 if (R->getOpcode() == Instruction::Call)
937 return MatchCalleeIntrinsic(R->getOperand(R->getNumOperands() - 1));
938 return false;
939 }
940};
941
942/// Intrinsic matches are combinations of ID matchers, and argument
943/// matchers. Higher arity matcher are defined recursively in terms of and-ing
944/// them with lower arity matchers. Here's some convenient typedefs for up to
945/// several arguments, and more can be added as needed
946template <typename T0 = void, typename T1 = void, typename T2 = void,
947 typename T3 = void>
948struct m_Intrinsic_Ty;
949template <typename T0> struct m_Intrinsic_Ty<T0> {
951};
952template <typename T0, typename T1> struct m_Intrinsic_Ty<T0, T1> {
953 using Ty =
955};
956template <typename T0, typename T1, typename T2>
961template <typename T0, typename T1, typename T2, typename T3>
966
967/// Match intrinsic calls like this:
968/// m_Intrinsic<Intrinsic::fabs>(m_VPValue(X), ...)
969template <Intrinsic::ID IntrID> inline IntrinsicID_match m_Intrinsic() {
970 return IntrinsicID_match(IntrID);
971}
972
973/// Match intrinsic calls with a runtime intrinsic ID.
975 return IntrinsicID_match(IntrID);
976}
977
978template <Intrinsic::ID IntrID, typename T0>
979inline typename m_Intrinsic_Ty<T0>::Ty m_Intrinsic(const T0 &Op0) {
981}
982
983template <Intrinsic::ID IntrID, typename T0, typename T1>
984inline typename m_Intrinsic_Ty<T0, T1>::Ty m_Intrinsic(const T0 &Op0,
985 const T1 &Op1) {
987}
988
989template <Intrinsic::ID IntrID, typename T0, typename T1, typename T2>
990inline typename m_Intrinsic_Ty<T0, T1, T2>::Ty
991m_Intrinsic(const T0 &Op0, const T1 &Op1, const T2 &Op2) {
992 return m_CombineAnd(m_Intrinsic<IntrID>(Op0, Op1), m_Argument<2>(Op2));
993}
994
995template <Intrinsic::ID IntrID, typename T0, typename T1, typename T2,
996 typename T3>
998m_Intrinsic(const T0 &Op0, const T1 &Op1, const T2 &Op2, const T3 &Op3) {
999 return m_CombineAnd(m_Intrinsic<IntrID>(Op0, Op1, Op2), m_Argument<3>(Op3));
1000}
1001
1002template <Intrinsic::ID IntrID, typename... T>
1003inline auto m_WidenIntrinsic(const T &...Ops) {
1005}
1006
1008
1009/// Match a GEP recipe (VPWidenGEPRecipe, VPInstruction, or VPReplicateRecipe)
1010/// and bind the source element type and operands.
1014
1017
1018 template <typename ITy> bool match(ITy *V) const {
1019 return matchRecipeAndBind<VPWidenGEPRecipe>(V) ||
1020 matchRecipeAndBind<VPInstruction>(V) ||
1021 matchRecipeAndBind<VPReplicateRecipe>(V);
1022 }
1023
1024private:
1025 template <typename RecipeTy> bool matchRecipeAndBind(const VPValue *V) const {
1026 auto *DefR = dyn_cast<RecipeTy>(V);
1027 if (!DefR)
1028 return false;
1029
1030 if constexpr (std::is_same_v<RecipeTy, VPWidenGEPRecipe>) {
1031 SourceElementType = DefR->getSourceElementType();
1032 } else if (DefR->getOpcode() == Instruction::GetElementPtr) {
1033 SourceElementType = cast<GetElementPtrInst>(DefR->getUnderlyingInstr())
1034 ->getSourceElementType();
1035 } else if constexpr (std::is_same_v<RecipeTy, VPInstruction>) {
1036 if (DefR->getOpcode() == VPInstruction::PtrAdd) {
1037 // PtrAdd is a byte-offset GEP with i8 element type.
1038 LLVMContext &Ctx = DefR->getParent()->getPlan()->getContext();
1040 } else {
1041 return false;
1042 }
1043 } else {
1044 return false;
1045 }
1046
1047 Operands = ArrayRef<VPValue *>(DefR->op_begin(), DefR->op_end());
1048 return true;
1049 }
1050};
1051
1052/// Match a GEP recipe with any number of operands and bind source element type
1053/// and operands.
1054inline GetElementPtr_match m_GetElementPtr(Type *&SourceElementType,
1055 ArrayRef<VPValue *> &Operands) {
1056 return GetElementPtr_match(SourceElementType, Operands);
1057}
1058
1059template <typename SubPattern_t> struct OneUse_match {
1060 SubPattern_t SubPattern;
1061
1062 OneUse_match(const SubPattern_t &SP) : SubPattern(SP) {}
1063
1064 template <typename OpTy> bool match(OpTy *V) const {
1065 return V->hasOneUse() && SubPattern.match(V);
1066 }
1067};
1068
1069template <typename T> inline OneUse_match<T> m_OneUse(const T &SubPattern) {
1070 return SubPattern;
1071}
1072
1075 return V;
1076}
1077
1078template <typename Op0_t, typename Op1_t>
1079inline auto m_VPPhi(const Op0_t &Op0, const Op1_t &Op1) {
1080 return Recipe_match<std::tuple<Op0_t, Op1_t>, Instruction::PHI,
1081 /*Commutative*/ false, VPInstruction>({Op0, Op1});
1082}
1083
1084} // namespace llvm::VPlanPatternMatch
1085
1086#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
#define F(x, y, z)
Definition MD5.cpp:54
#define T
MachineInstr unsigned OpIdx
#define P(N)
This file contains the declarations of the Vectorization Plan base classes:
Class for arbitrary precision integers.
Definition APInt.h:78
std::optional< uint64_t > tryZExtValue() const
Get zero extended value if possible.
Definition APInt.h:1575
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...
Definition APInt.h:555
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
@ ICMP_NE
not equal
Definition InstrTypes.h:698
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...
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
static LLVM_ABI IntegerType * getInt8Ty(LLVMContext &C)
Definition Type.cpp:311
A recipe for converting the input value IV value to the corresponding value of an IV with different s...
Definition VPlan.h:3895
This is a concrete Recipe that models a single VPlan-level instruction.
Definition VPlan.h:1226
@ ExtractLastActive
Extracts the last active lane from a set of vectors.
Definition VPlan.h:1332
VPRecipeBase is a base class modeling a sequence of one or more output IR instructions.
Definition VPlan.h:405
A recipe for handling reduction phis.
Definition VPlan.h:2685
VPReplicateRecipe replicates a given instruction producing multiple scalar copies of the original sca...
Definition VPlan.h:3194
A recipe for handling phi nodes of integer and floating-point inductions, producing their scalar valu...
Definition VPlan.h:3966
VPSingleDef is a base class for recipes for modeling a sequence of one or more output IR that define ...
Definition VPlan.h:609
This class augments VPValue with operands which provide the inverse def-use edges from VPValue's user...
Definition VPlanValue.h:329
This is the base class of the VPlan Def/Use graph, used for modeling the data flow into,...
Definition VPlanValue.h:49
A recipe to compute a pointer to the last element of each part of a widened memory access for widened...
Definition VPlan.h:2150
VPWidenCastRecipe is a recipe to create vector cast instructions.
Definition VPlan.h:1836
A recipe for handling GEP instructions.
Definition VPlan.h:2086
VPWidenRecipe is a recipe for producing a widened instruction using the opcode and operands of the re...
Definition VPlan.h:1780
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
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.
auto m_Cmp()
Matches any compare instruction and ignore it.
auto m_LogicalOr()
Matches L || R where L and R are arbitrary values.
auto m_LogicalAnd()
Matches L && R where L and R are arbitrary values.
auto m_ConstantInt()
Match an arbitrary ConstantInt and ignore it.
VPInstruction_match< VPInstruction::ExtractLastLane, VPInstruction_match< VPInstruction::ExtractLastPart, Op0_t > > m_ExtractLastLaneOfLastPart(const Op0_t &Op0)
AllRecipe_match< Instruction::Select, Op0_t, Op1_t, Op2_t > m_Select(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
VPInstruction_match< Instruction::Freeze, Op0_t > m_Freeze(const Op0_t &Op0)
AllRecipe_commutative_match< Instruction::And, Op0_t, Op1_t > m_c_BinaryAnd(const Op0_t &Op0, const Op1_t &Op1)
Match a binary AND operation.
AllRecipe_match< Instruction::ZExt, Op0_t > m_ZExt(const Op0_t &Op0)
AllRecipe_match< Instruction::Or, Op0_t, Op1_t > m_BinaryOr(const Op0_t &Op0, const Op1_t &Op1)
Match a binary OR operation.
int_pred_ty< is_specific_int, Bitwidth > specific_intval
Store_match< Addr_t, Val_t, Mask_t > m_MaskedStore(const Addr_t &Addr, const Val_t &Val, const Mask_t &Mask)
Match a (possibly reversed) masked store.
int_pred_ty< is_zero_int > m_ZeroInt()
Match an integer 0 or a vector with all elements equal to 0.
AllRecipe_match< Instruction::FMul, Op0_t, Op1_t > m_FMul(const Op0_t &Op0, const Op1_t &Op1)
SpecificCmp_match< Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp > m_SpecificCmp(CmpPredicate MatchPred, const Op0_t &Op0, const Op1_t &Op1)
VPInstruction_match< VPInstruction::AnyOf > m_AnyOf()
int_pred_ty< is_all_ones > m_AllOnes()
Match an integer or vector with all bits set.
AllRecipe_commutative_match< Opcode, Op0_t, Op1_t > m_c_Binary(const Op0_t &Op0, const Op1_t &Op1)
AllRecipe_commutative_match< Instruction::Add, Op0_t, Op1_t > m_c_Add(const Op0_t &Op0, const Op1_t &Op1)
AllRecipe_commutative_match< Instruction::Or, Op0_t, Op1_t > m_c_BinaryOr(const Op0_t &Op0, const Op1_t &Op1)
bool matchFindIVResult(VPInstruction *VPI, Op0_t ReducedIV, Op1_t Start)
Match FindIV result pattern: select(icmp ne ComputeReductionResult(ReducedIV), Sentinel),...
VPInstruction_match< VPInstruction::ComputeReductionResult, Op0_t > m_ComputeReductionResult(const Op0_t &Op0)
auto m_WidenAnyExtend(const Op0_t &Op0)
match_bind< VPIRValue > m_VPIRValue(VPIRValue *&V)
Match a VPIRValue.
VPInstruction_match< VPInstruction::StepVector > m_StepVector()
auto m_c_LogicalOr(const Op0_t &Op0, const Op1_t &Op1)
match_deferred< VPValue > m_Deferred(VPValue *const &V)
Like m_Specific(), but works if the specific value to match is determined as part of the same match()...
match_combine_or< AllRecipe_match< Instruction::ZExt, Op0_t >, AllRecipe_match< Instruction::SExt, Op0_t > > m_ZExtOrSExt(const Op0_t &Op0)
auto m_VPPhi(const Op0_t &Op0, const Op1_t &Op1)
SpecificCmp_match< Op0_t, Op1_t, Instruction::ICmp > m_SpecificICmp(CmpPredicate MatchPred, const Op0_t &Op0, const Op1_t &Op1)
AllRecipe_match< Instruction::Add, Op0_t, Op1_t > m_Add(const Op0_t &Op0, const Op1_t &Op1)
match_poison m_Poison()
Match a VPIRValue that's poison.
auto m_c_Select(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
Recipe_match< std::tuple< OpTys... >, Opcode, false, VPInstruction > VPInstruction_match
VPInstruction_match< VPInstruction::BranchOnTwoConds > m_BranchOnTwoConds()
VPInstruction_match< Instruction::InsertElement, Op0_t, Op1_t, Op2_t > m_InsertElement(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
AllRecipe_match< Opcode, Op0_t, Op1_t > m_Binary(const Op0_t &Op0, const Op1_t &Op1)
auto match_fn(const Pattern &P)
A match functor that can be used as a UnaryPredicate in functional algorithms like all_of.
VPInstruction_match< VPInstruction::LastActiveLane, Op0_t > m_LastActiveLane(const Op0_t &Op0)
AllRecipe_match< Opcode, Op0_t > m_Unary(const Op0_t &Op0)
auto m_WidenIntrinsic(const T &...Ops)
Recipe_match< std::tuple< OpTys... >, Opcode, true, VPInstruction > VPInstruction_commutative_match
AllRecipe_commutative_match< Instruction::FAdd, Op0_t, Op1_t > m_c_FAdd(const Op0_t &Op0, const Op1_t &Op1)
Load_match< Addr_t, Mask_t > m_MaskedLoad(const Addr_t &Addr, const Mask_t &Mask)
Match a (possibly reversed) masked load.
VPInstruction_match< VPInstruction::ExtractLastActive, Op0_t, Op1_t, Op2_t > m_ExtractLastActive(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
match_combine_or< AllRecipe_match< Instruction::Trunc, Op0_t >, Op0_t > m_TruncOrSelf(const Op0_t &Op0)
AllRecipe_match< Instruction::FPExt, Op0_t > m_FPExt(const Op0_t &Op0)
AllRecipe_commutative_match< Instruction::Mul, Op0_t, Op1_t > m_c_Mul(const Op0_t &Op0, const Op1_t &Op1)
Cmp_match< Op0_t, Op1_t, Instruction::ICmp > m_ICmp(const Op0_t &Op0, const Op1_t &Op1)
AllRecipe_match< Instruction::Mul, Op0_t, Op1_t > m_Mul(const Op0_t &Op0, const Op1_t &Op1)
specificval_ty m_Specific(const VPValue *VPV)
VPInstruction_match< VPInstruction::ExitingIVValue, Op0_t > m_ExitingIVValue(const Op0_t &Op0)
VPInstruction_match< Instruction::ExtractElement, Op0_t, Op1_t > m_ExtractElement(const Op0_t &Op0, const Op1_t &Op1)
specific_intval< 1 > m_False()
VPInstruction_match< VPInstruction::ExtractLastLane, Op0_t > m_ExtractLastLane(const Op0_t &Op0)
specific_intval< 0 > m_SpecificInt(uint64_t V)
VPInstruction_match< VPInstruction::ActiveLaneMask, Op0_t, Op1_t, Op2_t > m_ActiveLaneMask(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
match_bind< VPSingleDefRecipe > m_VPSingleDefRecipe(VPSingleDefRecipe *&V)
Match a VPSingleDefRecipe, capturing if we match.
VPInstruction_match< VPInstruction::BranchOnCount > m_BranchOnCount()
auto m_GetElementPtr(const Op0_t &Op0, const Op1_t &Op1)
auto m_ZExtOrTruncOrSelf(const Op0_t &Op0)
AllRecipe_match< Instruction::Sub, Op0_t, Op1_t > m_Sub(const Op0_t &Op0, const Op1_t &Op1)
canonical_iv_match m_CanonicalIV()
AllRecipe_match< Instruction::SExt, Op0_t > m_SExt(const Op0_t &Op0)
VPInstruction_commutative_match< Opcode, Op0_t, Op1_t > m_c_VPInstruction(const Op0_t &Op0, const Op1_t &Op1)
specific_intval< 1 > m_True()
auto m_VPValue()
Match an arbitrary VPValue and ignore it.
IntrinsicID_match m_Intrinsic()
Match intrinsic calls like this: m_Intrinsic<Intrinsic::fabs>(m_VPValue(X), ...)
Recipe_match< std::tuple< OpTys... >, Opcode, true, VPWidenRecipe, VPReplicateRecipe, VPInstruction > AllRecipe_commutative_match
specific_intval< 0 > m_SpecificSInt(int64_t V)
AllRecipe_match< Instruction::FAdd, Op0_t, Op1_t > m_FAdd(const Op0_t &Op0, const Op1_t &Op1)
VectorEndPointerRecipe_match< Op0_t, Op1_t > m_VecEndPtr(const Op0_t &Op0, const Op1_t &Op1)
VPInstruction_match< VPInstruction::ExtractLastPart, Op0_t > m_ExtractLastPart(const Op0_t &Op0)
VPInstruction_match< VPInstruction::Broadcast, Op0_t > m_Broadcast(const Op0_t &Op0)
bool match(Val *V, const Pattern &P)
OneUse_match< T > m_OneUse(const T &SubPattern)
VPInstruction_match< VPInstruction::ExplicitVectorLength, Op0_t > m_EVL(const Op0_t &Op0)
VPInstruction_match< VPInstruction::BuildVector > m_BuildVector()
BuildVector is matches only its opcode, w/o matching its operands as the number of operands is not fi...
AllRecipe_match< Instruction::Trunc, Op0_t > m_Trunc(const Op0_t &Op0)
VPInstruction_match< VPInstruction::ExtractPenultimateElement, Op0_t > m_ExtractPenultimateElement(const Op0_t &Op0)
Recipe_match< std::tuple< Op0_t, Op1_t >, 0, false, VPVectorEndPointerRecipe > VectorEndPointerRecipe_match
match_bind< VPInstruction > m_VPInstruction(VPInstruction *&V)
Match a VPInstruction, capturing if we match.
match_combine_or< AllRecipe_match< Instruction::ZExt, Op0_t >, Op0_t > m_ZExtOrSelf(const Op0_t &Op0)
VPInstruction_match< VPInstruction::FirstActiveLane, Op0_t > m_FirstActiveLane(const Op0_t &Op0)
Argument_match< Opnd_t > m_Argument(const Opnd_t &Op)
Match a call argument.
AllRecipe_match< Instruction::UDiv, Op0_t, Op1_t > m_UDiv(const Op0_t &Op0, const Op1_t &Op1)
auto m_Not(const Op0_t &Op0)
auto m_DerivedIV(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
auto m_c_LogicalAnd(const Op0_t &Op0, const Op1_t &Op1)
int_pred_ty< is_one > m_One()
Match an integer 1 or a vector with all elements equal to 1.
Recipe_match< std::tuple< OpTys... >, Opcode, false, VPWidenRecipe, VPReplicateRecipe, VPWidenCastRecipe, VPInstruction > AllRecipe_match
VPInstruction_match< VPInstruction::BranchOnCond > m_BranchOnCond()
match_bind< VPReductionPHIRecipe > m_ReductionPhi(VPReductionPHIRecipe *&V)
auto m_ScalarIVSteps(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
VPInstruction_match< VPInstruction::ExtractLane, Op0_t, Op1_t > m_ExtractLane(const Op0_t &Op0, const Op1_t &Op1)
VPInstruction_match< VPInstruction::BuildStructVector > m_BuildStructVector()
BuildStructVector matches only its opcode, w/o matching its operands as the number of operands is not...
bind_apint m_APInt(const APInt *&C)
VPInstruction_match< VPInstruction::Reverse, Op0_t > m_Reverse(const Op0_t &Op0)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
constexpr auto bind_back(FnT &&Fn, BindArgsT &&...BindArgs)
C++23 bind_back.
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...
Definition Casting.h:547
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
constexpr unsigned BitWidth
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1916
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:874
Matcher to bind the captured value.
Matcher for a specific value, but stores a reference to the value, not the value itself.
Intrinsic matches are combinations of ID matchers, and argument matchers.
A VPValue representing a live-in from the input IR or a constant.
Definition VPlanValue.h:240
Match a call argument at a given argument index.
unsigned OpI
Call argument index to match.
Argument_match(unsigned OpIdx, const Opnd_t &V)
Cmp_match is a variant of BinaryRecipe_match that also binds the comparison predicate.
Cmp_match(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1)
Cmp_match(const Op0_t &Op0, const Op1_t &Op1)
bool match(const VPValue *V) const
bool match(const VPRecipeBase *V) const
Match a GEP recipe (VPWidenGEPRecipe, VPInstruction, or VPReplicateRecipe) and bind the source elemen...
GetElementPtr_match(Type *&SourceElementType, ArrayRef< VPValue * > &Operands)
Load_match(Addr_t Addr, Mask_t Mask)
bool match(const VPSingleDefRecipe *R) const
bool match(const VPValue *V) const
bool match(const VPRecipeBase *R) const
SpecificCmp_match is a variant of Cmp_match that matches the comparison predicate,...
SpecificCmp_match(CmpPredicate Pred, const Op0_t &LHS, const Op1_t &RHS)
bool match(const VPRecipeBase *V) const
Store_match(Addr_t Addr, Val_t Val, Mask_t Mask)
bool match(const VPValue *VPV) const
bool match(const VPValue *VPV) const
Match the canonical induction variable (IV) of any loop region.
Match an integer constant if Pred::isValue returns true for the APInt.
bool match(const VPValue *VPV) const
bool isValue(const APInt &C) const
Match a specified signed or unsigned integer value.
is_specific_int(APInt Val, bool IsSigned=false)
match_combine_and< typename m_Intrinsic_Ty< T0, T1 >::Ty, Argument_match< T2 > > Ty
match_combine_and< typename m_Intrinsic_Ty< T0 >::Ty, Argument_match< T1 > > Ty
match_combine_and< IntrinsicID_match, Argument_match< T0 > > Ty
Intrinsic matches are combinations of ID matchers, and argument matchers.
match_combine_and< typename m_Intrinsic_Ty< T0, T1, T2 >::Ty, Argument_match< T3 > > Ty
bool match(const VPValue *V) const
bool match(const VPValue *VPV) const