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
21
22template <typename Val, typename Pattern> bool match(Val *V, const Pattern &P) {
23 return P.match(V);
24}
25
26/// A match functor that can be used as a UnaryPredicate in functional
27/// algorithms like all_of.
28template <typename Val, typename Pattern> auto match_fn(const Pattern &P) {
30}
31
32template <typename Pattern> bool match(VPUser *U, const Pattern &P) {
33 auto *R = dyn_cast<VPRecipeBase>(U);
34 return R && match(R, P);
35}
36
37/// Match functor for VPUser.
38template <typename Pattern> auto match_fn(const Pattern &P) {
40}
41
42template <typename Pattern> bool match(VPSingleDefRecipe *R, const Pattern &P) {
43 return P.match(static_cast<const VPRecipeBase *>(R));
44}
45
46template <typename... Classes> struct class_match {
47 template <typename ITy> bool match(ITy *V) const {
48 return isa<Classes...>(V);
49 }
50};
51
52/// Match an arbitrary VPValue and ignore it.
54
55template <typename Class> struct bind_ty {
56 Class *&VR;
57
58 bind_ty(Class *&V) : VR(V) {}
59
60 template <typename ITy> bool match(ITy *V) const {
61 if (auto *CV = dyn_cast<Class>(V)) {
62 VR = CV;
63 return true;
64 }
65 return false;
66 }
67};
68
69/// Match a specified VPValue.
71 const VPValue *Val;
72
73 specificval_ty(const VPValue *V) : Val(V) {}
74
75 bool match(const VPValue *VPV) const { return VPV == Val; }
76};
77
78inline specificval_ty m_Specific(const VPValue *VPV) { return VPV; }
79
80/// Stores a reference to the VPValue *, not the VPValue * itself,
81/// thus can be used in commutative matchers.
83 VPValue *const &Val;
84
85 deferredval_ty(VPValue *const &V) : Val(V) {}
86
87 bool match(const VPValue *const V) const { return V == Val; }
88};
89
90/// Like m_Specific(), but works if the specific value to match is determined
91/// as part of the same match() expression. For example:
92/// m_Mul(m_VPValue(X), m_Specific(X)) is incorrect, because m_Specific() will
93/// bind X before the pattern match starts.
94/// m_Mul(m_VPValue(X), m_Deferred(X)) is correct, and will check against
95/// whichever value m_VPValue(X) populated.
96inline deferredval_ty m_Deferred(VPValue *const &V) { return V; }
97
98/// Match an integer constant if Pred::isValue returns true for the APInt. \p
99/// BitWidth optionally specifies the bitwidth the matched constant must have.
100/// If it is 0, the matched constant can have any bitwidth.
101template <typename Pred, unsigned BitWidth = 0> struct int_pred_ty {
102 Pred P;
103
104 int_pred_ty(Pred P) : P(std::move(P)) {}
105 int_pred_ty() : P() {}
106
107 bool match(const VPValue *VPV) const {
108 auto *VPI = dyn_cast<VPInstruction>(VPV);
109 if (VPI && VPI->getOpcode() == VPInstruction::Broadcast)
110 VPV = VPI->getOperand(0);
111 auto *CI = dyn_cast<VPConstantInt>(VPV);
112 if (!CI)
113 return false;
114
115 if (BitWidth != 0 && CI->getBitWidth() != BitWidth)
116 return false;
117 return P.isValue(CI->getAPInt());
118 }
119};
120
121/// Match a specified signed or unsigned integer value.
125
128
129 bool isValue(const APInt &C) const {
131 }
132};
133
134template <unsigned Bitwidth = 0>
136
140
142 return specific_intval<0>(
143 is_specific_int(APInt(64, V, /*isSigned=*/true), /*IsSigned=*/true));
144}
145
149
153
155 bool isValue(const APInt &C) const { return C.isAllOnes(); }
156};
157
158/// Match an integer or vector with all bits set.
159/// For vectors, this includes constants with undefined elements.
163
165 bool isValue(const APInt &C) const { return C.isZero(); }
166};
167
168struct is_one {
169 bool isValue(const APInt &C) const { return C.isOne(); }
170};
171
172/// Match an integer 0 or a vector with all elements equal to 0.
173/// For vectors, this includes constants with undefined elements.
177
178/// Match an integer 1 or a vector with all elements equal to 1.
179/// For vectors, this includes constants with undefined elements.
181
183 const APInt *&Res;
184
185 bind_apint(const APInt *&Res) : Res(Res) {}
186
187 bool match(const VPValue *VPV) const {
188 auto *CI = dyn_cast<VPConstantInt>(VPV);
189 if (!CI)
190 return false;
191 Res = &CI->getAPInt();
192 return true;
193 }
194};
195
196inline bind_apint m_APInt(const APInt *&C) { return C; }
197
200
202
203 bool match(const VPValue *VPV) const {
204 const APInt *APConst;
205 if (!bind_apint(APConst).match(VPV))
206 return false;
207 if (auto C = APConst->tryZExtValue()) {
208 Res = *C;
209 return true;
210 }
211 return false;
212 }
213};
214
216 bool match(const VPValue *V) const {
217 return isa<VPIRValue>(V) &&
218 isa<PoisonValue>(cast<VPIRValue>(V)->getValue());
219 }
220};
221
222template <typename OpTy, typename... To> struct match_isa {
223 OpTy Op;
224
225 template <typename FromTy> bool match(FromTy *V) const {
226 return isa<To...>(V) && Op.match(V);
227 }
228};
229
230// Match isa<Ty>.
231template <typename... To, typename OpTy>
232inline match_isa<OpTy, To...> m_IsA(const OpTy &Op) {
233 return {Op};
234}
235
236/// Match a VPIRValue that's poison.
237inline match_poison m_Poison() { return match_poison(); }
238
239/// Match a plain integer constant no wider than 64-bits, capturing it if we
240/// match.
242
243/// Matching combinators
244template <typename LTy, typename RTy> struct match_combine_or {
245 LTy L;
246 RTy R;
247
248 match_combine_or(const LTy &Left, const RTy &Right) : L(Left), R(Right) {}
249
250 template <typename ITy> bool match(ITy *V) const {
251 return L.match(V) || R.match(V);
252 }
253};
254
255template <typename LTy, typename RTy> struct match_combine_and {
256 LTy L;
257 RTy R;
258
259 match_combine_and(const LTy &Left, const RTy &Right) : L(Left), R(Right) {}
260
261 template <typename ITy> bool match(ITy *V) const {
262 return L.match(V) && R.match(V);
263 }
264};
265
266/// Combine two pattern matchers matching L || R
267template <typename LTy, typename RTy>
268inline match_combine_or<LTy, RTy> m_CombineOr(const LTy &L, const RTy &R) {
269 return match_combine_or<LTy, RTy>(L, R);
270}
271
272/// Combine two pattern matchers matching L && R
273template <typename LTy, typename RTy>
274inline match_combine_and<LTy, RTy> m_CombineAnd(const LTy &L, const RTy &R) {
275 return match_combine_and<LTy, RTy>(L, R);
276}
277
278/// Match a VPValue, capturing it if we match.
279inline bind_ty<VPValue> m_VPValue(VPValue *&V) { return V; }
280
281/// Match a VPIRValue.
282inline bind_ty<VPIRValue> m_VPIRValue(VPIRValue *&V) { return V; }
283
284/// Match a VPInstruction, capturing if we match.
286
287template <typename Ops_t, unsigned Opcode, bool Commutative,
288 typename... RecipeTys>
290 Ops_t Ops;
291
292 template <typename... OpTy> Recipe_match(OpTy... Ops) : Ops(Ops...) {
293 static_assert(std::tuple_size<Ops_t>::value == sizeof...(Ops) &&
294 "number of operands in constructor doesn't match Ops_t");
295 static_assert((!Commutative || std::tuple_size<Ops_t>::value == 2) &&
296 "only binary ops can be commutative");
297 }
298
299 bool match(const VPValue *V) const {
300 auto *DefR = V->getDefiningRecipe();
301 return DefR && match(DefR);
302 }
303
304 bool match(const VPSingleDefRecipe *R) const {
305 return match(static_cast<const VPRecipeBase *>(R));
306 }
307
308 bool match(const VPRecipeBase *R) const {
309 if (std::tuple_size_v<Ops_t> == 0) {
310 auto *VPI = dyn_cast<VPInstruction>(R);
311 return VPI && VPI->getOpcode() == Opcode;
312 }
313
314 if ((!matchRecipeAndOpcode<RecipeTys>(R) && ...))
315 return false;
316
317 if (R->getNumOperands() < std::tuple_size<Ops_t>::value) {
318 [[maybe_unused]] auto *RepR = dyn_cast<VPReplicateRecipe>(R);
320 cast<VPInstruction>(R)->getNumOperandsForOpcode() == -1u) ||
321 (RepR && std::tuple_size_v<Ops_t> ==
322 RepR->getNumOperands() - RepR->isPredicated())) &&
323 "non-variadic recipe with matched opcode does not have the "
324 "expected number of operands");
325 return false;
326 }
327
328 // If the recipe has more operands than expected, we only support matching
329 // masked VPInstructions where the number of operands of the matcher is the
330 // same as the number of operands excluding mask.
331 if (R->getNumOperands() > std::tuple_size<Ops_t>::value) {
332 auto *VPI = dyn_cast<VPInstruction>(R);
333 if (!VPI || !VPI->isMasked() ||
334 VPI->getNumOperandsWithoutMask() != std::tuple_size<Ops_t>::value)
335 return false;
336 }
337
338 auto IdxSeq = std::make_index_sequence<std::tuple_size<Ops_t>::value>();
339 if (all_of_tuple_elements(IdxSeq, [R](auto Op, unsigned Idx) {
340 return Op.match(R->getOperand(Idx));
341 }))
342 return true;
343
344 return Commutative &&
345 all_of_tuple_elements(IdxSeq, [R](auto Op, unsigned Idx) {
346 return Op.match(R->getOperand(R->getNumOperands() - Idx - 1));
347 });
348 }
349
350private:
351 template <typename RecipeTy>
352 static bool matchRecipeAndOpcode(const VPRecipeBase *R) {
353 auto *DefR = dyn_cast<RecipeTy>(R);
354 // Check for recipes that do not have opcodes.
355 if constexpr (std::is_same_v<RecipeTy, VPScalarIVStepsRecipe> ||
356 std::is_same_v<RecipeTy, VPCanonicalIVPHIRecipe> ||
357 std::is_same_v<RecipeTy, VPDerivedIVRecipe> ||
358 std::is_same_v<RecipeTy, VPVectorEndPointerRecipe>)
359 return DefR;
360 else
361 return DefR && DefR->getOpcode() == Opcode;
362 }
363
364 /// Helper to check if predicate \p P holds on all tuple elements in Ops using
365 /// the provided index sequence.
366 template <typename Fn, std::size_t... Is>
367 bool all_of_tuple_elements(std::index_sequence<Is...>, Fn P) const {
368 return (P(std::get<Is>(Ops), Is) && ...);
369 }
370};
371
372template <unsigned Opcode, typename... OpTys>
374 Recipe_match<std::tuple<OpTys...>, Opcode, /*Commutative*/ false,
377
378template <unsigned Opcode, typename... OpTys>
380 Recipe_match<std::tuple<OpTys...>, Opcode, /*Commutative*/ true,
382
383template <unsigned Opcode, typename... OpTys>
384using VPInstruction_match = Recipe_match<std::tuple<OpTys...>, Opcode,
385 /*Commutative*/ false, VPInstruction>;
386
387template <unsigned Opcode, typename... OpTys>
389 Recipe_match<std::tuple<OpTys...>, Opcode,
390 /*Commutative*/ true, VPInstruction>;
391
392template <unsigned Opcode, typename... OpTys>
393inline VPInstruction_match<Opcode, OpTys...>
394m_VPInstruction(const OpTys &...Ops) {
395 return VPInstruction_match<Opcode, OpTys...>(Ops...);
396}
397
398template <unsigned Opcode, typename Op0_t, typename Op1_t>
400m_c_VPInstruction(const Op0_t &Op0, const Op1_t &Op1) {
402}
403
404/// BuildVector is matches only its opcode, w/o matching its operands as the
405/// number of operands is not fixed.
409
410template <typename Op0_t>
412m_Freeze(const Op0_t &Op0) {
414}
415
419
420template <typename Op0_t>
422m_BranchOnCond(const Op0_t &Op0) {
424}
425
430
431template <typename Op0_t, typename Op1_t>
433m_BranchOnTwoConds(const Op0_t &Op0, const Op1_t &Op1) {
435}
436
437template <typename Op0_t>
439m_Broadcast(const Op0_t &Op0) {
441}
442
443template <typename Op0_t>
445m_EVL(const Op0_t &Op0) {
447}
448
449template <typename Op0_t>
454
455template <typename Op0_t, typename Op1_t>
457m_ExtractElement(const Op0_t &Op0, const Op1_t &Op1) {
459}
460
461template <typename Op0_t, typename Op1_t>
463m_ExtractLane(const Op0_t &Op0, const Op1_t &Op1) {
465}
466
467template <typename Op0_t>
472
473template <typename Op0_t>
479}
480
481template <typename Op0_t>
486
487template <typename Op0_t, typename Op1_t, typename Op2_t>
489m_ActiveLaneMask(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
491}
492
496
497template <typename Op0_t, typename Op1_t>
499m_BranchOnCount(const Op0_t &Op0, const Op1_t &Op1) {
501}
502
506
507template <typename Op0_t>
509m_AnyOf(const Op0_t &Op0) {
511}
512
513template <typename Op0_t>
518
519template <typename Op0_t>
521m_LastActiveLane(const Op0_t &Op0) {
523}
524
525template <typename Op0_t, typename Op1_t, typename Op2_t>
527 Op2_t>
528m_ExtractLastActive(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
530}
531
532template <typename Op0_t>
537
538/// Match FindIV result pattern:
539/// select(icmp ne ComputeReductionResult(ReducedIV), Sentinel),
540/// ComputeReductionResult(ReducedIV), Start.
541template <typename Op0_t, typename Op1_t>
542inline bool matchFindIVResult(VPInstruction *VPI, Op0_t ReducedIV, Op1_t Start) {
544 m_ComputeReductionResult(ReducedIV),
545 m_VPValue()),
546 m_ComputeReductionResult(ReducedIV), Start));
547}
548
549template <typename Op0_t, typename Op1_t, typename Op2_t>
551 Op2_t>
552m_ComputeAnyOfResult(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
554}
555
556template <typename Op0_t>
558m_Reverse(const Op0_t &Op0) {
560}
561
565
566template <typename Op0_t>
568m_ExitingIVValue(const Op0_t &Op0) {
570}
571
572template <unsigned Opcode, typename Op0_t>
573inline AllRecipe_match<Opcode, Op0_t> m_Unary(const Op0_t &Op0) {
575}
576
577template <typename Op0_t>
581
582template <typename Op0_t>
584m_TruncOrSelf(const Op0_t &Op0) {
585 return m_CombineOr(m_Trunc(Op0), Op0);
586}
587
588template <typename Op0_t>
592
593template <typename Op0_t>
597
598template <typename Op0_t>
602
603template <typename Op0_t>
606m_ZExtOrSExt(const Op0_t &Op0) {
607 return m_CombineOr(m_ZExt(Op0), m_SExt(Op0));
608}
609
610template <typename Op0_t> inline auto m_WidenAnyExtend(const Op0_t &Op0) {
612}
613
614template <typename Op0_t>
616m_ZExtOrSelf(const Op0_t &Op0) {
617 return m_CombineOr(m_ZExt(Op0), Op0);
618}
619
620template <typename Op0_t>
621inline match_combine_or<
624 Op0_t>
625m_ZExtOrTruncOrSelf(const Op0_t &Op0) {
626 return m_CombineOr(m_CombineOr(m_ZExt(Op0), m_Trunc(Op0)), Op0);
627}
628
629template <unsigned Opcode, typename Op0_t, typename Op1_t>
631 const Op1_t &Op1) {
633}
634
635template <unsigned Opcode, typename Op0_t, typename Op1_t>
637m_c_Binary(const Op0_t &Op0, const Op1_t &Op1) {
639}
640
641template <typename Op0_t, typename Op1_t>
643 const Op1_t &Op1) {
645}
646
647template <typename Op0_t, typename Op1_t>
649m_c_Add(const Op0_t &Op0, const Op1_t &Op1) {
651}
652
653template <typename Op0_t, typename Op1_t>
655 const Op1_t &Op1) {
657}
658
659template <typename Op0_t, typename Op1_t>
661 const Op1_t &Op1) {
663}
664
665template <typename Op0_t, typename Op1_t>
667m_c_Mul(const Op0_t &Op0, const Op1_t &Op1) {
669}
670
671template <typename Op0_t, typename Op1_t>
673m_FMul(const Op0_t &Op0, const Op1_t &Op1) {
675}
676
677template <typename Op0_t, typename Op1_t>
679m_FAdd(const Op0_t &Op0, const Op1_t &Op1) {
681}
682
683template <typename Op0_t, typename Op1_t>
685m_c_FAdd(const Op0_t &Op0, const Op1_t &Op1) {
687}
688
689template <typename Op0_t, typename Op1_t>
691m_UDiv(const Op0_t &Op0, const Op1_t &Op1) {
693}
694
695/// Match a binary AND operation.
696template <typename Op0_t, typename Op1_t>
698m_c_BinaryAnd(const Op0_t &Op0, const Op1_t &Op1) {
700}
701
702/// Match a binary OR operation. Note that while conceptually the operands can
703/// be matched commutatively, \p Commutative defaults to false in line with the
704/// IR-based pattern matching infrastructure. Use m_c_BinaryOr for a commutative
705/// version of the matcher.
706template <typename Op0_t, typename Op1_t>
708m_BinaryOr(const Op0_t &Op0, const Op1_t &Op1) {
710}
711
712template <typename Op0_t, typename Op1_t>
714m_c_BinaryOr(const Op0_t &Op0, const Op1_t &Op1) {
716}
717
718/// Cmp_match is a variant of BinaryRecipe_match that also binds the comparison
719/// predicate. Opcodes must either be Instruction::ICmp or Instruction::FCmp, or
720/// both.
721template <typename Op0_t, typename Op1_t, unsigned... Opcodes>
722struct Cmp_match {
723 static_assert((sizeof...(Opcodes) == 1 || sizeof...(Opcodes) == 2) &&
724 "Expected one or two opcodes");
725 static_assert(
726 ((Opcodes == Instruction::ICmp || Opcodes == Instruction::FCmp) && ...) &&
727 "Expected a compare instruction opcode");
728
730 Op0_t Op0;
732
733 Cmp_match(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1)
734 : Predicate(&Pred), Op0(Op0), Op1(Op1) {}
735 Cmp_match(const Op0_t &Op0, const Op1_t &Op1) : Op0(Op0), Op1(Op1) {}
736
737 bool match(const VPValue *V) const {
738 auto *DefR = V->getDefiningRecipe();
739 return DefR && match(DefR);
740 }
741
742 bool match(const VPRecipeBase *V) const {
743 if ((m_Binary<Opcodes>(Op0, Op1).match(V) || ...)) {
744 if (Predicate)
745 *Predicate = cast<VPRecipeWithIRFlags>(V)->getPredicate();
746 return true;
747 }
748 return false;
749 }
750};
751
752/// SpecificCmp_match is a variant of Cmp_match that matches the comparison
753/// predicate, instead of binding it.
754template <typename Op0_t, typename Op1_t, unsigned... Opcodes>
757 Op0_t Op0;
759
760 SpecificCmp_match(CmpPredicate Pred, const Op0_t &LHS, const Op1_t &RHS)
761 : Predicate(Pred), Op0(LHS), Op1(RHS) {}
762
763 bool match(const VPValue *V) const {
764 auto *DefR = V->getDefiningRecipe();
765 return DefR && match(DefR);
766 }
767
768 bool match(const VPRecipeBase *V) const {
769 CmpPredicate CurrentPred;
770 return Cmp_match<Op0_t, Op1_t, Opcodes...>(CurrentPred, Op0, Op1)
771 .match(V) &&
773 }
774};
775
776template <typename Op0_t, typename Op1_t>
778 const Op1_t &Op1) {
780}
781
782template <typename Op0_t, typename Op1_t>
783inline Cmp_match<Op0_t, Op1_t, Instruction::ICmp>
784m_ICmp(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1) {
785 return Cmp_match<Op0_t, Op1_t, Instruction::ICmp>(Pred, Op0, Op1);
786}
787
788template <typename Op0_t, typename Op1_t>
789inline SpecificCmp_match<Op0_t, Op1_t, Instruction::ICmp>
790m_SpecificICmp(CmpPredicate MatchPred, const Op0_t &Op0, const Op1_t &Op1) {
792 Op1);
793}
794
795template <typename Op0_t, typename Op1_t>
796inline Cmp_match<Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp>
797m_Cmp(const Op0_t &Op0, const Op1_t &Op1) {
799 Op1);
800}
801
802template <typename Op0_t, typename Op1_t>
803inline Cmp_match<Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp>
804m_Cmp(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1) {
806 Pred, Op0, Op1);
807}
808
809template <typename Op0_t, typename Op1_t>
810inline SpecificCmp_match<Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp>
811m_SpecificCmp(CmpPredicate MatchPred, const Op0_t &Op0, const Op1_t &Op1) {
813 MatchPred, Op0, Op1);
814}
815
816template <typename Op0_t, typename Op1_t>
817inline auto m_GetElementPtr(const Op0_t &Op0, const Op1_t &Op1) {
818 return m_CombineOr(
819 Recipe_match<std::tuple<Op0_t, Op1_t>, Instruction::GetElementPtr,
820 /*Commutative*/ false, VPReplicateRecipe, VPWidenGEPRecipe>(
821 Op0, Op1),
825 Op1)));
826}
827
828template <typename Op0_t, typename Op1_t, typename Op2_t>
830m_Select(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
832 {Op0, Op1, Op2});
833}
834
835template <typename Op0_t> inline auto m_Not(const Op0_t &Op0) {
838}
839
840template <typename Op0_t, typename Op1_t, typename Op2_t>
841inline auto m_c_Select(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
842 return m_CombineOr(m_Select(Op0, Op1, Op2), m_Select(m_Not(Op0), Op2, Op1));
843}
844
845template <typename Op0_t, typename Op1_t>
846inline auto m_LogicalAnd(const Op0_t &Op0, const Op1_t &Op1) {
847 return m_CombineOr(
849 m_Select(Op0, Op1, m_False()));
850}
851
852template <typename Op0_t, typename Op1_t>
853inline auto m_c_LogicalAnd(const Op0_t &Op0, const Op1_t &Op1) {
854 return m_CombineOr(
856 m_c_Select(Op0, Op1, m_False()));
857}
858
859template <typename Op0_t, typename Op1_t>
860inline auto m_LogicalOr(const Op0_t &Op0, const Op1_t &Op1) {
861 return m_CombineOr(
863 m_Select(Op0, m_True(), Op1));
864}
865
866template <typename Op0_t, typename Op1_t>
867inline auto m_c_LogicalOr(const Op0_t &Op0, const Op1_t &Op1) {
868 return m_c_Select(Op0, m_True(), Op1);
869}
870
872
873template <typename Op0_t, typename Op1_t, typename Op2_t>
874inline auto m_ScalarIVSteps(const Op0_t &Op0, const Op1_t &Op1,
875 const Op2_t &Op2) {
877 VPScalarIVStepsRecipe>({Op0, Op1, Op2});
878}
879
880template <typename Op0_t, typename Op1_t, typename Op2_t>
881inline auto m_DerivedIV(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
883 VPDerivedIVRecipe>({Op0, Op1, Op2});
884}
885
886template <typename Addr_t, typename Mask_t> struct Load_match {
887 Addr_t Addr;
888 Mask_t Mask;
889
890 Load_match(Addr_t Addr, Mask_t Mask) : Addr(Addr), Mask(Mask) {}
891
892 template <typename OpTy> bool match(const OpTy *V) const {
893 auto *Load = dyn_cast<VPWidenLoadRecipe>(V);
894 if (!Load || !Addr.match(Load->getAddr()) || !Load->isMasked() ||
895 !Mask.match(Load->getMask()))
896 return false;
897 return true;
898 }
899};
900
901/// Match a (possibly reversed) masked load.
902template <typename Addr_t, typename Mask_t>
903inline Load_match<Addr_t, Mask_t> m_MaskedLoad(const Addr_t &Addr,
904 const Mask_t &Mask) {
905 return Load_match<Addr_t, Mask_t>(Addr, Mask);
906}
907
908template <typename Addr_t, typename Val_t, typename Mask_t> struct Store_match {
909 Addr_t Addr;
910 Val_t Val;
911 Mask_t Mask;
912
913 Store_match(Addr_t Addr, Val_t Val, Mask_t Mask)
914 : Addr(Addr), Val(Val), Mask(Mask) {}
915
916 template <typename OpTy> bool match(const OpTy *V) const {
917 auto *Store = dyn_cast<VPWidenStoreRecipe>(V);
918 if (!Store || !Addr.match(Store->getAddr()) ||
919 !Val.match(Store->getStoredValue()) || !Store->isMasked() ||
920 !Mask.match(Store->getMask()))
921 return false;
922 return true;
923 }
924};
925
926/// Match a (possibly reversed) masked store.
927template <typename Addr_t, typename Val_t, typename Mask_t>
928inline Store_match<Addr_t, Val_t, Mask_t>
929m_MaskedStore(const Addr_t &Addr, const Val_t &Val, const Mask_t &Mask) {
930 return Store_match<Addr_t, Val_t, Mask_t>(Addr, Val, Mask);
931}
932
933template <typename Op0_t, typename Op1_t>
936 /*Commutative*/ false, VPVectorEndPointerRecipe>;
937
938template <typename Op0_t, typename Op1_t>
943
944/// Match a call argument at a given argument index.
945template <typename Opnd_t> struct Argument_match {
946 /// Call argument index to match.
947 unsigned OpI;
948 Opnd_t Val;
949
950 Argument_match(unsigned OpIdx, const Opnd_t &V) : OpI(OpIdx), Val(V) {}
951
952 template <typename OpTy> bool match(OpTy *V) const {
953 if (const auto *R = dyn_cast<VPWidenIntrinsicRecipe>(V))
954 return Val.match(R->getOperand(OpI));
955 if (const auto *R = dyn_cast<VPWidenCallRecipe>(V))
956 return Val.match(R->getOperand(OpI));
957 if (const auto *R = dyn_cast<VPReplicateRecipe>(V))
958 if (R->getOpcode() == Instruction::Call)
959 return Val.match(R->getOperand(OpI));
960 if (const auto *R = dyn_cast<VPInstruction>(V))
961 if (R->getOpcode() == Instruction::Call)
962 return Val.match(R->getOperand(OpI));
963 return false;
964 }
965};
966
967/// Match a call argument.
968template <unsigned OpI, typename Opnd_t>
969inline Argument_match<Opnd_t> m_Argument(const Opnd_t &Op) {
970 return Argument_match<Opnd_t>(OpI, Op);
971}
972
973/// Intrinsic matchers.
975 unsigned ID;
976
977 IntrinsicID_match(Intrinsic::ID IntrID) : ID(IntrID) {}
978
979 template <typename OpTy> bool match(OpTy *V) const {
980 if (const auto *R = dyn_cast<VPWidenIntrinsicRecipe>(V))
981 return R->getVectorIntrinsicID() == ID;
982 if (const auto *R = dyn_cast<VPWidenCallRecipe>(V))
983 return R->getCalledScalarFunction()->getIntrinsicID() == ID;
984
985 auto MatchCalleeIntrinsic = [&](VPValue *CalleeOp) {
986 if (!isa<VPIRValue>(CalleeOp))
987 return false;
988 auto *F = cast<Function>(CalleeOp->getLiveInIRValue());
989 return F->getIntrinsicID() == ID;
990 };
991 if (const auto *R = dyn_cast<VPReplicateRecipe>(V))
992 if (R->getOpcode() == Instruction::Call) {
993 // The mask is always the last operand if predicated.
994 return MatchCalleeIntrinsic(
995 R->getOperand(R->getNumOperands() - 1 - R->isPredicated()));
996 }
997 if (const auto *R = dyn_cast<VPInstruction>(V))
998 if (R->getOpcode() == Instruction::Call)
999 return MatchCalleeIntrinsic(R->getOperand(R->getNumOperands() - 1));
1000 return false;
1001 }
1002};
1003
1004/// Intrinsic matches are combinations of ID matchers, and argument
1005/// matchers. Higher arity matcher are defined recursively in terms of and-ing
1006/// them with lower arity matchers. Here's some convenient typedefs for up to
1007/// several arguments, and more can be added as needed
1008template <typename T0 = void, typename T1 = void, typename T2 = void,
1009 typename T3 = void>
1010struct m_Intrinsic_Ty;
1011template <typename T0> struct m_Intrinsic_Ty<T0> {
1013};
1014template <typename T0, typename T1> struct m_Intrinsic_Ty<T0, T1> {
1015 using Ty =
1017};
1018template <typename T0, typename T1, typename T2>
1023template <typename T0, typename T1, typename T2, typename T3>
1028
1029/// Match intrinsic calls like this:
1030/// m_Intrinsic<Intrinsic::fabs>(m_VPValue(X), ...)
1031template <Intrinsic::ID IntrID> inline IntrinsicID_match m_Intrinsic() {
1032 return IntrinsicID_match(IntrID);
1033}
1034
1035/// Match intrinsic calls with a runtime intrinsic ID.
1037 return IntrinsicID_match(IntrID);
1038}
1039
1040template <Intrinsic::ID IntrID, typename T0>
1041inline typename m_Intrinsic_Ty<T0>::Ty m_Intrinsic(const T0 &Op0) {
1043}
1044
1045template <Intrinsic::ID IntrID, typename T0, typename T1>
1046inline typename m_Intrinsic_Ty<T0, T1>::Ty m_Intrinsic(const T0 &Op0,
1047 const T1 &Op1) {
1049}
1050
1051template <Intrinsic::ID IntrID, typename T0, typename T1, typename T2>
1052inline typename m_Intrinsic_Ty<T0, T1, T2>::Ty
1053m_Intrinsic(const T0 &Op0, const T1 &Op1, const T2 &Op2) {
1054 return m_CombineAnd(m_Intrinsic<IntrID>(Op0, Op1), m_Argument<2>(Op2));
1055}
1056
1057template <Intrinsic::ID IntrID, typename T0, typename T1, typename T2,
1058 typename T3>
1060m_Intrinsic(const T0 &Op0, const T1 &Op1, const T2 &Op2, const T3 &Op3) {
1061 return m_CombineAnd(m_Intrinsic<IntrID>(Op0, Op1, Op2), m_Argument<3>(Op3));
1062}
1063
1065
1066/// Match a GEP recipe (VPWidenGEPRecipe, VPInstruction, or VPReplicateRecipe)
1067/// and bind the source element type and operands.
1071
1074
1075 template <typename ITy> bool match(ITy *V) const {
1076 return matchRecipeAndBind<VPWidenGEPRecipe>(V) ||
1077 matchRecipeAndBind<VPInstruction>(V) ||
1078 matchRecipeAndBind<VPReplicateRecipe>(V);
1079 }
1080
1081private:
1082 template <typename RecipeTy> bool matchRecipeAndBind(const VPValue *V) const {
1083 auto *DefR = dyn_cast<RecipeTy>(V);
1084 if (!DefR)
1085 return false;
1086
1087 if constexpr (std::is_same_v<RecipeTy, VPWidenGEPRecipe>) {
1088 SourceElementType = DefR->getSourceElementType();
1089 } else if (DefR->getOpcode() == Instruction::GetElementPtr) {
1090 SourceElementType = cast<GetElementPtrInst>(DefR->getUnderlyingInstr())
1091 ->getSourceElementType();
1092 } else if constexpr (std::is_same_v<RecipeTy, VPInstruction>) {
1093 if (DefR->getOpcode() == VPInstruction::PtrAdd) {
1094 // PtrAdd is a byte-offset GEP with i8 element type.
1095 LLVMContext &Ctx = DefR->getParent()->getPlan()->getContext();
1097 } else {
1098 return false;
1099 }
1100 } else {
1101 return false;
1102 }
1103
1104 Operands = ArrayRef<VPValue *>(DefR->op_begin(), DefR->op_end());
1105 return true;
1106 }
1107};
1108
1109/// Match a GEP recipe with any number of operands and bind source element type
1110/// and operands.
1111inline GetElementPtr_match m_GetElementPtr(Type *&SourceElementType,
1112 ArrayRef<VPValue *> &Operands) {
1113 return GetElementPtr_match(SourceElementType, Operands);
1114}
1115
1116template <typename SubPattern_t> struct OneUse_match {
1117 SubPattern_t SubPattern;
1118
1119 OneUse_match(const SubPattern_t &SP) : SubPattern(SP) {}
1120
1121 template <typename OpTy> bool match(OpTy *V) {
1122 return V->hasOneUse() && SubPattern.match(V);
1123 }
1124};
1125
1126template <typename T> inline OneUse_match<T> m_OneUse(const T &SubPattern) {
1127 return SubPattern;
1128}
1129
1133
1134template <typename Op0_t, typename Op1_t>
1135inline auto m_VPPhi(const Op0_t &Op0, const Op1_t &Op1) {
1136 return Recipe_match<std::tuple<Op0_t, Op1_t>, Instruction::PHI,
1137 /*Commutative*/ false, VPInstruction>({Op0, Op1});
1138}
1139
1140} // namespace llvm::VPlanPatternMatch
1141
1142#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
#define F(x, y, z)
Definition MD5.cpp:54
#define T
#define T1
MachineInstr unsigned OpIdx
#define P(N)
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:1567
static bool isSameValue(const APInt &I1, const APInt &I2, bool SignedCompare=false)
Determine if two APInts have the same value, after zero-extending or sign-extending (if SignedCompare...
Definition APInt.h:555
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
@ ICMP_NE
not equal
Definition InstrTypes.h:698
An abstraction over a floating-point predicate, and a pack of an integer predicate with samesign info...
static LLVM_ABI std::optional< CmpPredicate > getMatching(CmpPredicate A, CmpPredicate B)
Compares two CmpPredicates taking samesign into account and returns the canonicalized CmpPredicate if...
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
static LLVM_ABI IntegerType * getInt8Ty(LLVMContext &C)
Definition Type.cpp:311
A recipe for converting the input value IV value to the corresponding value of an IV with different s...
Definition VPlan.h:4001
This is a concrete Recipe that models a single VPlan-level instruction.
Definition VPlan.h:1225
@ ExtractLastActive
Extracts the last active lane from a set of vectors.
Definition VPlan.h:1336
@ ComputeAnyOfResult
Compute the final result of a AnyOf reduction with select(cmp(),x,y), where one of (x,...
Definition VPlan.h:1272
VPRecipeBase is a base class modeling a sequence of one or more output IR instructions.
Definition VPlan.h:406
A recipe for handling reduction phis.
Definition VPlan.h:2700
VPReplicateRecipe replicates a given instruction producing multiple scalar copies of the original sca...
Definition VPlan.h:3217
A recipe for handling phi nodes of integer and floating-point inductions, producing their scalar valu...
Definition VPlan.h:4073
VPSingleDef is a base class for recipes for modeling a sequence of one or more output IR that define ...
Definition VPlan.h:607
This class augments VPValue with operands which provide the inverse def-use edges from VPValue's user...
Definition VPlanValue.h:296
This is the base class of the VPlan Def/Use graph, used for modeling the data flow into,...
Definition VPlanValue.h:46
A recipe to compute a pointer to the last element of each part of a widened memory access for widened...
Definition VPlan.h:2154
VPWidenCastRecipe is a recipe to create vector cast instructions.
Definition VPlan.h:1840
A recipe for handling GEP instructions.
Definition VPlan.h:2090
VPWidenRecipe is a recipe for producing a widened instruction using the opcode and operands of the re...
Definition VPlan.h:1784
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
class_match< ConstantInt > m_ConstantInt()
Match an arbitrary ConstantInt and ignore it.
auto m_LogicalOr()
Matches L || R where L and R are arbitrary values.
class_match< CmpInst > m_Cmp()
Matches any compare instruction and ignore it.
auto m_LogicalAnd()
Matches L && R where L and R are arbitrary values.
VPInstruction_match< VPInstruction::ExtractLastLane, VPInstruction_match< VPInstruction::ExtractLastPart, Op0_t > > m_ExtractLastLaneOfLastPart(const Op0_t &Op0)
AllRecipe_match< Instruction::Select, Op0_t, Op1_t, Op2_t > m_Select(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
VPInstruction_match< Instruction::Freeze, Op0_t > m_Freeze(const Op0_t &Op0)
AllRecipe_commutative_match< Instruction::And, Op0_t, Op1_t > m_c_BinaryAnd(const Op0_t &Op0, const Op1_t &Op1)
Match a binary AND operation.
AllRecipe_match< Instruction::ZExt, Op0_t > m_ZExt(const Op0_t &Op0)
AllRecipe_match< Instruction::Or, Op0_t, Op1_t > m_BinaryOr(const Op0_t &Op0, const Op1_t &Op1)
Match a binary OR operation.
int_pred_ty< is_specific_int, Bitwidth > specific_intval
Store_match< Addr_t, Val_t, Mask_t > m_MaskedStore(const Addr_t &Addr, const Val_t &Val, const Mask_t &Mask)
Match a (possibly reversed) masked store.
int_pred_ty< is_zero_int > m_ZeroInt()
Match an integer 0 or a vector with all elements equal to 0.
AllRecipe_match< Instruction::FMul, Op0_t, Op1_t > m_FMul(const Op0_t &Op0, const Op1_t &Op1)
SpecificCmp_match< Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp > m_SpecificCmp(CmpPredicate MatchPred, const Op0_t &Op0, const Op1_t &Op1)
VPInstruction_match< VPInstruction::AnyOf > m_AnyOf()
int_pred_ty< is_all_ones > m_AllOnes()
Match an integer or vector with all bits set.
AllRecipe_commutative_match< Opcode, Op0_t, Op1_t > m_c_Binary(const Op0_t &Op0, const Op1_t &Op1)
AllRecipe_commutative_match< Instruction::Add, Op0_t, Op1_t > m_c_Add(const Op0_t &Op0, const Op1_t &Op1)
AllRecipe_commutative_match< Instruction::Or, Op0_t, Op1_t > m_c_BinaryOr(const Op0_t &Op0, const Op1_t &Op1)
bool matchFindIVResult(VPInstruction *VPI, Op0_t ReducedIV, Op1_t Start)
Match FindIV result pattern: select(icmp ne ComputeReductionResult(ReducedIV), Sentinel),...
VPInstruction_match< VPInstruction::ComputeReductionResult, Op0_t > m_ComputeReductionResult(const Op0_t &Op0)
auto m_WidenAnyExtend(const Op0_t &Op0)
VPInstruction_match< VPInstruction::StepVector > m_StepVector()
auto m_c_LogicalOr(const Op0_t &Op0, const Op1_t &Op1)
match_combine_or< AllRecipe_match< Instruction::ZExt, Op0_t >, AllRecipe_match< Instruction::SExt, Op0_t > > m_ZExtOrSExt(const Op0_t &Op0)
match_combine_and< LTy, RTy > m_CombineAnd(const LTy &L, const RTy &R)
Combine two pattern matchers matching L && R.
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)
match_combine_or< LTy, RTy > m_CombineOr(const LTy &L, const RTy &R)
Combine two pattern matchers matching L || R.
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()
AllRecipe_match< Opcode, Op0_t, Op1_t > m_Binary(const Op0_t &Op0, const Op1_t &Op1)
bind_ty< VPReductionPHIRecipe > m_ReductionPhi(VPReductionPHIRecipe *&V)
auto match_fn(const Pattern &P)
A match functor that can be used as a UnaryPredicate in functional algorithms like all_of.
VPInstruction_match< VPInstruction::LastActiveLane, Op0_t > m_LastActiveLane(const Op0_t &Op0)
AllRecipe_match< Opcode, Op0_t > m_Unary(const Op0_t &Op0)
Recipe_match< std::tuple< OpTys... >, Opcode, true, VPInstruction > VPInstruction_commutative_match
AllRecipe_commutative_match< Instruction::FAdd, Op0_t, Op1_t > m_c_FAdd(const Op0_t &Op0, const Op1_t &Op1)
Load_match< Addr_t, Mask_t > m_MaskedLoad(const Addr_t &Addr, const Mask_t &Mask)
Match a (possibly reversed) masked load.
VPInstruction_match< VPInstruction::ExtractLastActive, Op0_t, Op1_t, Op2_t > m_ExtractLastActive(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
match_isa< OpTy, To... > m_IsA(const OpTy &Op)
match_combine_or< AllRecipe_match< Instruction::Trunc, Op0_t >, Op0_t > m_TruncOrSelf(const Op0_t &Op0)
AllRecipe_match< Instruction::FPExt, Op0_t > m_FPExt(const Op0_t &Op0)
AllRecipe_commutative_match< Instruction::Mul, Op0_t, Op1_t > m_c_Mul(const Op0_t &Op0, const Op1_t &Op1)
Cmp_match< Op0_t, Op1_t, Instruction::ICmp > m_ICmp(const Op0_t &Op0, const Op1_t &Op1)
AllRecipe_match< Instruction::Mul, Op0_t, Op1_t > m_Mul(const Op0_t &Op0, const Op1_t &Op1)
specificval_ty m_Specific(const VPValue *VPV)
VPInstruction_match< VPInstruction::ExitingIVValue, Op0_t > m_ExitingIVValue(const Op0_t &Op0)
VPInstruction_match< Instruction::ExtractElement, Op0_t, Op1_t > m_ExtractElement(const Op0_t &Op0, const Op1_t &Op1)
specific_intval< 1 > m_False()
VPInstruction_match< VPInstruction::ExtractLastLane, Op0_t > m_ExtractLastLane(const Op0_t &Op0)
specific_intval< 0 > m_SpecificInt(uint64_t V)
VPInstruction_match< VPInstruction::ActiveLaneMask, Op0_t, Op1_t, Op2_t > m_ActiveLaneMask(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
VPInstruction_match< VPInstruction::BranchOnCount > m_BranchOnCount()
bind_ty< VPIRValue > m_VPIRValue(VPIRValue *&V)
Match a VPIRValue.
auto m_GetElementPtr(const Op0_t &Op0, const Op1_t &Op1)
AllRecipe_match< Instruction::Sub, Op0_t, Op1_t > m_Sub(const Op0_t &Op0, const Op1_t &Op1)
AllRecipe_match< Instruction::SExt, Op0_t > m_SExt(const Op0_t &Op0)
VPInstruction_commutative_match< Opcode, Op0_t, Op1_t > m_c_VPInstruction(const Op0_t &Op0, const Op1_t &Op1)
specific_intval< 1 > m_True()
IntrinsicID_match m_Intrinsic()
Match intrinsic calls like this: m_Intrinsic<Intrinsic::fabs>(m_VPValue(X), ...)
Recipe_match< std::tuple< OpTys... >, Opcode, true, VPWidenRecipe, VPReplicateRecipe, VPInstruction > AllRecipe_commutative_match
specific_intval< 0 > m_SpecificSInt(int64_t V)
AllRecipe_match< Instruction::FAdd, Op0_t, Op1_t > m_FAdd(const Op0_t &Op0, const Op1_t &Op1)
deferredval_ty m_Deferred(VPValue *const &V)
Like m_Specific(), but works if the specific value to match is determined as part of the same match()...
VectorEndPointerRecipe_match< Op0_t, Op1_t > m_VecEndPtr(const Op0_t &Op0, const Op1_t &Op1)
VPInstruction_match< VPInstruction::ExtractLastPart, Op0_t > m_ExtractLastPart(const Op0_t &Op0)
VPInstruction_match< VPInstruction::Broadcast, Op0_t > m_Broadcast(const Op0_t &Op0)
bool match(Val *V, const Pattern &P)
class_match< VPValue > m_VPValue()
Match an arbitrary VPValue and ignore it.
OneUse_match< T > m_OneUse(const T &SubPattern)
VPInstruction_match< VPInstruction::ExplicitVectorLength, Op0_t > m_EVL(const Op0_t &Op0)
match_combine_or< match_combine_or< AllRecipe_match< Instruction::ZExt, Op0_t >, AllRecipe_match< Instruction::Trunc, Op0_t > >, Op0_t > m_ZExtOrTruncOrSelf(const Op0_t &Op0)
VPInstruction_match< VPInstruction::BuildVector > m_BuildVector()
BuildVector is matches only its opcode, w/o matching its operands as the number of operands is not fi...
AllRecipe_match< Instruction::Trunc, Op0_t > m_Trunc(const Op0_t &Op0)
VPInstruction_match< VPInstruction::ExtractPenultimateElement, Op0_t > m_ExtractPenultimateElement(const Op0_t &Op0)
Recipe_match< std::tuple< Op0_t, Op1_t >, 0, false, VPVectorEndPointerRecipe > VectorEndPointerRecipe_match
match_combine_or< AllRecipe_match< Instruction::ZExt, Op0_t >, Op0_t > m_ZExtOrSelf(const Op0_t &Op0)
VPInstruction_match< VPInstruction::FirstActiveLane, Op0_t > m_FirstActiveLane(const Op0_t &Op0)
Argument_match< Opnd_t > m_Argument(const Opnd_t &Op)
Match a call argument.
bind_ty< VPInstruction > m_VPInstruction(VPInstruction *&V)
Match a VPInstruction, capturing if we match.
VPInstruction_match< VPInstruction::ComputeAnyOfResult, Op0_t, Op1_t, Op2_t > m_ComputeAnyOfResult(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
AllRecipe_match< Instruction::UDiv, Op0_t, Op1_t > m_UDiv(const Op0_t &Op0, const Op1_t &Op1)
auto m_Not(const Op0_t &Op0)
auto m_DerivedIV(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
auto m_c_LogicalAnd(const Op0_t &Op0, const Op1_t &Op1)
int_pred_ty< is_one > m_One()
Match an integer 1 or a vector with all elements equal to 1.
Recipe_match< std::tuple< OpTys... >, Opcode, false, VPWidenRecipe, VPReplicateRecipe, VPWidenCastRecipe, VPInstruction > AllRecipe_match
VPInstruction_match< VPInstruction::BranchOnCond > m_BranchOnCond()
auto m_ScalarIVSteps(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
VPInstruction_match< VPInstruction::ExtractLane, Op0_t, Op1_t > m_ExtractLane(const Op0_t &Op0, const Op1_t &Op1)
bind_apint m_APInt(const APInt *&C)
VPInstruction_match< VPInstruction::Reverse, Op0_t > m_Reverse(const Op0_t &Op0)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
constexpr auto bind_back(FnT &&Fn, BindArgsT &&...BindArgs)
C++23 bind_back.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
constexpr unsigned BitWidth
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1917
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:870
Intrinsic matches are combinations of ID matchers, and argument matchers.
A VPValue representing a live-in from the input IR or a constant.
Definition VPlanValue.h:207
Match a call argument at a given argument index.
unsigned OpI
Call argument index to match.
Argument_match(unsigned OpIdx, const Opnd_t &V)
Cmp_match is a variant of BinaryRecipe_match that also binds the comparison predicate.
Cmp_match(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1)
Cmp_match(const Op0_t &Op0, const Op1_t &Op1)
bool match(const VPValue *V) const
bool match(const VPRecipeBase *V) const
Match a GEP recipe (VPWidenGEPRecipe, VPInstruction, or VPReplicateRecipe) and bind the source elemen...
GetElementPtr_match(Type *&SourceElementType, ArrayRef< VPValue * > &Operands)
Load_match(Addr_t Addr, Mask_t Mask)
bool match(const VPSingleDefRecipe *R) const
bool match(const VPValue *V) const
bool match(const VPRecipeBase *R) const
SpecificCmp_match is a variant of Cmp_match that matches the comparison predicate,...
SpecificCmp_match(CmpPredicate Pred, const Op0_t &LHS, const Op1_t &RHS)
bool match(const VPRecipeBase *V) const
Store_match(Addr_t Addr, Val_t Val, Mask_t Mask)
bool match(const VPValue *VPV) const
bool match(const VPValue *VPV) const
Stores a reference to the VPValue *, not the VPValue * itself, thus can be used in commutative matche...
bool match(const VPValue *const V) const
Match an integer constant if Pred::isValue returns true for the APInt.
bool match(const VPValue *VPV) const
bool isValue(const APInt &C) const
Match a specified signed or unsigned integer value.
is_specific_int(APInt Val, bool IsSigned=false)
match_combine_and< typename m_Intrinsic_Ty< T0, T1 >::Ty, Argument_match< T2 > > Ty
match_combine_and< typename m_Intrinsic_Ty< T0 >::Ty, Argument_match< T1 > > Ty
match_combine_and< IntrinsicID_match, Argument_match< T0 > > Ty
Intrinsic matches are combinations of ID matchers, and argument matchers.
match_combine_and< typename m_Intrinsic_Ty< T0, T1, T2 >::Ty, Argument_match< T3 > > Ty
match_combine_and(const LTy &Left, const RTy &Right)
match_combine_or(const LTy &Left, const RTy &Right)
bool match(const VPValue *V) const
bool match(const VPValue *VPV) const