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"
19#include "VPlanUtils.h"
21
22using namespace llvm::PatternMatchHelpers;
23
25
26template <typename Val, typename Pattern> bool match(Val *V, const Pattern &P) {
27 return P.match(V);
28}
29
30/// A match functor that can be used as a UnaryPredicate in functional
31/// algorithms like all_of.
32template <typename Val, typename Pattern> auto match_fn(const Pattern &P) {
34}
35
36template <typename Pattern> bool match(VPUser *U, const Pattern &P) {
37 auto *R = dyn_cast<VPRecipeBase>(U);
38 return R && match(R, P);
39}
40
41/// Match functor for VPUser.
42template <typename Pattern> auto match_fn(const Pattern &P) {
44}
45
46template <typename Pattern> bool match(VPSingleDefRecipe *R, const Pattern &P) {
47 return P.match(static_cast<const VPRecipeBase *>(R));
48}
49
50/// Match an arbitrary VPValue and ignore it.
51inline auto m_VPValue() { return m_Isa<VPValue>(); }
52
53/// Match a specified VPValue.
55 const VPValue *Val;
56
57 specificval_ty(const VPValue *V) : Val(V) {}
58
59 bool match(const VPValue *VPV) const { return VPV == Val; }
60};
61
62inline specificval_ty m_Specific(const VPValue *VPV) { return VPV; }
63
64/// Like m_Specific(), but works if the specific value to match is determined
65/// as part of the same match() expression. For example:
66/// m_Mul(m_VPValue(X), m_Specific(X)) is incorrect, because m_Specific() will
67/// bind X before the pattern match starts.
68/// m_Mul(m_VPValue(X), m_Deferred(X)) is correct, and will check against
69/// whichever value m_VPValue(X) populated.
70inline match_deferred<VPValue> m_Deferred(VPValue *const &V) { return V; }
71
72/// Match an integer constant if Pred::isValue returns true for the APInt. \p
73/// BitWidth optionally specifies the bitwidth the matched constant must have.
74/// If it is 0, the matched constant can have any bitwidth.
75template <typename Pred, unsigned BitWidth = 0> struct int_pred_ty {
76 Pred P;
77
78 int_pred_ty(Pred P) : P(std::move(P)) {}
79 int_pred_ty() : P() {}
80
81 bool match(const VPValue *VPV) const {
82 auto *VPI = dyn_cast<VPInstruction>(VPV);
83 if (VPI && VPI->getOpcode() == VPInstruction::Broadcast)
84 VPV = VPI->getOperand(0);
85 auto *CI = dyn_cast<VPConstantInt>(VPV);
86 if (!CI)
87 return false;
88
89 if (BitWidth != 0 && CI->getBitWidth() != BitWidth)
90 return false;
91 return P.isValue(CI->getAPInt());
92 }
93};
94
95/// Match a specified signed or unsigned integer value.
99
102
103 bool isValue(const APInt &C) const {
105 }
106};
107
108template <unsigned Bitwidth = 0>
110
114
116 return specific_intval<0>(
117 is_specific_int(APInt(64, V, /*isSigned=*/true), /*IsSigned=*/true));
118}
119
123
127
129 bool isValue(const APInt &C) const { return C.isAllOnes(); }
130};
131
132/// Match an integer or vector with all bits set.
133/// For vectors, this includes constants with undefined elements.
137
139 bool isValue(const APInt &C) const { return C.isZero(); }
140};
141
142struct is_one {
143 bool isValue(const APInt &C) const { return C.isOne(); }
144};
145
146/// Match an integer 0 or a vector with all elements equal to 0.
147/// For vectors, this includes constants with undefined elements.
151
152/// Match an integer 1 or a vector with all elements equal to 1.
153/// For vectors, this includes constants with undefined elements.
155
157 const APInt *&Res;
158
159 bind_apint(const APInt *&Res) : Res(Res) {}
160
161 bool match(const VPValue *VPV) const {
162 auto *CI = dyn_cast<VPConstantInt>(VPV);
163 if (!CI)
164 return false;
165 Res = &CI->getAPInt();
166 return true;
167 }
168};
169
170inline bind_apint m_APInt(const APInt *&C) { return C; }
171
174
176
177 bool match(const VPValue *VPV) const {
178 const APInt *APConst;
179 if (!bind_apint(APConst).match(VPV))
180 return false;
181 if (auto C = APConst->tryZExtValue()) {
182 Res = *C;
183 return true;
184 }
185 return false;
186 }
187};
188
190 bool match(const VPValue *V) const {
191 return isa<VPIRValue>(V) &&
193 }
194};
195
196/// Match a VPIRValue that's poison.
197inline match_poison m_Poison() { return match_poison(); }
198
199/// Match a plain integer constant no wider than 64-bits, capturing it if we
200/// match.
202
203/// Match a VPValue, capturing it if we match.
204inline match_bind<VPValue> m_VPValue(VPValue *&V) { return V; }
205
206/// Match a VPIRValue.
208
209/// Match a VPSingleDefRecipe, capturing if we match.
212 return V;
213}
214
215/// Match a VPInstruction, capturing if we match.
219
220template <typename Ops_t, unsigned Opcode, bool Commutative,
221 typename... RecipeTys>
223 Ops_t Ops;
224
225 template <typename... OpTy> Recipe_match(OpTy... Ops) : Ops(Ops...) {
226 static_assert(std::tuple_size<Ops_t>::value == sizeof...(Ops) &&
227 "number of operands in constructor doesn't match Ops_t");
228 static_assert((!Commutative || std::tuple_size<Ops_t>::value == 2) &&
229 "only binary ops can be commutative");
230 }
231
232 bool match(const VPValue *V) const {
233 auto *DefR = V->getDefiningRecipe();
234 return DefR && match(DefR);
235 }
236
237 bool match(const VPSingleDefRecipe *R) const {
238 return match(static_cast<const VPRecipeBase *>(R));
239 }
240
241 bool match(const VPRecipeBase *R) const {
242 if (std::tuple_size_v<Ops_t> == 0) {
243 auto *VPI = dyn_cast<VPInstruction>(R);
244 return VPI && VPI->getOpcode() == Opcode;
245 }
246
247 if ((!matchRecipeAndOpcode<RecipeTys>(R) && ...))
248 return false;
249
250 if (R->getNumOperands() < std::tuple_size<Ops_t>::value) {
251 [[maybe_unused]] auto *RepR = dyn_cast<VPReplicateRecipe>(R);
253 cast<VPInstruction>(R)->getNumOperandsForOpcode() == -1u) ||
254 (RepR && std::tuple_size_v<Ops_t> ==
255 RepR->getNumOperandsWithoutMask())) &&
256 "non-variadic recipe with matched opcode does not have the "
257 "expected number of operands");
258 return false;
259 }
260
261 // If the recipe has more operands than expected, we only support matching
262 // masked VPInstructions or predicated VPReplicateRecipes, where the number
263 // of operands of the matcher matches the number of operands excluding the
264 // mask.
265 if (R->getNumOperands() > std::tuple_size<Ops_t>::value) {
266 if (auto *VPI = dyn_cast<VPInstruction>(R)) {
267 if (!VPI->isMasked() ||
268 VPI->getNumOperandsWithoutMask() != std::tuple_size<Ops_t>::value)
269 return false;
270 } else if (auto *RepR = dyn_cast<VPReplicateRecipe>(R)) {
271 if (!RepR->isPredicated() ||
272 RepR->getNumOperandsWithoutMask() != std::tuple_size<Ops_t>::value)
273 return false;
274 } else {
275 return false;
276 }
277 }
278
279 auto IdxSeq = std::make_index_sequence<std::tuple_size<Ops_t>::value>();
280 if (all_of_tuple_elements(IdxSeq, [R](auto Op, unsigned Idx) {
281 return Op.match(R->getOperand(Idx));
282 }))
283 return true;
284
285 return Commutative &&
286 all_of_tuple_elements(IdxSeq, [R](auto Op, unsigned Idx) {
287 return Op.match(R->getOperand(R->getNumOperands() - Idx - 1));
288 });
289 }
290
291private:
292 template <typename RecipeTy>
293 static bool matchRecipeAndOpcode(const VPRecipeBase *R) {
294 auto *DefR = dyn_cast<RecipeTy>(R);
295 // Check for recipes that do not have opcodes.
296 if constexpr (std::is_same_v<RecipeTy, VPScalarIVStepsRecipe> ||
297 std::is_same_v<RecipeTy, VPDerivedIVRecipe> ||
298 std::is_same_v<RecipeTy, VPVectorEndPointerRecipe>)
299 return DefR;
300 else
301 return DefR && DefR->getOpcode() == Opcode;
302 }
303
304 /// Helper to check if predicate \p P holds on all tuple elements in Ops using
305 /// the provided index sequence.
306 template <typename Fn, std::size_t... Is>
307 bool all_of_tuple_elements(std::index_sequence<Is...>,
308 [[maybe_unused]] Fn P) const {
309 return (P(std::get<Is>(Ops), Is) && ...);
310 }
311};
312
313template <unsigned Opcode, typename... OpTys>
315 Recipe_match<std::tuple<OpTys...>, Opcode, /*Commutative*/ false,
318
319template <unsigned Opcode, typename... OpTys>
321 Recipe_match<std::tuple<OpTys...>, Opcode, /*Commutative*/ true,
323
324template <unsigned Opcode, typename... OpTys>
325using VPInstruction_match = Recipe_match<std::tuple<OpTys...>, Opcode,
326 /*Commutative*/ false, VPInstruction>;
327
328template <unsigned Opcode, typename... OpTys>
330 Recipe_match<std::tuple<OpTys...>, Opcode,
331 /*Commutative*/ true, VPInstruction>;
332
333template <unsigned Opcode, typename... OpTys>
334inline VPInstruction_match<Opcode, OpTys...>
335m_VPInstruction(const OpTys &...Ops) {
336 return VPInstruction_match<Opcode, OpTys...>(Ops...);
337}
338
339template <unsigned Opcode, typename Op0_t, typename Op1_t>
341m_c_VPInstruction(const Op0_t &Op0, const Op1_t &Op1) {
343}
344
345/// BuildVector is matches only its opcode, w/o matching its operands as the
346/// number of operands is not fixed.
350
351/// BuildStructVector matches only its opcode, w/o matching its operands as the
352/// number of operands is not fixed.
357
358template <typename Op0_t>
360m_Freeze(const Op0_t &Op0) {
362}
363
367
368template <typename Op0_t>
370m_BranchOnCond(const Op0_t &Op0) {
372}
373
378
379template <typename Op0_t, typename Op1_t>
381m_BranchOnTwoConds(const Op0_t &Op0, const Op1_t &Op1) {
383}
384
385template <typename Op0_t>
387m_Broadcast(const Op0_t &Op0) {
389}
390
391template <typename Op0_t>
393m_EVL(const Op0_t &Op0) {
395}
396
397template <typename Op0_t>
402
403template <typename Op0_t, typename Op1_t>
405m_ExtractElement(const Op0_t &Op0, const Op1_t &Op1) {
407}
408
409template <typename Op0_t, typename Op1_t, typename Op2_t>
411m_InsertElement(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
413}
414
415template <typename Op0_t, typename Op1_t>
417m_ExtractLane(const Op0_t &Op0, const Op1_t &Op1) {
419}
420
421template <typename Op0_t>
426
427template <typename Op0_t>
433}
434
435template <typename Op0_t>
440
441template <typename Op0_t, typename Op1_t, typename Op2_t>
443m_ActiveLaneMask(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
445}
446
450
451template <typename Op0_t, typename Op1_t>
453m_BranchOnCount(const Op0_t &Op0, const Op1_t &Op1) {
455}
456
460
461template <typename Op0_t>
463m_AnyOf(const Op0_t &Op0) {
465}
466
467template <typename Op0_t>
472
473template <typename Op0_t>
475m_LastActiveLane(const Op0_t &Op0) {
477}
478
479template <typename Op0_t, typename Op1_t, typename Op2_t>
481 Op2_t>
482m_ExtractLastActive(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
484}
485
486template <typename Op0_t>
491
492/// Match FindIV result pattern:
493/// select(icmp ne ComputeReductionResult(ReducedIV), Sentinel),
494/// ComputeReductionResult(ReducedIV), Start.
495template <typename Op0_t, typename Op1_t>
496inline bool matchFindIVResult(VPInstruction *VPI, Op0_t ReducedIV, Op1_t Start) {
498 m_ComputeReductionResult(ReducedIV),
499 m_VPValue()),
500 m_ComputeReductionResult(ReducedIV), Start));
501}
502
503template <typename Op0_t>
505m_Reverse(const Op0_t &Op0) {
507}
508
512
513template <typename Op0_t>
515m_ExitingIVValue(const Op0_t &Op0) {
517}
518
519template <unsigned Opcode, typename Op0_t>
520inline AllRecipe_match<Opcode, Op0_t> m_Unary(const Op0_t &Op0) {
522}
523
524template <typename Op0_t>
528
529template <typename Op0_t>
531m_TruncOrSelf(const Op0_t &Op0) {
532 return m_CombineOr(m_Trunc(Op0), Op0);
533}
534
535template <typename Op0_t>
539
540template <typename Op0_t>
544
545template <typename Op0_t>
549
550template <typename Op0_t>
554
555template <typename Op0_t>
558m_ZExtOrSExt(const Op0_t &Op0) {
559 return m_CombineOr(m_ZExt(Op0), m_SExt(Op0));
560}
561
562template <typename Op0_t> inline auto m_WidenAnyExtend(const Op0_t &Op0) {
564}
565
566template <typename Op0_t> inline auto m_AnyNeg(const Op0_t &Op0) {
567 return m_CombineOr(m_Sub(m_ZeroInt(), Op0), m_FNeg(Op0));
568}
569
570template <typename Op0_t>
572m_ZExtOrSelf(const Op0_t &Op0) {
573 return m_CombineOr(m_ZExt(Op0), Op0);
574}
575
576template <typename Op0_t> inline auto m_ZExtOrTruncOrSelf(const Op0_t &Op0) {
577 return m_CombineOr(m_ZExt(Op0), m_Trunc(Op0), Op0);
578}
579
580template <unsigned Opcode, typename Op0_t, typename Op1_t>
582 const Op1_t &Op1) {
584}
585
586template <unsigned Opcode, typename Op0_t, typename Op1_t>
588m_c_Binary(const Op0_t &Op0, const Op1_t &Op1) {
590}
591
592template <typename Op0_t, typename Op1_t>
594 const Op1_t &Op1) {
596}
597
598template <typename Op0_t, typename Op1_t>
600m_c_Add(const Op0_t &Op0, const Op1_t &Op1) {
602}
603
604template <typename Op0_t, typename Op1_t>
606 const Op1_t &Op1) {
608}
609
610template <typename Op0_t, typename Op1_t>
612 const Op1_t &Op1) {
614}
615
616template <typename Op0_t, typename Op1_t>
618m_c_Mul(const Op0_t &Op0, const Op1_t &Op1) {
620}
621
622template <typename Op0_t, typename Op1_t>
624 const Op1_t &Op1) {
626}
627
628template <typename Op0_t, typename Op1_t>
630m_LShr(const Op0_t &Op0, const Op1_t &Op1) {
632}
633
634template <typename Op0_t, typename Op1_t>
636m_FMul(const Op0_t &Op0, const Op1_t &Op1) {
638}
639
640template <typename Op0_t, typename Op1_t>
642m_FAdd(const Op0_t &Op0, const Op1_t &Op1) {
644}
645
646template <typename Op0_t, typename Op1_t>
648m_c_FAdd(const Op0_t &Op0, const Op1_t &Op1) {
650}
651
652template <typename Op0_t, typename Op1_t>
654m_UDiv(const Op0_t &Op0, const Op1_t &Op1) {
656}
657
658template <typename Op0_t, typename Op1_t>
660m_URem(const Op0_t &Op0, const Op1_t &Op1) {
662}
663
664/// Match a binary AND operation.
665template <typename Op0_t, typename Op1_t>
667m_c_BinaryAnd(const Op0_t &Op0, const Op1_t &Op1) {
669}
670
671/// Match a binary OR operation. Note that while conceptually the operands can
672/// be matched commutatively, \p Commutative defaults to false in line with the
673/// IR-based pattern matching infrastructure. Use m_c_BinaryOr for a commutative
674/// version of the matcher.
675template <typename Op0_t, typename Op1_t>
677m_BinaryOr(const Op0_t &Op0, const Op1_t &Op1) {
679}
680
681template <typename Op0_t, typename Op1_t>
683m_c_BinaryOr(const Op0_t &Op0, const Op1_t &Op1) {
685}
686
687/// Cmp_match is a variant of BinaryRecipe_match that also binds the comparison
688/// predicate. Opcodes must either be Instruction::ICmp or Instruction::FCmp, or
689/// both.
690template <typename Op0_t, typename Op1_t, unsigned... Opcodes>
691struct Cmp_match {
692 static_assert((sizeof...(Opcodes) == 1 || sizeof...(Opcodes) == 2) &&
693 "Expected one or two opcodes");
694 static_assert(
695 ((Opcodes == Instruction::ICmp || Opcodes == Instruction::FCmp) && ...) &&
696 "Expected a compare instruction opcode");
697
699 Op0_t Op0;
701
702 Cmp_match(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1)
703 : Predicate(&Pred), Op0(Op0), Op1(Op1) {}
704 Cmp_match(const Op0_t &Op0, const Op1_t &Op1) : Op0(Op0), Op1(Op1) {}
705
706 bool match(const VPValue *V) const {
707 auto *DefR = V->getDefiningRecipe();
708 return DefR && match(DefR);
709 }
710
711 bool match(const VPRecipeBase *V) const {
712 if ((m_Binary<Opcodes>(Op0, Op1).match(V) || ...)) {
713 if (Predicate)
714 *Predicate = cast<VPRecipeWithIRFlags>(V)->getPredicate();
715 return true;
716 }
717 return false;
718 }
719};
720
721/// SpecificCmp_match is a variant of Cmp_match that matches the comparison
722/// predicate, instead of binding it.
723template <typename Op0_t, typename Op1_t, unsigned... Opcodes>
726 Op0_t Op0;
728
729 SpecificCmp_match(CmpPredicate Pred, const Op0_t &LHS, const Op1_t &RHS)
730 : Predicate(Pred), Op0(LHS), Op1(RHS) {}
731
732 bool match(const VPValue *V) const {
733 auto *DefR = V->getDefiningRecipe();
734 return DefR && match(DefR);
735 }
736
737 bool match(const VPRecipeBase *V) const {
738 CmpPredicate CurrentPred;
739 return Cmp_match<Op0_t, Op1_t, Opcodes...>(CurrentPred, Op0, Op1)
740 .match(V) &&
742 }
743};
744
745template <typename Op0_t, typename Op1_t>
747 const Op1_t &Op1) {
749}
750
751template <typename Op0_t, typename Op1_t>
752inline Cmp_match<Op0_t, Op1_t, Instruction::ICmp>
753m_ICmp(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1) {
754 return Cmp_match<Op0_t, Op1_t, Instruction::ICmp>(Pred, Op0, Op1);
755}
756
757template <typename Op0_t, typename Op1_t>
758inline SpecificCmp_match<Op0_t, Op1_t, Instruction::ICmp>
759m_SpecificICmp(CmpPredicate MatchPred, const Op0_t &Op0, const Op1_t &Op1) {
761 Op1);
762}
763
764template <typename Op0_t, typename Op1_t>
765inline Cmp_match<Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp>
766m_Cmp(const Op0_t &Op0, const Op1_t &Op1) {
768 Op1);
769}
770
771template <typename Op0_t, typename Op1_t>
772inline Cmp_match<Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp>
773m_Cmp(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1) {
775 Pred, Op0, Op1);
776}
777
778template <typename Op0_t, typename Op1_t>
779inline SpecificCmp_match<Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp>
780m_SpecificCmp(CmpPredicate MatchPred, const Op0_t &Op0, const Op1_t &Op1) {
782 MatchPred, Op0, Op1);
783}
784
785template <typename Op0_t, typename Op1_t>
786inline auto m_GetElementPtr(const Op0_t &Op0, const Op1_t &Op1) {
787 return m_CombineOr(
788 Recipe_match<std::tuple<Op0_t, Op1_t>, Instruction::GetElementPtr,
789 /*Commutative*/ false, VPReplicateRecipe, VPWidenGEPRecipe>(
790 Op0, Op1),
793}
794
795/// Match a VPBlendRecipe with 2 incoming values ([I0, I1, M1] ==
796/// normalized([I0, M0, I1, M1])) as select(M1, I1, I0), mirroring how it is
797/// lowered.
798template <typename Op0_t, typename Op1_t, typename Op2_t> struct Blend2_match {
799 Op0_t MaskOp;
801 Op2_t FalseOp;
802
803 Blend2_match(const Op0_t &MaskOp, const Op1_t &TrueOp, const Op2_t &FalseOp)
805
806 template <typename T> bool match(const T *Val) const {
807 auto *Blend = dyn_cast<VPBlendRecipe>(Val);
808 if (!Blend || Blend->getNumIncomingValues() != 2)
809 return false;
810 return MaskOp.match(Blend->getMask(1)) &&
811 TrueOp.match(Blend->getIncomingValue(1)) &&
812 FalseOp.match(Blend->getIncomingValue(0));
813 }
814};
815
816/// Match recipe recipe with Select opcode, i.e. excluding VPBlendRecipe.
817template <typename Op0_t, typename Op1_t, typename Op2_t>
819m_Select(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
821 {Op0, Op1, Op2});
822}
823
824/// Match recipe with Select opcode or an equivalent VPBlendRecipe with 2
825/// incoming values.
826template <typename Op0_t, typename Op1_t, typename Op2_t>
827inline auto m_SelectLike(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
828 return m_CombineOr(m_Select(Op0, Op1, Op2),
829 Blend2_match<Op0_t, Op1_t, Op2_t>(Op0, Op1, Op2));
830}
831
832template <typename Op0_t> inline auto m_Not(const Op0_t &Op0) {
835}
836
837template <typename Op0_t, typename Op1_t, typename Op2_t>
838inline auto m_c_Select(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
839 return m_CombineOr(m_Select(Op0, Op1, Op2), m_Select(m_Not(Op0), Op2, Op1));
840}
841
842template <typename Op0_t, typename Op1_t>
843inline auto m_LogicalAnd(const Op0_t &Op0, const Op1_t &Op1) {
844 return m_CombineOr(
846 m_Select(Op0, Op1, m_False()));
847}
848
849template <typename Op0_t, typename Op1_t>
850inline auto m_c_LogicalAnd(const Op0_t &Op0, const Op1_t &Op1) {
851 return m_CombineOr(
853 m_c_Select(Op0, Op1, m_False()));
854}
855
856template <typename Op0_t, typename Op1_t>
857inline auto m_LogicalOr(const Op0_t &Op0, const Op1_t &Op1) {
858 return m_CombineOr(
860 m_Select(Op0, m_True(), Op1));
861}
862
863template <typename Op0_t, typename Op1_t>
864inline auto m_c_LogicalOr(const Op0_t &Op0, const Op1_t &Op1) {
865 return m_c_Select(Op0, m_True(), Op1);
866}
867
868/// Match the canonical induction variable (IV) of any loop region.
870 template <typename ArgTy> bool match(const ArgTy *V) const {
871 const auto *RV = dyn_cast<VPRegionValue>(V);
872 return RV && RV->getDefiningRegion()->getCanonicalIV() == RV;
873 }
874};
875
876inline canonical_iv_match m_CanonicalIV() { return {}; }
877
878/// Match a canonical VPWidenIntOrFpInductionRecipe optionally capturing it.
881
884
885 template <typename ArgTy> bool match(ArgTy *V) const {
887 if (!WidenIV || !WidenIV->isCanonical())
888 return false;
889 if (Capture)
890 *Capture = WidenIV;
891 return true;
892 }
893};
894
896
897/// Match a canonical VPWidenIntOrFpInductionRecipe, capturing it.
898inline canonical_widen_iv_match
902
903template <typename Op0_t, typename Op1_t, typename Op2_t>
904inline auto m_ScalarIVSteps(const Op0_t &Op0, const Op1_t &Op1,
905 const Op2_t &Op2) {
907 VPScalarIVStepsRecipe>({Op0, Op1, Op2});
908}
909
910template <typename Op0_t, typename Op1_t, typename Op2_t>
911inline auto m_DerivedIV(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
913 VPDerivedIVRecipe>({Op0, Op1, Op2});
914}
915
916template <typename Addr_t, typename Mask_t> struct Load_match {
917 Addr_t Addr;
918 Mask_t Mask;
919
920 Load_match(Addr_t Addr, Mask_t Mask) : Addr(Addr), Mask(Mask) {}
921
922 template <typename OpTy> bool match(const OpTy *V) const {
923 auto *Load = dyn_cast<VPWidenLoadRecipe>(V);
924 if (!Load || !Addr.match(Load->getAddr()) || !Load->isMasked() ||
925 !Mask.match(Load->getMask()))
926 return false;
927 return true;
928 }
929};
930
931/// Match a (possibly reversed) masked load.
932template <typename Addr_t, typename Mask_t>
933inline Load_match<Addr_t, Mask_t> m_MaskedLoad(const Addr_t &Addr,
934 const Mask_t &Mask) {
935 return Load_match<Addr_t, Mask_t>(Addr, Mask);
936}
937
938template <typename Addr_t, typename Val_t, typename Mask_t> struct Store_match {
939 Addr_t Addr;
940 Val_t Val;
941 Mask_t Mask;
942
943 Store_match(Addr_t Addr, Val_t Val, Mask_t Mask)
944 : Addr(Addr), Val(Val), Mask(Mask) {}
945
946 template <typename OpTy> bool match(const OpTy *V) const {
947 auto *Store = dyn_cast<VPWidenStoreRecipe>(V);
948 if (!Store || !Addr.match(Store->getAddr()) ||
949 !Val.match(Store->getStoredValue()) || !Store->isMasked() ||
950 !Mask.match(Store->getMask()))
951 return false;
952 return true;
953 }
954};
955
956/// Match a (possibly reversed) masked store.
957template <typename Addr_t, typename Val_t, typename Mask_t>
958inline Store_match<Addr_t, Val_t, Mask_t>
959m_MaskedStore(const Addr_t &Addr, const Val_t &Val, const Mask_t &Mask) {
960 return Store_match<Addr_t, Val_t, Mask_t>(Addr, Val, Mask);
961}
962
963template <typename Op0_t, typename Op1_t>
966 /*Commutative*/ false, VPVectorEndPointerRecipe>;
967
968template <typename Op0_t, typename Op1_t>
973
974/// Match a call argument at a given argument index.
975template <typename Opnd_t> struct Argument_match {
976 /// Call argument index to match.
977 unsigned OpI;
978 Opnd_t Val;
979
980 Argument_match(unsigned OpIdx, const Opnd_t &V) : OpI(OpIdx), Val(V) {}
981
982 template <typename OpTy> bool match(OpTy *V) const {
983 if (const auto *R = dyn_cast<VPWidenIntrinsicRecipe>(V))
984 return Val.match(R->getOperand(OpI));
985 if (const auto *R = dyn_cast<VPWidenCallRecipe>(V))
986 return Val.match(R->getOperand(OpI));
987 if (const auto *R = dyn_cast<VPReplicateRecipe>(V))
988 if (R->getOpcode() == Instruction::Call)
989 return Val.match(R->getOperand(OpI));
990 if (const auto *R = dyn_cast<VPInstruction>(V))
991 if (R->getOpcode() == Instruction::Call)
992 return Val.match(R->getOperand(OpI));
993 return false;
994 }
995};
996
997/// Match a call argument.
998template <unsigned OpI, typename Opnd_t>
999inline Argument_match<Opnd_t> m_Argument(const Opnd_t &Op) {
1000 return Argument_match<Opnd_t>(OpI, Op);
1001}
1002
1003/// Intrinsic matchers.
1005 unsigned ID;
1006
1008
1009 template <typename OpTy> bool match(OpTy *V) const {
1010 return vputils::getIntrinsicID(V) == ID;
1011 }
1012};
1013
1014/// Intrinsic matches are combinations of ID matchers, and argument
1015/// matchers. Higher arity matcher are defined recursively in terms of and-ing
1016/// them with lower arity matchers. Here's some convenient typedefs for up to
1017/// several arguments, and more can be added as needed
1018template <typename T0 = void, typename T1 = void, typename T2 = void,
1019 typename T3 = void>
1020struct m_Intrinsic_Ty;
1021template <typename T0> struct m_Intrinsic_Ty<T0> {
1023};
1024template <typename T0, typename T1> struct m_Intrinsic_Ty<T0, T1> {
1025 using Ty =
1027};
1028template <typename T0, typename T1, typename T2>
1033template <typename T0, typename T1, typename T2, typename T3>
1038
1039/// Match intrinsic calls like this:
1040/// m_Intrinsic<Intrinsic::fabs>(m_VPValue(X), ...)
1041template <Intrinsic::ID IntrID> inline IntrinsicID_match m_Intrinsic() {
1042 return IntrinsicID_match(IntrID);
1043}
1044
1045/// Match intrinsic calls with a runtime intrinsic ID.
1047 return IntrinsicID_match(IntrID);
1048}
1049
1050template <Intrinsic::ID IntrID, typename T0>
1051inline typename m_Intrinsic_Ty<T0>::Ty m_Intrinsic(const T0 &Op0) {
1053}
1054
1055template <Intrinsic::ID IntrID, typename T0, typename T1>
1056inline typename m_Intrinsic_Ty<T0, T1>::Ty m_Intrinsic(const T0 &Op0,
1057 const T1 &Op1) {
1059}
1060
1061template <Intrinsic::ID IntrID, typename T0, typename T1, typename T2>
1062inline typename m_Intrinsic_Ty<T0, T1, T2>::Ty
1063m_Intrinsic(const T0 &Op0, const T1 &Op1, const T2 &Op2) {
1064 return m_CombineAnd(m_Intrinsic<IntrID>(Op0, Op1), m_Argument<2>(Op2));
1065}
1066
1067template <Intrinsic::ID IntrID, typename T0, typename T1, typename T2,
1068 typename T3>
1070m_Intrinsic(const T0 &Op0, const T1 &Op1, const T2 &Op2, const T3 &Op3) {
1071 return m_CombineAnd(m_Intrinsic<IntrID>(Op0, Op1, Op2), m_Argument<3>(Op3));
1072}
1073
1074template <Intrinsic::ID IntrID, typename... T>
1075inline auto m_WidenIntrinsic(const T &...Ops) {
1077}
1078
1080
1081/// Match a GEP recipe (VPWidenGEPRecipe, VPInstruction, or VPReplicateRecipe)
1082/// and bind the source element type and operands.
1086
1089
1090 template <typename ITy> bool match(ITy *V) const {
1091 return matchRecipeAndBind<VPWidenGEPRecipe>(V) ||
1092 matchRecipeAndBind<VPInstruction>(V) ||
1093 matchRecipeAndBind<VPReplicateRecipe>(V);
1094 }
1095
1096private:
1097 template <typename RecipeTy> bool matchRecipeAndBind(const VPValue *V) const {
1098 auto *DefR = dyn_cast<RecipeTy>(V);
1099 if (!DefR)
1100 return false;
1101
1102 if constexpr (std::is_same_v<RecipeTy, VPWidenGEPRecipe>) {
1103 SourceElementType = DefR->getSourceElementType();
1104 } else if (DefR->getOpcode() == Instruction::GetElementPtr) {
1105 SourceElementType = cast<GetElementPtrInst>(DefR->getUnderlyingInstr())
1106 ->getSourceElementType();
1107 } else if constexpr (std::is_same_v<RecipeTy, VPInstruction>) {
1108 if (DefR->getOpcode() == VPInstruction::PtrAdd) {
1109 // PtrAdd is a byte-offset GEP with i8 element type.
1110 LLVMContext &Ctx = DefR->getParent()->getPlan()->getContext();
1112 } else {
1113 return false;
1114 }
1115 } else {
1116 return false;
1117 }
1118
1119 Operands = ArrayRef<VPValue *>(DefR->op_begin(), DefR->op_end());
1120 return true;
1121 }
1122};
1123
1124/// Match a GEP recipe with any number of operands and bind source element type
1125/// and operands.
1126inline GetElementPtr_match m_GetElementPtr(Type *&SourceElementType,
1127 ArrayRef<VPValue *> &Operands) {
1128 return GetElementPtr_match(SourceElementType, Operands);
1129}
1130
1131template <typename SubPattern_t> struct OneUse_match {
1132 SubPattern_t SubPattern;
1133
1134 OneUse_match(const SubPattern_t &SP) : SubPattern(SP) {}
1135
1136 template <typename OpTy> bool match(OpTy *V) const {
1137 return V->hasOneUse() && SubPattern.match(V);
1138 }
1139};
1140
1141template <typename T> inline OneUse_match<T> m_OneUse(const T &SubPattern) {
1142 return SubPattern;
1143}
1144
1147 return V;
1148}
1149
1150template <typename Op0_t, typename Op1_t>
1151inline auto m_VPPhi(const Op0_t &Op0, const Op1_t &Op1) {
1152 return Recipe_match<std::tuple<Op0_t, Op1_t>, Instruction::PHI,
1153 /*Commutative*/ false, VPInstruction>({Op0, Op1});
1154}
1155
1156/// If \p V is used by a recipe matching pattern \p P, return it. Otherwise
1157/// return nullptr;
1158template <typename MatchT>
1159static VPRecipeBase *findUserOf(VPValue *V, const MatchT &P) {
1160 auto It = find_if(V->users(), match_fn(P));
1161 return It == V->user_end() ? nullptr : cast<VPRecipeBase>(*It);
1162}
1163
1164/// If \p V is used by a VPInstruction with \p Opcode, return it. Otherwise
1165/// return nullptr.
1166template <unsigned Opcode> static VPInstruction *findUserOf(VPValue *V) {
1168}
1169
1170template <typename RecipeTy> static RecipeTy *findUserOf(VPValue *V) {
1172}
1173} // namespace llvm::VPlanPatternMatch
1174
1175#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static constexpr Value * getValue(Ty &ValueOrUse)
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
#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:762
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:307
A recipe for converting the input value IV value to the corresponding value of an IV with different s...
Definition VPlan.h:4188
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:1328
VPRecipeBase is a base class modeling a sequence of one or more output IR instructions.
Definition VPlan.h:402
A recipe for handling reduction phis.
Definition VPlan.h:2864
VPReplicateRecipe replicates a given instruction producing multiple scalar copies of the original sca...
Definition VPlan.h:3398
A recipe for handling phi nodes of integer and floating-point inductions, producing their scalar valu...
Definition VPlan.h:4255
VPSingleDefRecipe is a base class for recipes that model a sequence of one or more output IR that def...
Definition VPlan.h:609
This class augments VPValue with operands which provide the inverse def-use edges from VPValue's user...
Definition VPlanValue.h:384
This is the base class of the VPlan Def/Use graph, used for modeling the data flow into,...
Definition VPlanValue.h:50
A recipe to compute a pointer to the last element of each part of a widened memory access for widened...
Definition VPlan.h:2266
VPWidenCastRecipe is a recipe to create vector cast instructions.
Definition VPlan.h:1878
A recipe for handling GEP instructions.
Definition VPlan.h:2206
A recipe for handling phi nodes of integer and floating-point inductions, producing their vector valu...
Definition VPlan.h:2623
VPWidenRecipe is a recipe for producing a widened instruction using the opcode and operands of the re...
Definition VPlan.h:1817
@ 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)
Match recipe recipe with Select opcode, i.e. excluding VPBlendRecipe.
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::URem, Op0_t, Op1_t > m_URem(const Op0_t &Op0, const Op1_t &Op1)
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)
auto m_SelectLike(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
Match recipe with Select opcode or an equivalent VPBlendRecipe with 2 incoming values.
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.
AllRecipe_match< Instruction::LShr, Op0_t, Op1_t > m_LShr(const Op0_t &Op0, const Op1_t &Op1)
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)
canonical_widen_iv_match m_CanonicalWidenIV()
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)
AllRecipe_match< Instruction::Shl, Op0_t, Op1_t > m_Shl(const Op0_t &Op0, const Op1_t &Op1)
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::FNeg, Op0_t > m_FNeg(const Op0_t &Op0)
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)
static VPRecipeBase * findUserOf(VPValue *V, const MatchT &P)
If V is used by a recipe matching pattern P, return it.
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)
auto m_AnyNeg(const Op0_t &Op0)
VPInstruction_match< VPInstruction::Reverse, Op0_t > m_Reverse(const Op0_t &Op0)
Intrinsic::ID getIntrinsicID(const Ty *R)
Return the intrinsic ID underlying a call.
Definition VPlanUtils.h:81
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
auto cast_or_null(const Y &Val)
Definition Casting.h:714
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
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1771
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:860
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:246
Match a call argument at a given argument index.
unsigned OpI
Call argument index to match.
Argument_match(unsigned OpIdx, const Opnd_t &V)
Match a VPBlendRecipe with 2 incoming values ([I0, I1, M1] == normalized([I0, M0, I1,...
Blend2_match(const Op0_t &MaskOp, const Op1_t &TrueOp, const Op2_t &FalseOp)
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 a canonical VPWidenIntOrFpInductionRecipe optionally capturing it.
canonical_widen_iv_match(VPWidenIntOrFpInductionRecipe *&V)
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