LLVM 24.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#include <utility>
22
24
25using namespace llvm::PatternMatchHelpers;
26
27template <typename Val, typename Pattern> bool match(Val *V, const Pattern &P) {
28 return P.match(V);
29}
30
31template <typename Pattern> bool match(VPUser *U, const Pattern &P) {
32 auto *R = dyn_cast<VPRecipeBase>(U);
33 return R && match(R, P);
34}
35
36template <typename Pattern> bool match(VPSingleDefRecipe *R, const Pattern &P) {
37 return P.match(static_cast<const VPRecipeBase *>(R));
38}
39
40/// A match functor that can be used as a UnaryPredicate in functional
41/// algorithms like all_of.
42template <typename Pattern> auto match_fn(const Pattern &P) {
43 return [&P](auto *V) { return match(V, P); };
44}
45
46/// Match an arbitrary VPValue and ignore it.
47inline auto m_VPValue() { return m_Isa<VPValue>(); }
48
49/// Match a specified VPValue.
51 const VPValue *Val;
52
53 specificval_ty(const VPValue *V) : Val(V) {}
54
55 bool match(const VPValue *VPV) const { return VPV == Val; }
56};
57
58inline specificval_ty m_Specific(const VPValue *VPV) { return VPV; }
59
60/// Like m_Specific(), but works if the specific value to match is determined
61/// as part of the same match() expression. For example:
62/// m_Mul(m_VPValue(X), m_Specific(X)) is incorrect, because m_Specific() will
63/// bind X before the pattern match starts.
64/// m_Mul(m_VPValue(X), m_Deferred(X)) is correct, and will check against
65/// whichever value m_VPValue(X) populated.
66inline match_deferred<VPValue> m_Deferred(VPValue *const &V) { return V; }
67
68/// Match an integer constant if Pred::isValue returns true for the APInt. \p
69/// BitWidth optionally specifies the bitwidth the matched constant must have.
70/// If it is 0, the matched constant can have any bitwidth.
71template <typename Pred, unsigned BitWidth = 0> struct int_pred_ty {
72 Pred P;
73
74 int_pred_ty(Pred P) : P(std::move(P)) {}
75 int_pred_ty() : P() {}
76
77 bool match(const VPValue *VPV) const {
78 auto *VPI = dyn_cast<VPInstruction>(VPV);
79 if (VPI && VPI->getOpcode() == VPInstruction::Broadcast)
80 VPV = VPI->getOperand(0);
81 auto *CI = dyn_cast<VPConstantInt>(VPV);
82 if (!CI)
83 return false;
84
85 if (BitWidth != 0 && CI->getBitWidth() != BitWidth)
86 return false;
87 return P.isValue(CI->getAPInt());
88 }
89};
90
91/// Match a specified signed or unsigned integer value.
95
98
99 bool isValue(const APInt &C) const {
101 }
102};
103
104template <unsigned Bitwidth = 0>
106
110
112 return specific_intval<0>(
113 is_specific_int(APInt(64, V, /*isSigned=*/true), /*IsSigned=*/true));
114}
115
119
123
125 bool isValue(const APInt &C) const { return C.isAllOnes(); }
126};
127
128/// Match an integer or vector with all bits set.
129/// For vectors, this includes constants with undefined elements.
133
135 bool isValue(const APInt &C) const { return C.isZero(); }
136};
137
138struct is_one {
139 bool isValue(const APInt &C) const { return C.isOne(); }
140};
141
142/// Match an integer 0 or a vector with all elements equal to 0.
143/// For vectors, this includes constants with undefined elements.
147
148/// Match an integer 1 or a vector with all elements equal to 1.
149/// For vectors, this includes constants with undefined elements.
151
153 const APInt *&Res;
154
155 bind_apint(const APInt *&Res) : Res(Res) {}
156
157 bool match(const VPValue *VPV) const {
158 auto *CI = dyn_cast<VPConstantInt>(VPV);
159 if (!CI)
160 return false;
161 Res = &CI->getAPInt();
162 return true;
163 }
164};
165
166inline bind_apint m_APInt(const APInt *&C) { return C; }
167
170
172
173 bool match(const VPValue *VPV) const {
174 const APInt *APConst;
175 if (!bind_apint(APConst).match(VPV))
176 return false;
177 if (auto C = APConst->tryZExtValue()) {
178 Res = *C;
179 return true;
180 }
181 return false;
182 }
183};
184
186 bool match(const VPValue *V) const {
187 return isa<VPIRValue>(V) &&
189 }
190};
191
192/// Match a VPIRValue that's poison.
193inline match_poison m_Poison() { return match_poison(); }
194
195/// Match a plain integer constant no wider than 64-bits, capturing it if we
196/// match.
198
199/// Match a VPValue, capturing it if we match.
200inline match_bind<VPValue> m_VPValue(VPValue *&V) { return V; }
201
202/// Match against the nested pattern, and capture the value if we match.
203template <typename Op_t> inline auto m_VPValue(VPValue *&V, const Op_t &Op) {
204 return m_CombineAnd(Op, m_VPValue(V));
205}
206
207/// Match a VPIRValue.
209
210/// Match a VPSingleDefRecipe, capturing if we match.
213 return V;
214}
215
216/// Match a VPInstruction, capturing if we match.
220
221template <typename Ops_t, unsigned Opcode, bool Commutative,
222 typename... RecipeTys>
224 Ops_t Ops;
225
226 template <typename... OpTy> Recipe_match(OpTy... Ops) : Ops(Ops...) {
227 static_assert(std::tuple_size<Ops_t>::value == sizeof...(Ops) &&
228 "number of operands in constructor doesn't match Ops_t");
229 static_assert((!Commutative || std::tuple_size<Ops_t>::value == 2) &&
230 "only binary ops can be commutative");
231 }
232
233 bool match(const VPValue *V) const {
234 auto *DefR = V->getDefiningRecipe();
235 return DefR && match(DefR);
236 }
237
238 bool match(const VPSingleDefRecipe *R) const {
239 return match(static_cast<const VPRecipeBase *>(R));
240 }
241
242 bool match(const VPRecipeBase *R) const {
243 if (std::tuple_size_v<Ops_t> == 0) {
244 auto *VPI = dyn_cast<VPInstruction>(R);
245 return VPI && VPI->getOpcode() == Opcode;
246 }
247
248 if ((!matchRecipeAndOpcode<RecipeTys>(R) && ...))
249 return false;
250
251 if (R->getNumOperands() < std::tuple_size<Ops_t>::value) {
252 [[maybe_unused]] auto *RepR = dyn_cast<VPReplicateRecipe>(R);
254 cast<VPInstruction>(R)->getNumOperandsForOpcode() == -1u) ||
255 (RepR && std::tuple_size_v<Ops_t> ==
256 RepR->getNumOperandsWithoutMask())) &&
257 "non-variadic recipe with matched opcode does not have the "
258 "expected number of operands");
259 return false;
260 }
261
262 // If the recipe has more operands than expected, we only support matching
263 // masked VPInstructions or predicated VPReplicateRecipes, where the number
264 // of operands of the matcher matches the number of operands excluding the
265 // mask.
266 if (R->getNumOperands() > std::tuple_size<Ops_t>::value) {
267 if (auto *VPI = dyn_cast<VPInstruction>(R)) {
268 if (!VPI->isMasked() ||
269 VPI->getNumOperandsWithoutMask() != std::tuple_size<Ops_t>::value)
270 return false;
271 } else if (auto *RepR = dyn_cast<VPReplicateRecipe>(R)) {
272 if (!RepR->isPredicated() ||
273 RepR->getNumOperandsWithoutMask() != std::tuple_size<Ops_t>::value)
274 return false;
275 } else {
276 return false;
277 }
278 }
279
280 auto IdxSeq = std::make_index_sequence<std::tuple_size<Ops_t>::value>();
281 if (all_of_tuple_elements(IdxSeq, [R](auto Op, unsigned Idx) {
282 return Op.match(R->getOperand(Idx));
283 }))
284 return true;
285
286 return Commutative &&
287 all_of_tuple_elements(IdxSeq, [R](auto Op, unsigned Idx) {
288 return Op.match(R->getOperand(R->getNumOperands() - Idx - 1));
289 });
290 }
291
292private:
293 template <typename RecipeTy>
294 static bool matchRecipeAndOpcode(const VPRecipeBase *R) {
295 auto *DefR = dyn_cast<RecipeTy>(R);
296 // Check for recipes that do not have opcodes.
297 if constexpr (std::is_same_v<RecipeTy, VPScalarIVStepsRecipe> ||
298 std::is_same_v<RecipeTy, VPDerivedIVRecipe> ||
299 std::is_same_v<RecipeTy, VPVectorEndPointerRecipe>)
300 return DefR;
301 else
302 return DefR && DefR->getOpcode() == Opcode;
303 }
304
305 /// Helper to check if predicate \p P holds on all tuple elements in Ops using
306 /// the provided index sequence.
307 template <typename Fn, std::size_t... Is>
308 bool all_of_tuple_elements(std::index_sequence<Is...>,
309 [[maybe_unused]] Fn P) const {
310 return (P(std::get<Is>(Ops), Is) && ...);
311 }
312};
313
314template <unsigned Opcode, typename... OpTys>
316 Recipe_match<std::tuple<OpTys...>, Opcode, /*Commutative*/ false,
319
320template <unsigned Opcode, typename... OpTys>
322 Recipe_match<std::tuple<OpTys...>, Opcode, /*Commutative*/ true,
324
325template <unsigned Opcode, typename... OpTys>
326using VPInstruction_match = Recipe_match<std::tuple<OpTys...>, Opcode,
327 /*Commutative*/ false, VPInstruction>;
328
329template <unsigned Opcode, typename... OpTys>
331 Recipe_match<std::tuple<OpTys...>, Opcode,
332 /*Commutative*/ true, VPInstruction>;
333
334template <unsigned Opcode, typename... OpTys>
335inline VPInstruction_match<Opcode, OpTys...>
336m_VPInstruction(const OpTys &...Ops) {
337 return VPInstruction_match<Opcode, OpTys...>(Ops...);
338}
339
340template <unsigned Opcode, typename Op0_t, typename Op1_t>
342m_c_VPInstruction(const Op0_t &Op0, const Op1_t &Op1) {
344}
345
346/// BuildVector is matches only its opcode, w/o matching its operands as the
347/// number of operands is not fixed.
351
352/// BuildStructVector matches only its opcode, w/o matching its operands as the
353/// number of operands is not fixed.
358
359template <typename Op0_t>
361m_Freeze(const Op0_t &Op0) {
363}
364
368
369template <typename Op0_t>
371m_BranchOnCond(const Op0_t &Op0) {
373}
374
379
380template <typename Op0_t, typename Op1_t>
382m_BranchOnTwoConds(const Op0_t &Op0, const Op1_t &Op1) {
384}
385
389
390template <typename Op0_t, typename Op1_t>
392m_BranchOnCount(const Op0_t &Op0, const Op1_t &Op1) {
394}
395
396inline auto m_Branch() {
398}
399
400template <typename Op0_t>
402m_Broadcast(const Op0_t &Op0) {
404}
405
406template <typename Op0_t>
408m_EVL(const Op0_t &Op0) {
410}
411
412template <typename Op0_t>
417
418template <typename Op0_t, typename Op1_t>
420m_ExtractElement(const Op0_t &Op0, const Op1_t &Op1) {
422}
423
424template <typename Op0_t, typename Op1_t, typename Op2_t>
426m_InsertElement(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
428}
429
430template <typename Op0_t, typename Op1_t>
432m_ExtractLane(const Op0_t &Op0, const Op1_t &Op1) {
434}
435
436template <typename Op0_t>
441
442template <typename Op0_t>
448}
449
450template <typename Op0_t, typename Op1_t>
452m_ExtractVectorForPart(const Op0_t &Op0, const Op1_t &Op1) {
454}
455
456template <typename Op0_t>
461
462template <typename Op0_t, typename Op1_t, typename Op2_t>
464 Op2_t>
465m_WideActiveLaneMask(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
467}
468
472
473template <typename Op0_t>
475m_AnyOf(const Op0_t &Op0) {
477}
478
479template <typename Op0_t>
484
485template <typename Op0_t>
487m_LastActiveLane(const Op0_t &Op0) {
489}
490
491template <typename Op0_t, typename Op1_t, typename Op2_t>
493 Op2_t>
494m_ExtractLastActive(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
496}
497
498template <typename Op0_t>
503
504/// Match FindIV result pattern:
505/// select(icmp ne ComputeReductionResult(ReducedIV), Sentinel),
506/// ComputeReductionResult(ReducedIV), Start.
507template <typename Op0_t, typename Op1_t>
508inline bool matchFindIVResult(VPInstruction *VPI, Op0_t ReducedIV, Op1_t Start) {
510 m_ComputeReductionResult(ReducedIV),
511 m_VPValue()),
512 m_ComputeReductionResult(ReducedIV), Start));
513}
514
515template <typename Op0_t>
517m_Reverse(const Op0_t &Op0) {
519}
520
524
525template <typename Op0_t>
527m_ExitingIVValue(const Op0_t &Op0) {
529}
530
531template <unsigned Opcode, typename Op0_t>
532inline AllRecipe_match<Opcode, Op0_t> m_Unary(const Op0_t &Op0) {
534}
535
536template <typename Op0_t>
540
541template <typename Op0_t>
543m_TruncOrSelf(const Op0_t &Op0) {
544 return m_CombineOr(m_Trunc(Op0), Op0);
545}
546
547template <typename Op0_t>
551
552template <typename Op0_t>
556
557template <typename Op0_t>
561
562template <typename Op0_t>
564m_BitCast(const Op0_t &Op0) {
566}
567
568template <typename Op0_t>
572
573template <typename Op0_t>
576m_ZExtOrSExt(const Op0_t &Op0) {
577 return m_CombineOr(m_ZExt(Op0), m_SExt(Op0));
578}
579
580template <typename Op0_t> inline auto m_WidenAnyExtend(const Op0_t &Op0) {
582}
583
584template <typename Op0_t> inline auto m_AnyNeg(const Op0_t &Op0) {
585 return m_CombineOr(m_Sub(m_ZeroInt(), Op0), m_FNeg(Op0));
586}
587
588template <typename Op0_t>
590m_ZExtOrSelf(const Op0_t &Op0) {
591 return m_CombineOr(m_ZExt(Op0), Op0);
592}
593
594template <typename Op0_t> inline auto m_ZExtOrTruncOrSelf(const Op0_t &Op0) {
595 return m_CombineOr(m_ZExt(Op0), m_Trunc(Op0), Op0);
596}
597
598template <unsigned Opcode, typename Op0_t, typename Op1_t>
600 const Op1_t &Op1) {
602}
603
604template <unsigned Opcode, typename Op0_t, typename Op1_t>
606m_c_Binary(const Op0_t &Op0, 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_Add(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>
630 const Op1_t &Op1) {
632}
633
634template <typename Op0_t, typename Op1_t>
636m_c_Mul(const Op0_t &Op0, const Op1_t &Op1) {
638}
639
640template <typename Op0_t, typename Op1_t>
642 const Op1_t &Op1) {
644}
645
646template <typename Op0_t, typename Op1_t>
648m_LShr(const Op0_t &Op0, const Op1_t &Op1) {
650}
651
652template <typename Op0_t, typename Op1_t>
654m_FMul(const Op0_t &Op0, const Op1_t &Op1) {
656}
657
658template <typename Op0_t, typename Op1_t>
660m_FAdd(const Op0_t &Op0, const Op1_t &Op1) {
662}
663
664template <typename Op0_t, typename Op1_t>
666m_c_FAdd(const Op0_t &Op0, const Op1_t &Op1) {
668}
669
670template <typename Op0_t, typename Op1_t>
672m_UDiv(const Op0_t &Op0, const Op1_t &Op1) {
674}
675
676template <typename Op0_t, typename Op1_t>
678m_URem(const Op0_t &Op0, const Op1_t &Op1) {
680}
681
682template <typename Op0_t, typename Op1_t>
684m_SDiv(const Op0_t &Op0, const Op1_t &Op1) {
686}
687
688template <typename Op0_t, typename Op1_t>
690m_SRem(const Op0_t &Op0, const Op1_t &Op1) {
692}
693
694/// Match a binary AND operation.
695template <typename Op0_t, typename Op1_t>
697m_c_BinaryAnd(const Op0_t &Op0, const Op1_t &Op1) {
699}
700
701/// Match a binary OR operation. Note that while conceptually the operands can
702/// be matched commutatively, \p Commutative defaults to false in line with the
703/// IR-based pattern matching infrastructure. Use m_c_BinaryOr for a commutative
704/// version of the matcher.
705template <typename Op0_t, typename Op1_t>
707m_BinaryOr(const Op0_t &Op0, const Op1_t &Op1) {
709}
710
711template <typename Op0_t, typename Op1_t>
713m_c_BinaryOr(const Op0_t &Op0, const Op1_t &Op1) {
715}
716
717/// Cmp_match is a variant of BinaryRecipe_match that also binds the comparison
718/// predicate. Opcodes must either be Instruction::ICmp or Instruction::FCmp, or
719/// both.
720template <typename Op0_t, typename Op1_t, unsigned... Opcodes>
721struct Cmp_match {
722 static_assert((sizeof...(Opcodes) == 1 || sizeof...(Opcodes) == 2) &&
723 "Expected one or two opcodes");
724 static_assert(
725 ((Opcodes == Instruction::ICmp || Opcodes == Instruction::FCmp) && ...) &&
726 "Expected a compare instruction opcode");
727
729 Op0_t Op0;
731
732 Cmp_match(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1)
733 : Predicate(&Pred), Op0(Op0), Op1(Op1) {}
734 Cmp_match(const Op0_t &Op0, const Op1_t &Op1) : Op0(Op0), Op1(Op1) {}
735
736 bool match(const VPValue *V) const {
737 auto *DefR = V->getDefiningRecipe();
738 return DefR && match(DefR);
739 }
740
741 bool match(const VPRecipeBase *V) const {
742 if ((m_Binary<Opcodes>(Op0, Op1).match(V) || ...)) {
743 if (Predicate)
744 *Predicate = cast<VPRecipeWithIRFlags>(V)->getPredicate();
745 return true;
746 }
747 return false;
748 }
749};
750
751/// SpecificCmp_match is a variant of Cmp_match that matches the comparison
752/// predicate, instead of binding it.
753template <typename Op0_t, typename Op1_t, unsigned... Opcodes>
756 Op0_t Op0;
758
759 SpecificCmp_match(CmpPredicate Pred, const Op0_t &LHS, const Op1_t &RHS)
760 : Predicate(Pred), Op0(LHS), Op1(RHS) {}
761
762 bool match(const VPValue *V) const {
763 auto *DefR = V->getDefiningRecipe();
764 return DefR && match(DefR);
765 }
766
767 bool match(const VPRecipeBase *V) const {
768 CmpPredicate CurrentPred;
769 return Cmp_match<Op0_t, Op1_t, Opcodes...>(CurrentPred, Op0, Op1)
770 .match(V) &&
772 }
773};
774
775template <typename Op0_t, typename Op1_t>
777 const Op1_t &Op1) {
779}
780
781template <typename Op0_t, typename Op1_t>
782inline Cmp_match<Op0_t, Op1_t, Instruction::ICmp>
783m_ICmp(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1) {
784 return Cmp_match<Op0_t, Op1_t, Instruction::ICmp>(Pred, Op0, Op1);
785}
786
787template <typename Op0_t, typename Op1_t>
788inline SpecificCmp_match<Op0_t, Op1_t, Instruction::ICmp>
789m_SpecificICmp(CmpPredicate MatchPred, const Op0_t &Op0, const Op1_t &Op1) {
791 Op1);
792}
793
794template <typename Op0_t, typename Op1_t>
795inline Cmp_match<Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp>
796m_Cmp(const Op0_t &Op0, const Op1_t &Op1) {
798 Op1);
799}
800
801template <typename Op0_t, typename Op1_t>
802inline Cmp_match<Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp>
803m_Cmp(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1) {
805 Pred, Op0, Op1);
806}
807
808template <typename Op0_t, typename Op1_t>
809inline SpecificCmp_match<Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp>
810m_SpecificCmp(CmpPredicate MatchPred, const Op0_t &Op0, const Op1_t &Op1) {
812 MatchPred, Op0, Op1);
813}
814
815template <typename Op0_t, typename Op1_t>
816inline auto m_GetElementPtr(const Op0_t &Op0, const Op1_t &Op1) {
817 return m_CombineOr(
818 Recipe_match<std::tuple<Op0_t, Op1_t>, Instruction::GetElementPtr,
819 /*Commutative*/ false, VPReplicateRecipe, VPWidenGEPRecipe>(
820 Op0, Op1),
823}
824
825/// Match a VPBlendRecipe with 2 incoming values ([I0, I1, M1] ==
826/// normalized([I0, M0, I1, M1])) as select(M1, I1, I0), mirroring how it is
827/// lowered.
828template <typename Op0_t, typename Op1_t, typename Op2_t> struct Blend2_match {
829 Op0_t MaskOp;
831 Op2_t FalseOp;
832
833 Blend2_match(const Op0_t &MaskOp, const Op1_t &TrueOp, const Op2_t &FalseOp)
835
836 template <typename T> bool match(const T *Val) const {
837 auto *Blend = dyn_cast<VPBlendRecipe>(Val);
838 if (!Blend || Blend->getNumIncomingValues() != 2)
839 return false;
840 return MaskOp.match(Blend->getMask(1)) &&
841 TrueOp.match(Blend->getIncomingValue(1)) &&
842 FalseOp.match(Blend->getIncomingValue(0));
843 }
844};
845
846/// Match recipe recipe with Select opcode, i.e. excluding VPBlendRecipe.
847template <typename Op0_t, typename Op1_t, typename Op2_t>
849m_Select(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
851 {Op0, Op1, Op2});
852}
853
854/// Match recipe with Select opcode or an equivalent VPBlendRecipe with 2
855/// incoming values.
856template <typename Op0_t, typename Op1_t, typename Op2_t>
857inline auto m_SelectLike(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
858 return m_CombineOr(m_Select(Op0, Op1, Op2),
859 Blend2_match<Op0_t, Op1_t, Op2_t>(Op0, Op1, Op2));
860}
861
862template <typename Op0_t> inline auto m_Not(const Op0_t &Op0) {
865}
866
867template <typename Op0_t, typename Op1_t, typename Op2_t>
868inline auto m_c_Select(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
869 return m_CombineOr(m_Select(Op0, Op1, Op2), m_Select(m_Not(Op0), Op2, Op1));
870}
871
872template <typename Op0_t, typename Op1_t>
873inline auto m_LogicalAnd(const Op0_t &Op0, const Op1_t &Op1) {
874 return m_CombineOr(
876 m_Select(Op0, Op1, m_False()));
877}
878
879template <typename Op0_t, typename Op1_t>
880inline auto m_c_LogicalAnd(const Op0_t &Op0, const Op1_t &Op1) {
881 return m_CombineOr(
883 m_c_Select(Op0, Op1, m_False()));
884}
885
886template <typename Op0_t, typename Op1_t>
887inline auto m_LogicalOr(const Op0_t &Op0, const Op1_t &Op1) {
888 return m_CombineOr(
890 m_Select(Op0, m_True(), Op1));
891}
892
893template <typename Op0_t, typename Op1_t>
894inline auto m_c_LogicalOr(const Op0_t &Op0, const Op1_t &Op1) {
895 return m_c_Select(Op0, m_True(), Op1);
896}
897
898/// Match the canonical induction variable (IV) of any loop region.
900 template <typename ArgTy> bool match(const ArgTy *V) const {
901 const auto *RV = dyn_cast<VPRegionValue>(V);
902 return RV && RV->getDefiningRegion()->getCanonicalIV() == RV;
903 }
904};
905
906inline canonical_iv_match m_CanonicalIV() { return {}; }
907
908/// Match the abstract header mask of any loop region.
910 template <typename ArgTy> bool match(const ArgTy *V) const {
911 const auto *RV = dyn_cast<VPRegionValue>(V);
912 return RV && RV->getDefiningRegion()->getHeaderMask() == RV;
913 }
914};
915
916inline header_mask_match m_HeaderMask() { return {}; }
917
918/// Match a canonical VPWidenIntOrFpInductionRecipe optionally capturing it.
921
924
925 template <typename ArgTy> bool match(ArgTy *V) const {
927 if (!WidenIV || !WidenIV->isCanonical())
928 return false;
929 if (Capture)
930 *Capture = WidenIV;
931 return true;
932 }
933};
934
936
937/// Match a canonical VPWidenIntOrFpInductionRecipe, capturing it.
938inline canonical_widen_iv_match
942
943template <typename Op0_t, typename Op1_t, typename Op2_t>
944inline auto m_ScalarIVSteps(const Op0_t &Op0, const Op1_t &Op1,
945 const Op2_t &Op2) {
947 VPScalarIVStepsRecipe>({Op0, Op1, Op2});
948}
949
950template <typename Op0_t, typename Op1_t, typename Op2_t>
951inline auto m_DerivedIV(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
953 VPDerivedIVRecipe>({Op0, Op1, Op2});
954}
955
956template <typename Addr_t, typename Mask_t> struct Load_match {
957 Addr_t Addr;
958 Mask_t Mask;
959
960 Load_match(Addr_t Addr, Mask_t Mask) : Addr(Addr), Mask(Mask) {}
961
962 template <typename OpTy> bool match(const OpTy *V) const {
964 if (!Load || !Addr.match(Load->getAddr()) || !Load->isMasked() ||
965 !Mask.match(Load->getMask()))
966 return false;
967 return true;
968 }
969};
970
971/// Match a (possibly reversed) masked load.
972template <typename Addr_t, typename Mask_t>
973inline Load_match<Addr_t, Mask_t> m_MaskedLoad(const Addr_t &Addr,
974 const Mask_t &Mask) {
975 return Load_match<Addr_t, Mask_t>(Addr, Mask);
976}
977
978template <typename Addr_t, typename Val_t, typename Mask_t> struct Store_match {
979 Addr_t Addr;
980 Val_t Val;
981 Mask_t Mask;
982
983 Store_match(Addr_t Addr, Val_t Val, Mask_t Mask)
984 : Addr(Addr), Val(Val), Mask(Mask) {}
985
986 template <typename OpTy> bool match(const OpTy *V) const {
988 if (!Store || !Addr.match(Store->getAddr()) ||
989 !Val.match(Store->getStoredValue()) || !Store->isMasked() ||
990 !Mask.match(Store->getMask()))
991 return false;
992 return true;
993 }
994};
995
996/// Match a (possibly reversed) masked store.
997template <typename Addr_t, typename Val_t, typename Mask_t>
998inline Store_match<Addr_t, Val_t, Mask_t>
999m_MaskedStore(const Addr_t &Addr, const Val_t &Val, const Mask_t &Mask) {
1000 return Store_match<Addr_t, Val_t, Mask_t>(Addr, Val, Mask);
1001}
1002
1003template <typename Op0_t, typename Op1_t>
1006 /*Commutative*/ false, VPVectorEndPointerRecipe>;
1007
1008template <typename Op0_t, typename Op1_t>
1010 const Op1_t &Op1) {
1012}
1013
1014/// Match a call argument at a given argument index.
1015template <typename Opnd_t> struct Argument_match {
1016 /// Call argument index to match.
1017 unsigned OpI;
1018 Opnd_t Val;
1019
1020 Argument_match(unsigned OpIdx, const Opnd_t &V) : OpI(OpIdx), Val(V) {}
1021
1022 template <typename OpTy> bool match(OpTy *V) const {
1023 if (const auto *R = dyn_cast<VPWidenIntrinsicRecipe>(V))
1024 return Val.match(R->getOperand(OpI));
1025 if (const auto *R = dyn_cast<VPWidenCallRecipe>(V))
1026 return Val.match(R->getOperand(OpI));
1027 if (const auto *R = dyn_cast<VPReplicateRecipe>(V))
1028 if (R->getOpcode() == Instruction::Call)
1029 return Val.match(R->getOperand(OpI));
1030 if (const auto *R = dyn_cast<VPInstruction>(V))
1031 if (R->getOpcode() == Instruction::Call ||
1032 R->getOpcode() == VPInstruction::Intrinsic)
1033 return Val.match(R->getOperand(OpI));
1034 return false;
1035 }
1036};
1037
1038/// Match a call argument.
1039template <unsigned OpI, typename Opnd_t>
1040inline Argument_match<Opnd_t> m_Argument(const Opnd_t &Op) {
1041 return Argument_match<Opnd_t>(OpI, Op);
1042}
1043
1044/// Intrinsic matchers.
1046 unsigned ID;
1047
1049
1050 template <typename OpTy> bool match(OpTy *V) const {
1051 return vputils::getIntrinsicID(V) == ID;
1052 }
1053};
1054
1055/// Match intrinsic calls with a runtime intrinsic ID.
1057 return IntrinsicID_match(IntrID);
1058}
1059
1061 template <Intrinsic::ID IntrID, typename... Ts, size_t... Is>
1062 static auto impl(std::index_sequence<Is...>, const Ts &...Ops) {
1063 return m_CombineAnd(IntrinsicID_match(IntrID), m_Argument<Is>(Ops)...);
1064 }
1065};
1066
1067/// Match intrinsic calls like this:
1068/// m_Intrinsic<Intrinsic::fabs>(m_VPValue(X), ...)
1069template <Intrinsic::ID IntrID, typename... Ts>
1070inline auto m_Intrinsic(const Ts &...Ops) {
1072 std::make_index_sequence<sizeof...(Ts)>{}, Ops...);
1073}
1074
1075template <Intrinsic::ID IntrID, typename... T>
1076inline auto m_WidenIntrinsic(const T &...Ops) {
1078}
1079
1080/// Match VPValues that represent live-ins: VPIRValues and (plain)
1081/// VPSymbolicValues. VPRegionValues (which inherit from VPSymbolicValue) are
1082/// not live-ins and are excluded.
1084 template <typename ITy> bool match(ITy *V) const {
1085 return isa<VPIRValue>(V) ||
1087 }
1088};
1089
1090inline auto m_VScale() { return m_Intrinsic<Intrinsic::vscale>(); }
1091
1093
1094/// Match a GEP recipe (VPWidenGEPRecipe, VPInstruction, or VPReplicateRecipe)
1095/// and bind the source element type and operands.
1099
1102
1103 template <typename ITy> bool match(ITy *V) const {
1104 return matchRecipeAndBind<VPWidenGEPRecipe>(V) ||
1105 matchRecipeAndBind<VPInstruction>(V) ||
1106 matchRecipeAndBind<VPReplicateRecipe>(V);
1107 }
1108
1109private:
1110 template <typename RecipeTy> bool matchRecipeAndBind(const VPValue *V) const {
1111 auto *DefR = dyn_cast<RecipeTy>(V);
1112 if (!DefR)
1113 return false;
1114
1115 if constexpr (std::is_same_v<RecipeTy, VPWidenGEPRecipe>) {
1116 SourceElementType = DefR->getSourceElementType();
1117 } else if (DefR->getOpcode() == Instruction::GetElementPtr) {
1118 SourceElementType = cast<GetElementPtrInst>(DefR->getUnderlyingInstr())
1119 ->getSourceElementType();
1120 } else if constexpr (std::is_same_v<RecipeTy, VPInstruction>) {
1121 if (DefR->getOpcode() == VPInstruction::PtrAdd) {
1122 // PtrAdd is a byte-offset GEP with i8 element type.
1123 LLVMContext &Ctx = DefR->getParent()->getPlan()->getContext();
1125 } else {
1126 return false;
1127 }
1128 } else {
1129 return false;
1130 }
1131
1132 Operands = ArrayRef<VPValue *>(DefR->op_begin(), DefR->op_end());
1133 return true;
1134 }
1135};
1136
1137/// Match a GEP recipe with any number of operands and bind source element type
1138/// and operands.
1139inline GetElementPtr_match m_GetElementPtr(Type *&SourceElementType,
1141 return GetElementPtr_match(SourceElementType, Operands);
1142}
1143
1144template <typename SubPattern_t> struct OneUse_match {
1145 SubPattern_t SubPattern;
1146
1147 OneUse_match(const SubPattern_t &SP) : SubPattern(SP) {}
1148
1149 template <typename OpTy> bool match(OpTy *V) const {
1150 return V->hasOneUse() && SubPattern.match(V);
1151 }
1152};
1153
1154template <typename T> inline OneUse_match<T> m_OneUse(const T &SubPattern) {
1155 return SubPattern;
1156}
1157
1160 return V;
1161}
1162
1163template <typename Op0_t, typename Op1_t>
1164inline auto m_VPPhi(const Op0_t &Op0, const Op1_t &Op1) {
1165 return Recipe_match<std::tuple<Op0_t, Op1_t>, Instruction::PHI,
1166 /*Commutative*/ false, VPInstruction>({Op0, Op1});
1167}
1168
1169/// If \p V is used by a recipe matching pattern \p P, return it. Otherwise
1170/// return nullptr;
1171template <typename MatchT>
1172VPRecipeBase *findUserOf(VPValue *V, const MatchT &P) {
1173 auto It = find_if(V->users(), match_fn(P));
1174 return It == V->user_end() ? nullptr : cast<VPRecipeBase>(*It);
1175}
1176
1177/// If \p V is used by a VPInstruction with \p Opcode, return it. Otherwise
1178/// return nullptr.
1179template <unsigned Opcode> VPInstruction *findUserOf(VPValue *V) {
1181}
1182
1183template <typename RecipeTy> RecipeTy *findUserOf(VPValue *V) {
1185}
1186} // namespace llvm::VPlanPatternMatch
1187
1188#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
unsigned uint64_t
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static constexpr Value * getValue(Ty &ValueOrUse)
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
#define T
#define P(N)
SI Fold Operands
This file contains the declarations of the Vectorization Plan base classes:
Value * RHS
Value * LHS
Class for arbitrary precision integers.
Definition APInt.h:78
std::optional< uint64_t > tryZExtValue() const
Get zero extended value if possible.
Definition APInt.h:1573
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:551
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 Current into Start + Current * Step.
Definition VPlan.h:4194
This is a concrete Recipe that models a single VPlan-level instruction.
Definition VPlan.h:1235
@ ExtractLastActive
Extracts the last active lane from a set of vectors.
Definition VPlan.h:1345
@ Intrinsic
Calls a scalar intrinsic. The intrinsic ID is the last operand.
Definition VPlan.h:1365
VPRecipeBase is a base class modeling a sequence of one or more output IR instructions.
Definition VPlan.h:410
A recipe for handling reduction phis.
Definition VPlan.h:2870
VPReplicateRecipe replicates a given instruction producing multiple scalar copies of the original sca...
Definition VPlan.h:3405
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:618
This class augments VPValue with operands which provide the inverse def-use edges from VPValue's user...
Definition VPlanValue.h:401
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:2281
VPWidenCastRecipe is a recipe to create vector cast instructions.
Definition VPlan.h:1894
A recipe for handling GEP instructions.
Definition VPlan.h:2221
A recipe for handling phi nodes of integer and floating-point inductions, producing their vector valu...
Definition VPlan.h:2625
VPWidenRecipe is a recipe for producing a widened instruction using the opcode and operands of the re...
Definition VPlan.h:1828
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)
IntrinsicID_match m_Intrinsic(Intrinsic::ID IntrID)
Match intrinsic calls with a runtime intrinsic ID.
auto m_WidenAnyExtend(const Op0_t &Op0)
match_bind< VPIRValue > m_VPIRValue(VPIRValue *&V)
Match a VPIRValue.
VPInstruction_match< VPInstruction::WideActiveLaneMask, Op0_t, Op1_t, Op2_t > m_WideActiveLaneMask(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
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)
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()
auto match_fn(const Pattern &P)
A match functor that can be used as a UnaryPredicate in functional algorithms like all_of.
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)
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.
Recipe_match< std::tuple< OpTys... >, Opcode, true, VPWidenRecipe, VPReplicateRecipe, VPInstruction > AllRecipe_commutative_match
VPInstruction_match< VPInstruction::ExtractVectorForPart, Op0_t, Op1_t > m_ExtractVectorForPart(const Op0_t &Op0, const Op1_t &Op1)
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)
VPRecipeBase * findUserOf(VPValue *V, const MatchT &P)
If V is used by a recipe matching pattern P, return it.
AllRecipe_match< Instruction::BitCast, Op0_t > m_BitCast(const Op0_t &Op0)
VPInstruction_match< VPInstruction::Broadcast, Op0_t > m_Broadcast(const Op0_t &Op0)
bool match(Val *V, const Pattern &P)
header_mask_match m_HeaderMask()
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.
AllRecipe_match< Instruction::SDiv, Op0_t, Op1_t > m_SDiv(const Op0_t &Op0, const Op1_t &Op1)
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
AllRecipe_match< Instruction::SRem, Op0_t, Op1_t > m_SRem(const Op0_t &Op0, const Op1_t &Op1)
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)
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:85
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
@ Load
The value being inserted comes from a load (InsertElement only).
@ Store
The extracted value is stored (ExtractElement only).
auto cast_or_null(const Y &Val)
Definition Casting.h:714
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
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:1772
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878
Matcher to bind the captured value.
Matcher for a specific value, but stores a reference to the value, not the value itself.
A VPValue representing a live-in from the input IR or a constant.
Definition VPlanValue.h:279
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)
static auto impl(std::index_sequence< Is... >, const Ts &...Ops)
Match VPValues that represent live-ins: VPIRValues and (plain) VPSymbolicValues.
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 the abstract header mask 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)
bool match(const VPValue *V) const
bool match(const VPValue *VPV) const