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
52template <typename Class> struct bind_ty {
53 Class *&VR;
54
55 bind_ty(Class *&V) : VR(V) {}
56
57 template <typename ITy> bool match(ITy *V) const {
58 if (auto *CV = dyn_cast<Class>(V)) {
59 VR = CV;
60 return true;
61 }
62 return false;
63 }
64};
65
66/// Match a specified VPValue.
68 const VPValue *Val;
69
70 specificval_ty(const VPValue *V) : Val(V) {}
71
72 bool match(const VPValue *VPV) const { return VPV == Val; }
73};
74
75inline specificval_ty m_Specific(const VPValue *VPV) { return VPV; }
76
77/// Stores a reference to the VPValue *, not the VPValue * itself,
78/// thus can be used in commutative matchers.
80 VPValue *const &Val;
81
82 deferredval_ty(VPValue *const &V) : Val(V) {}
83
84 bool match(const VPValue *const V) const { return V == Val; }
85};
86
87/// Like m_Specific(), but works if the specific value to match is determined
88/// as part of the same match() expression. For example:
89/// m_Mul(m_VPValue(X), m_Specific(X)) is incorrect, because m_Specific() will
90/// bind X before the pattern match starts.
91/// m_Mul(m_VPValue(X), m_Deferred(X)) is correct, and will check against
92/// whichever value m_VPValue(X) populated.
93inline deferredval_ty m_Deferred(VPValue *const &V) { return V; }
94
95/// Match an integer constant if Pred::isValue returns true for the APInt. \p
96/// BitWidth optionally specifies the bitwidth the matched constant must have.
97/// If it is 0, the matched constant can have any bitwidth.
98template <typename Pred, unsigned BitWidth = 0> struct int_pred_ty {
99 Pred P;
100
101 int_pred_ty(Pred P) : P(std::move(P)) {}
102 int_pred_ty() : P() {}
103
104 bool match(const VPValue *VPV) const {
105 auto *VPI = dyn_cast<VPInstruction>(VPV);
106 if (VPI && VPI->getOpcode() == VPInstruction::Broadcast)
107 VPV = VPI->getOperand(0);
108 auto *CI = dyn_cast<VPConstantInt>(VPV);
109 if (!CI)
110 return false;
111
112 if (BitWidth != 0 && CI->getBitWidth() != BitWidth)
113 return false;
114 return P.isValue(CI->getAPInt());
115 }
116};
117
118/// Match a specified signed or unsigned integer value.
122
125
126 bool isValue(const APInt &C) const {
128 }
129};
130
131template <unsigned Bitwidth = 0>
133
137
139 return specific_intval<0>(
140 is_specific_int(APInt(64, V, /*isSigned=*/true), /*IsSigned=*/true));
141}
142
146
150
152 bool isValue(const APInt &C) const { return C.isAllOnes(); }
153};
154
155/// Match an integer or vector with all bits set.
156/// For vectors, this includes constants with undefined elements.
160
162 bool isValue(const APInt &C) const { return C.isZero(); }
163};
164
165struct is_one {
166 bool isValue(const APInt &C) const { return C.isOne(); }
167};
168
169/// Match an integer 0 or a vector with all elements equal to 0.
170/// For vectors, this includes constants with undefined elements.
174
175/// Match an integer 1 or a vector with all elements equal to 1.
176/// For vectors, this includes constants with undefined elements.
178
180 const APInt *&Res;
181
182 bind_apint(const APInt *&Res) : Res(Res) {}
183
184 bool match(const VPValue *VPV) const {
185 auto *CI = dyn_cast<VPConstantInt>(VPV);
186 if (!CI)
187 return false;
188 Res = &CI->getAPInt();
189 return true;
190 }
191};
192
193inline bind_apint m_APInt(const APInt *&C) { return C; }
194
197
199
200 bool match(const VPValue *VPV) const {
201 const APInt *APConst;
202 if (!bind_apint(APConst).match(VPV))
203 return false;
204 if (auto C = APConst->tryZExtValue()) {
205 Res = *C;
206 return true;
207 }
208 return false;
209 }
210};
211
213 bool match(const VPValue *V) const {
214 return isa<VPIRValue>(V) &&
215 isa<PoisonValue>(cast<VPIRValue>(V)->getValue());
216 }
217};
218
219/// Match a VPIRValue that's poison.
220inline match_poison m_Poison() { return match_poison(); }
221
222/// Match a plain integer constant no wider than 64-bits, capturing it if we
223/// match.
225
226/// Match a VPValue, capturing it if we match.
227inline bind_ty<VPValue> m_VPValue(VPValue *&V) { return V; }
228
229/// Match a VPIRValue.
230inline bind_ty<VPIRValue> m_VPIRValue(VPIRValue *&V) { return V; }
231
232/// Match a VPSingleDefRecipe, capturing if we match.
236
237/// Match a VPInstruction, capturing if we match.
239
240template <typename Ops_t, unsigned Opcode, bool Commutative,
241 typename... RecipeTys>
243 Ops_t Ops;
244
245 template <typename... OpTy> Recipe_match(OpTy... Ops) : Ops(Ops...) {
246 static_assert(std::tuple_size<Ops_t>::value == sizeof...(Ops) &&
247 "number of operands in constructor doesn't match Ops_t");
248 static_assert((!Commutative || std::tuple_size<Ops_t>::value == 2) &&
249 "only binary ops can be commutative");
250 }
251
252 bool match(const VPValue *V) const {
253 auto *DefR = V->getDefiningRecipe();
254 return DefR && match(DefR);
255 }
256
257 bool match(const VPSingleDefRecipe *R) const {
258 return match(static_cast<const VPRecipeBase *>(R));
259 }
260
261 bool match(const VPRecipeBase *R) const {
262 if (std::tuple_size_v<Ops_t> == 0) {
263 auto *VPI = dyn_cast<VPInstruction>(R);
264 return VPI && VPI->getOpcode() == Opcode;
265 }
266
267 if ((!matchRecipeAndOpcode<RecipeTys>(R) && ...))
268 return false;
269
270 if (R->getNumOperands() < std::tuple_size<Ops_t>::value) {
271 [[maybe_unused]] auto *RepR = dyn_cast<VPReplicateRecipe>(R);
273 cast<VPInstruction>(R)->getNumOperandsForOpcode() == -1u) ||
274 (RepR && std::tuple_size_v<Ops_t> ==
275 RepR->getNumOperands() - RepR->isPredicated())) &&
276 "non-variadic recipe with matched opcode does not have the "
277 "expected number of operands");
278 return false;
279 }
280
281 // If the recipe has more operands than expected, we only support matching
282 // masked VPInstructions where the number of operands of the matcher is the
283 // same as the number of operands excluding mask.
284 if (R->getNumOperands() > std::tuple_size<Ops_t>::value) {
285 auto *VPI = dyn_cast<VPInstruction>(R);
286 if (!VPI || !VPI->isMasked() ||
287 VPI->getNumOperandsWithoutMask() != std::tuple_size<Ops_t>::value)
288 return false;
289 }
290
291 auto IdxSeq = std::make_index_sequence<std::tuple_size<Ops_t>::value>();
292 if (all_of_tuple_elements(IdxSeq, [R](auto Op, unsigned Idx) {
293 return Op.match(R->getOperand(Idx));
294 }))
295 return true;
296
297 return Commutative &&
298 all_of_tuple_elements(IdxSeq, [R](auto Op, unsigned Idx) {
299 return Op.match(R->getOperand(R->getNumOperands() - Idx - 1));
300 });
301 }
302
303private:
304 template <typename RecipeTy>
305 static bool matchRecipeAndOpcode(const VPRecipeBase *R) {
306 auto *DefR = dyn_cast<RecipeTy>(R);
307 // Check for recipes that do not have opcodes.
308 if constexpr (std::is_same_v<RecipeTy, VPScalarIVStepsRecipe> ||
309 std::is_same_v<RecipeTy, VPCanonicalIVPHIRecipe> ||
310 std::is_same_v<RecipeTy, VPDerivedIVRecipe> ||
311 std::is_same_v<RecipeTy, VPVectorEndPointerRecipe>)
312 return DefR;
313 else
314 return DefR && DefR->getOpcode() == Opcode;
315 }
316
317 /// Helper to check if predicate \p P holds on all tuple elements in Ops using
318 /// the provided index sequence.
319 template <typename Fn, std::size_t... Is>
320 bool all_of_tuple_elements(std::index_sequence<Is...>, Fn P) const {
321 return (P(std::get<Is>(Ops), Is) && ...);
322 }
323};
324
325template <unsigned Opcode, typename... OpTys>
327 Recipe_match<std::tuple<OpTys...>, Opcode, /*Commutative*/ false,
330
331template <unsigned Opcode, typename... OpTys>
333 Recipe_match<std::tuple<OpTys...>, Opcode, /*Commutative*/ true,
335
336template <unsigned Opcode, typename... OpTys>
337using VPInstruction_match = Recipe_match<std::tuple<OpTys...>, Opcode,
338 /*Commutative*/ false, VPInstruction>;
339
340template <unsigned Opcode, typename... OpTys>
342 Recipe_match<std::tuple<OpTys...>, Opcode,
343 /*Commutative*/ true, VPInstruction>;
344
345template <unsigned Opcode, typename... OpTys>
346inline VPInstruction_match<Opcode, OpTys...>
347m_VPInstruction(const OpTys &...Ops) {
348 return VPInstruction_match<Opcode, OpTys...>(Ops...);
349}
350
351template <unsigned Opcode, typename Op0_t, typename Op1_t>
353m_c_VPInstruction(const Op0_t &Op0, const Op1_t &Op1) {
355}
356
357/// BuildVector is matches only its opcode, w/o matching its operands as the
358/// number of operands is not fixed.
362
363template <typename Op0_t>
365m_Freeze(const Op0_t &Op0) {
367}
368
372
373template <typename Op0_t>
375m_BranchOnCond(const Op0_t &Op0) {
377}
378
383
384template <typename Op0_t, typename Op1_t>
386m_BranchOnTwoConds(const Op0_t &Op0, const Op1_t &Op1) {
388}
389
390template <typename Op0_t>
392m_Broadcast(const Op0_t &Op0) {
394}
395
396template <typename Op0_t>
398m_EVL(const Op0_t &Op0) {
400}
401
402template <typename Op0_t>
407
408template <typename Op0_t, typename Op1_t>
410m_ExtractElement(const Op0_t &Op0, const Op1_t &Op1) {
412}
413
414template <typename Op0_t, typename Op1_t>
416m_ExtractLane(const Op0_t &Op0, const Op1_t &Op1) {
418}
419
420template <typename Op0_t>
425
426template <typename Op0_t>
432}
433
434template <typename Op0_t>
439
440template <typename Op0_t, typename Op1_t, typename Op2_t>
442m_ActiveLaneMask(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
444}
445
449
450template <typename Op0_t, typename Op1_t>
452m_BranchOnCount(const Op0_t &Op0, const Op1_t &Op1) {
454}
455
459
460template <typename Op0_t>
462m_AnyOf(const Op0_t &Op0) {
464}
465
466template <typename Op0_t>
471
472template <typename Op0_t>
474m_LastActiveLane(const Op0_t &Op0) {
476}
477
478template <typename Op0_t, typename Op1_t, typename Op2_t>
480 Op2_t>
481m_ExtractLastActive(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
483}
484
485template <typename Op0_t>
490
491/// Match FindIV result pattern:
492/// select(icmp ne ComputeReductionResult(ReducedIV), Sentinel),
493/// ComputeReductionResult(ReducedIV), Start.
494template <typename Op0_t, typename Op1_t>
495inline bool matchFindIVResult(VPInstruction *VPI, Op0_t ReducedIV, Op1_t Start) {
497 m_ComputeReductionResult(ReducedIV),
498 m_VPValue()),
499 m_ComputeReductionResult(ReducedIV), Start));
500}
501
502template <typename Op0_t, typename Op1_t, typename Op2_t>
504 Op2_t>
505m_ComputeAnyOfResult(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
507}
508
509template <typename Op0_t>
511m_Reverse(const Op0_t &Op0) {
513}
514
518
519template <typename Op0_t>
521m_ExitingIVValue(const Op0_t &Op0) {
523}
524
525template <unsigned Opcode, typename Op0_t>
526inline AllRecipe_match<Opcode, Op0_t> m_Unary(const Op0_t &Op0) {
528}
529
530template <typename Op0_t>
534
535template <typename Op0_t>
537m_TruncOrSelf(const Op0_t &Op0) {
538 return m_CombineOr(m_Trunc(Op0), Op0);
539}
540
541template <typename Op0_t>
545
546template <typename Op0_t>
550
551template <typename Op0_t>
555
556template <typename Op0_t>
559m_ZExtOrSExt(const Op0_t &Op0) {
560 return m_CombineOr(m_ZExt(Op0), m_SExt(Op0));
561}
562
563template <typename Op0_t> inline auto m_WidenAnyExtend(const Op0_t &Op0) {
565}
566
567template <typename Op0_t>
569m_ZExtOrSelf(const Op0_t &Op0) {
570 return m_CombineOr(m_ZExt(Op0), Op0);
571}
572
573template <typename Op0_t> inline auto m_ZExtOrTruncOrSelf(const Op0_t &Op0) {
574 return m_CombineOr(m_ZExt(Op0), m_Trunc(Op0), Op0);
575}
576
577template <unsigned Opcode, typename Op0_t, typename Op1_t>
579 const Op1_t &Op1) {
581}
582
583template <unsigned Opcode, typename Op0_t, typename Op1_t>
585m_c_Binary(const Op0_t &Op0, const Op1_t &Op1) {
587}
588
589template <typename Op0_t, typename Op1_t>
591 const Op1_t &Op1) {
593}
594
595template <typename Op0_t, typename Op1_t>
597m_c_Add(const Op0_t &Op0, const Op1_t &Op1) {
599}
600
601template <typename Op0_t, typename Op1_t>
603 const Op1_t &Op1) {
605}
606
607template <typename Op0_t, typename Op1_t>
609 const Op1_t &Op1) {
611}
612
613template <typename Op0_t, typename Op1_t>
615m_c_Mul(const Op0_t &Op0, const Op1_t &Op1) {
617}
618
619template <typename Op0_t, typename Op1_t>
621m_FMul(const Op0_t &Op0, const Op1_t &Op1) {
623}
624
625template <typename Op0_t, typename Op1_t>
627m_FAdd(const Op0_t &Op0, const Op1_t &Op1) {
629}
630
631template <typename Op0_t, typename Op1_t>
633m_c_FAdd(const Op0_t &Op0, const Op1_t &Op1) {
635}
636
637template <typename Op0_t, typename Op1_t>
639m_UDiv(const Op0_t &Op0, const Op1_t &Op1) {
641}
642
643/// Match a binary AND operation.
644template <typename Op0_t, typename Op1_t>
646m_c_BinaryAnd(const Op0_t &Op0, const Op1_t &Op1) {
648}
649
650/// Match a binary OR operation. Note that while conceptually the operands can
651/// be matched commutatively, \p Commutative defaults to false in line with the
652/// IR-based pattern matching infrastructure. Use m_c_BinaryOr for a commutative
653/// version of the matcher.
654template <typename Op0_t, typename Op1_t>
656m_BinaryOr(const Op0_t &Op0, const Op1_t &Op1) {
658}
659
660template <typename Op0_t, typename Op1_t>
662m_c_BinaryOr(const Op0_t &Op0, const Op1_t &Op1) {
664}
665
666/// Cmp_match is a variant of BinaryRecipe_match that also binds the comparison
667/// predicate. Opcodes must either be Instruction::ICmp or Instruction::FCmp, or
668/// both.
669template <typename Op0_t, typename Op1_t, unsigned... Opcodes>
670struct Cmp_match {
671 static_assert((sizeof...(Opcodes) == 1 || sizeof...(Opcodes) == 2) &&
672 "Expected one or two opcodes");
673 static_assert(
674 ((Opcodes == Instruction::ICmp || Opcodes == Instruction::FCmp) && ...) &&
675 "Expected a compare instruction opcode");
676
678 Op0_t Op0;
680
681 Cmp_match(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1)
682 : Predicate(&Pred), Op0(Op0), Op1(Op1) {}
683 Cmp_match(const Op0_t &Op0, const Op1_t &Op1) : Op0(Op0), Op1(Op1) {}
684
685 bool match(const VPValue *V) const {
686 auto *DefR = V->getDefiningRecipe();
687 return DefR && match(DefR);
688 }
689
690 bool match(const VPRecipeBase *V) const {
691 if ((m_Binary<Opcodes>(Op0, Op1).match(V) || ...)) {
692 if (Predicate)
693 *Predicate = cast<VPRecipeWithIRFlags>(V)->getPredicate();
694 return true;
695 }
696 return false;
697 }
698};
699
700/// SpecificCmp_match is a variant of Cmp_match that matches the comparison
701/// predicate, instead of binding it.
702template <typename Op0_t, typename Op1_t, unsigned... Opcodes>
705 Op0_t Op0;
707
708 SpecificCmp_match(CmpPredicate Pred, const Op0_t &LHS, const Op1_t &RHS)
709 : Predicate(Pred), Op0(LHS), Op1(RHS) {}
710
711 bool match(const VPValue *V) const {
712 auto *DefR = V->getDefiningRecipe();
713 return DefR && match(DefR);
714 }
715
716 bool match(const VPRecipeBase *V) const {
717 CmpPredicate CurrentPred;
718 return Cmp_match<Op0_t, Op1_t, Opcodes...>(CurrentPred, Op0, Op1)
719 .match(V) &&
721 }
722};
723
724template <typename Op0_t, typename Op1_t>
726 const Op1_t &Op1) {
728}
729
730template <typename Op0_t, typename Op1_t>
731inline Cmp_match<Op0_t, Op1_t, Instruction::ICmp>
732m_ICmp(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1) {
733 return Cmp_match<Op0_t, Op1_t, Instruction::ICmp>(Pred, Op0, Op1);
734}
735
736template <typename Op0_t, typename Op1_t>
737inline SpecificCmp_match<Op0_t, Op1_t, Instruction::ICmp>
738m_SpecificICmp(CmpPredicate MatchPred, const Op0_t &Op0, const Op1_t &Op1) {
740 Op1);
741}
742
743template <typename Op0_t, typename Op1_t>
744inline Cmp_match<Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp>
745m_Cmp(const Op0_t &Op0, const Op1_t &Op1) {
747 Op1);
748}
749
750template <typename Op0_t, typename Op1_t>
751inline Cmp_match<Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp>
752m_Cmp(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1) {
754 Pred, Op0, Op1);
755}
756
757template <typename Op0_t, typename Op1_t>
758inline SpecificCmp_match<Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp>
759m_SpecificCmp(CmpPredicate MatchPred, const Op0_t &Op0, const Op1_t &Op1) {
761 MatchPred, Op0, Op1);
762}
763
764template <typename Op0_t, typename Op1_t>
765inline auto m_GetElementPtr(const Op0_t &Op0, const Op1_t &Op1) {
766 return m_CombineOr(
767 Recipe_match<std::tuple<Op0_t, Op1_t>, Instruction::GetElementPtr,
768 /*Commutative*/ false, VPReplicateRecipe, VPWidenGEPRecipe>(
769 Op0, Op1),
772}
773
774template <typename Op0_t, typename Op1_t, typename Op2_t>
776m_Select(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
778 {Op0, Op1, Op2});
779}
780
781template <typename Op0_t> inline auto m_Not(const Op0_t &Op0) {
784}
785
786template <typename Op0_t, typename Op1_t, typename Op2_t>
787inline auto m_c_Select(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
788 return m_CombineOr(m_Select(Op0, Op1, Op2), m_Select(m_Not(Op0), Op2, Op1));
789}
790
791template <typename Op0_t, typename Op1_t>
792inline auto m_LogicalAnd(const Op0_t &Op0, const Op1_t &Op1) {
793 return m_CombineOr(
795 m_Select(Op0, Op1, m_False()));
796}
797
798template <typename Op0_t, typename Op1_t>
799inline auto m_c_LogicalAnd(const Op0_t &Op0, const Op1_t &Op1) {
800 return m_CombineOr(
802 m_c_Select(Op0, Op1, m_False()));
803}
804
805template <typename Op0_t, typename Op1_t>
806inline auto m_LogicalOr(const Op0_t &Op0, const Op1_t &Op1) {
807 return m_CombineOr(
809 m_Select(Op0, m_True(), Op1));
810}
811
812template <typename Op0_t, typename Op1_t>
813inline auto m_c_LogicalOr(const Op0_t &Op0, const Op1_t &Op1) {
814 return m_c_Select(Op0, m_True(), Op1);
815}
816
818
819template <typename Op0_t, typename Op1_t, typename Op2_t>
820inline auto m_ScalarIVSteps(const Op0_t &Op0, const Op1_t &Op1,
821 const Op2_t &Op2) {
823 VPScalarIVStepsRecipe>({Op0, Op1, Op2});
824}
825
826template <typename Op0_t, typename Op1_t, typename Op2_t>
827inline auto m_DerivedIV(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
829 VPDerivedIVRecipe>({Op0, Op1, Op2});
830}
831
832template <typename Addr_t, typename Mask_t> struct Load_match {
833 Addr_t Addr;
834 Mask_t Mask;
835
836 Load_match(Addr_t Addr, Mask_t Mask) : Addr(Addr), Mask(Mask) {}
837
838 template <typename OpTy> bool match(const OpTy *V) const {
839 auto *Load = dyn_cast<VPWidenLoadRecipe>(V);
840 if (!Load || !Addr.match(Load->getAddr()) || !Load->isMasked() ||
841 !Mask.match(Load->getMask()))
842 return false;
843 return true;
844 }
845};
846
847/// Match a (possibly reversed) masked load.
848template <typename Addr_t, typename Mask_t>
849inline Load_match<Addr_t, Mask_t> m_MaskedLoad(const Addr_t &Addr,
850 const Mask_t &Mask) {
851 return Load_match<Addr_t, Mask_t>(Addr, Mask);
852}
853
854template <typename Addr_t, typename Val_t, typename Mask_t> struct Store_match {
855 Addr_t Addr;
856 Val_t Val;
857 Mask_t Mask;
858
859 Store_match(Addr_t Addr, Val_t Val, Mask_t Mask)
860 : Addr(Addr), Val(Val), Mask(Mask) {}
861
862 template <typename OpTy> bool match(const OpTy *V) const {
863 auto *Store = dyn_cast<VPWidenStoreRecipe>(V);
864 if (!Store || !Addr.match(Store->getAddr()) ||
865 !Val.match(Store->getStoredValue()) || !Store->isMasked() ||
866 !Mask.match(Store->getMask()))
867 return false;
868 return true;
869 }
870};
871
872/// Match a (possibly reversed) masked store.
873template <typename Addr_t, typename Val_t, typename Mask_t>
874inline Store_match<Addr_t, Val_t, Mask_t>
875m_MaskedStore(const Addr_t &Addr, const Val_t &Val, const Mask_t &Mask) {
876 return Store_match<Addr_t, Val_t, Mask_t>(Addr, Val, Mask);
877}
878
879template <typename Op0_t, typename Op1_t>
882 /*Commutative*/ false, VPVectorEndPointerRecipe>;
883
884template <typename Op0_t, typename Op1_t>
889
890/// Match a call argument at a given argument index.
891template <typename Opnd_t> struct Argument_match {
892 /// Call argument index to match.
893 unsigned OpI;
894 Opnd_t Val;
895
896 Argument_match(unsigned OpIdx, const Opnd_t &V) : OpI(OpIdx), Val(V) {}
897
898 template <typename OpTy> bool match(OpTy *V) const {
899 if (const auto *R = dyn_cast<VPWidenIntrinsicRecipe>(V))
900 return Val.match(R->getOperand(OpI));
901 if (const auto *R = dyn_cast<VPWidenCallRecipe>(V))
902 return Val.match(R->getOperand(OpI));
903 if (const auto *R = dyn_cast<VPReplicateRecipe>(V))
904 if (R->getOpcode() == Instruction::Call)
905 return Val.match(R->getOperand(OpI));
906 if (const auto *R = dyn_cast<VPInstruction>(V))
907 if (R->getOpcode() == Instruction::Call)
908 return Val.match(R->getOperand(OpI));
909 return false;
910 }
911};
912
913/// Match a call argument.
914template <unsigned OpI, typename Opnd_t>
915inline Argument_match<Opnd_t> m_Argument(const Opnd_t &Op) {
916 return Argument_match<Opnd_t>(OpI, Op);
917}
918
919/// Intrinsic matchers.
921 unsigned ID;
922
923 IntrinsicID_match(Intrinsic::ID IntrID) : ID(IntrID) {}
924
925 template <typename OpTy> bool match(OpTy *V) const {
926 if (const auto *R = dyn_cast<VPWidenIntrinsicRecipe>(V))
927 return R->getVectorIntrinsicID() == ID;
928 if (const auto *R = dyn_cast<VPWidenCallRecipe>(V))
929 return R->getCalledScalarFunction()->getIntrinsicID() == ID;
930
931 auto MatchCalleeIntrinsic = [&](VPValue *CalleeOp) {
932 if (!isa<VPIRValue>(CalleeOp))
933 return false;
934 auto *F = cast<Function>(CalleeOp->getLiveInIRValue());
935 return F->getIntrinsicID() == ID;
936 };
937 if (const auto *R = dyn_cast<VPReplicateRecipe>(V))
938 if (R->getOpcode() == Instruction::Call) {
939 // The mask is always the last operand if predicated.
940 return MatchCalleeIntrinsic(
941 R->getOperand(R->getNumOperands() - 1 - R->isPredicated()));
942 }
943 if (const auto *R = dyn_cast<VPInstruction>(V))
944 if (R->getOpcode() == Instruction::Call)
945 return MatchCalleeIntrinsic(R->getOperand(R->getNumOperands() - 1));
946 return false;
947 }
948};
949
950/// Intrinsic matches are combinations of ID matchers, and argument
951/// matchers. Higher arity matcher are defined recursively in terms of and-ing
952/// them with lower arity matchers. Here's some convenient typedefs for up to
953/// several arguments, and more can be added as needed
954template <typename T0 = void, typename T1 = void, typename T2 = void,
955 typename T3 = void>
956struct m_Intrinsic_Ty;
957template <typename T0> struct m_Intrinsic_Ty<T0> {
959};
960template <typename T0, typename T1> struct m_Intrinsic_Ty<T0, T1> {
961 using Ty =
963};
964template <typename T0, typename T1, typename T2>
969template <typename T0, typename T1, typename T2, typename T3>
974
975/// Match intrinsic calls like this:
976/// m_Intrinsic<Intrinsic::fabs>(m_VPValue(X), ...)
977template <Intrinsic::ID IntrID> inline IntrinsicID_match m_Intrinsic() {
978 return IntrinsicID_match(IntrID);
979}
980
981/// Match intrinsic calls with a runtime intrinsic ID.
983 return IntrinsicID_match(IntrID);
984}
985
986template <Intrinsic::ID IntrID, typename T0>
987inline typename m_Intrinsic_Ty<T0>::Ty m_Intrinsic(const T0 &Op0) {
989}
990
991template <Intrinsic::ID IntrID, typename T0, typename T1>
992inline typename m_Intrinsic_Ty<T0, T1>::Ty m_Intrinsic(const T0 &Op0,
993 const T1 &Op1) {
995}
996
997template <Intrinsic::ID IntrID, typename T0, typename T1, typename T2>
998inline typename m_Intrinsic_Ty<T0, T1, T2>::Ty
999m_Intrinsic(const T0 &Op0, const T1 &Op1, const T2 &Op2) {
1000 return m_CombineAnd(m_Intrinsic<IntrID>(Op0, Op1), m_Argument<2>(Op2));
1001}
1002
1003template <Intrinsic::ID IntrID, typename T0, typename T1, typename T2,
1004 typename T3>
1006m_Intrinsic(const T0 &Op0, const T1 &Op1, const T2 &Op2, const T3 &Op3) {
1007 return m_CombineAnd(m_Intrinsic<IntrID>(Op0, Op1, Op2), m_Argument<3>(Op3));
1008}
1009
1011
1012/// Match a GEP recipe (VPWidenGEPRecipe, VPInstruction, or VPReplicateRecipe)
1013/// and bind the source element type and operands.
1017
1020
1021 template <typename ITy> bool match(ITy *V) const {
1022 return matchRecipeAndBind<VPWidenGEPRecipe>(V) ||
1023 matchRecipeAndBind<VPInstruction>(V) ||
1024 matchRecipeAndBind<VPReplicateRecipe>(V);
1025 }
1026
1027private:
1028 template <typename RecipeTy> bool matchRecipeAndBind(const VPValue *V) const {
1029 auto *DefR = dyn_cast<RecipeTy>(V);
1030 if (!DefR)
1031 return false;
1032
1033 if constexpr (std::is_same_v<RecipeTy, VPWidenGEPRecipe>) {
1034 SourceElementType = DefR->getSourceElementType();
1035 } else if (DefR->getOpcode() == Instruction::GetElementPtr) {
1036 SourceElementType = cast<GetElementPtrInst>(DefR->getUnderlyingInstr())
1037 ->getSourceElementType();
1038 } else if constexpr (std::is_same_v<RecipeTy, VPInstruction>) {
1039 if (DefR->getOpcode() == VPInstruction::PtrAdd) {
1040 // PtrAdd is a byte-offset GEP with i8 element type.
1041 LLVMContext &Ctx = DefR->getParent()->getPlan()->getContext();
1043 } else {
1044 return false;
1045 }
1046 } else {
1047 return false;
1048 }
1049
1050 Operands = ArrayRef<VPValue *>(DefR->op_begin(), DefR->op_end());
1051 return true;
1052 }
1053};
1054
1055/// Match a GEP recipe with any number of operands and bind source element type
1056/// and operands.
1057inline GetElementPtr_match m_GetElementPtr(Type *&SourceElementType,
1058 ArrayRef<VPValue *> &Operands) {
1059 return GetElementPtr_match(SourceElementType, Operands);
1060}
1061
1062template <typename SubPattern_t> struct OneUse_match {
1063 SubPattern_t SubPattern;
1064
1065 OneUse_match(const SubPattern_t &SP) : SubPattern(SP) {}
1066
1067 template <typename OpTy> bool match(OpTy *V) {
1068 return V->hasOneUse() && SubPattern.match(V);
1069 }
1070};
1071
1072template <typename T> inline OneUse_match<T> m_OneUse(const T &SubPattern) {
1073 return SubPattern;
1074}
1075
1079
1080template <typename Op0_t, typename Op1_t>
1081inline auto m_VPPhi(const Op0_t &Op0, const Op1_t &Op1) {
1082 return Recipe_match<std::tuple<Op0_t, Op1_t>, Instruction::PHI,
1083 /*Commutative*/ false, VPInstruction>({Op0, Op1});
1084}
1085
1086} // namespace llvm::VPlanPatternMatch
1087
1088#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:1567
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
ArrayRef - 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:4001
This is a concrete Recipe that models a single VPlan-level instruction.
Definition VPlan.h:1225
@ ExtractLastActive
Extracts the last active lane from a set of vectors.
Definition VPlan.h:1336
@ ComputeAnyOfResult
Compute the final result of a AnyOf reduction with select(cmp(),x,y), where one of (x,...
Definition VPlan.h:1272
VPRecipeBase is a base class modeling a sequence of one or more output IR instructions.
Definition VPlan.h:406
A recipe for handling reduction phis.
Definition VPlan.h:2700
VPReplicateRecipe replicates a given instruction producing multiple scalar copies of the original sca...
Definition VPlan.h:3217
A recipe for handling phi nodes of integer and floating-point inductions, producing their scalar valu...
Definition VPlan.h:4073
VPSingleDef is a base class for recipes for modeling a sequence of one or more output IR that define ...
Definition VPlan.h:607
This class augments VPValue with operands which provide the inverse def-use edges from VPValue's user...
Definition VPlanValue.h:296
This is the base class of the VPlan Def/Use graph, used for modeling the data flow into,...
Definition VPlanValue.h:46
A recipe to compute a pointer to the last element of each part of a widened memory access for widened...
Definition VPlan.h:2154
VPWidenCastRecipe is a recipe to create vector cast instructions.
Definition VPlan.h:1840
A recipe for handling GEP instructions.
Definition VPlan.h:2090
VPWidenRecipe is a recipe for producing a widened instruction using the opcode and operands of the re...
Definition VPlan.h:1784
@ 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)
VPInstruction_match< VPInstruction::StepVector > m_StepVector()
auto m_c_LogicalOr(const Op0_t &Op0, const Op1_t &Op1)
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.
bind_ty< VPSingleDefRecipe > m_VPSingleDefRecipe(VPSingleDefRecipe *&V)
Match a VPSingleDefRecipe, capturing if we match.
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()
AllRecipe_match< Opcode, Op0_t, Op1_t > m_Binary(const Op0_t &Op0, const Op1_t &Op1)
bind_ty< VPReductionPHIRecipe > m_ReductionPhi(VPReductionPHIRecipe *&V)
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)
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)
VPInstruction_match< VPInstruction::BranchOnCount > m_BranchOnCount()
bind_ty< VPIRValue > m_VPIRValue(VPIRValue *&V)
Match a VPIRValue.
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)
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)
deferredval_ty m_Deferred(VPValue *const &V)
Like m_Specific(), but works if the specific value to match is determined as part of the same match()...
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_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.
bind_ty< VPInstruction > m_VPInstruction(VPInstruction *&V)
Match a VPInstruction, capturing if we match.
VPInstruction_match< VPInstruction::ComputeAnyOfResult, Op0_t, Op1_t, Op2_t > m_ComputeAnyOfResult(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
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()
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)
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:1917
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:870
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:207
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
Stores a reference to the VPValue *, not the VPValue * itself, thus can be used in commutative matche...
bool match(const VPValue *const V) const
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