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"
22#include <utility>
23
25
26using namespace llvm::PatternMatchHelpers;
27
28template <typename Val, typename Pattern> bool match(Val *V, const Pattern &P) {
29 return P.match(V);
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
37template <typename Pattern> bool match(VPSingleDefRecipe *R, const Pattern &P) {
38 return P.match(static_cast<const VPRecipeBase *>(R));
39}
40
41/// A match functor that can be used as a UnaryPredicate in functional
42/// algorithms like all_of.
43template <typename Pattern> auto match_fn(const Pattern &P) {
44 return [&P](auto *V) { return match(V, P); };
45}
46
47/// Match an arbitrary VPValue and ignore it.
48inline auto m_VPValue() { return m_Isa<VPValue>(); }
49
50/// Match a specified VPValue.
52 const VPValue *Val;
53
55
56 bool match(const VPValue *VPV) const { return VPV == Val; }
57 bool match(const VPRecipeBase *R) const {
58 return R->getNumDefinedValues() == 1 && R->getVPSingleValue() == Val;
59 }
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 {
77
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
121 bool isValue(const APInt &C) const { return C.isAllOnes(); }
122};
123
124/// Match an integer or vector with all bits set.
125/// For vectors, this includes constants with undefined elements.
129
131 bool isValue(const APInt &C) const { return C.isZero(); }
132};
133
134struct is_one {
135 bool isValue(const APInt &C) const { return C.isOne(); }
136};
137
138/// Match an integer 0 or a vector with all elements equal to 0.
139/// For vectors, this includes constants with undefined elements.
143
144/// Match an integer 1 or a vector with all elements equal to 1.
145/// For vectors, this includes constants with undefined elements.
147
149
150inline int_pred_ty<is_one, 1> m_True() { return {}; }
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.
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.
215
216/// Match a VPInstruction, capturing if we match.
220
221template <typename T>
222using hasOpcode_t = decltype(std::declval<T &>().getOpcode()); // NOLINT
223
224template <typename Ops_t, unsigned Opcode, bool Commutative,
225 typename... RecipeTys>
227 Ops_t Ops;
228
229 template <typename... OpTy> Recipe_match(OpTy... Ops) : Ops(Ops...) {
230 static_assert(std::tuple_size<Ops_t>::value == sizeof...(Ops) &&
231 "number of operands in constructor doesn't match Ops_t");
232 static_assert((!Commutative || std::tuple_size<Ops_t>::value == 2) &&
233 "only binary ops can be commutative");
234 }
235
236 bool match(const VPValue *V) const {
237 auto *DefR = V->getDefiningRecipe();
238 return DefR && match(DefR);
239 }
240
241 bool match(const VPSingleDefRecipe *R) const {
242 return match(static_cast<const VPRecipeBase *>(R));
243 }
244
245 bool match(const VPRecipeBase *R) const {
246 if (std::tuple_size_v<Ops_t> == 0) {
247 auto *VPI = dyn_cast<VPInstruction>(R);
248 return VPI && VPI->getOpcode() == Opcode;
249 }
250
251 if ((!matchRecipeAndOpcode<RecipeTys>(R) && ...))
252 return false;
253
254 if (R->getNumOperands() < std::tuple_size<Ops_t>::value) {
255 [[maybe_unused]] auto *RepR = dyn_cast<VPReplicateRecipe>(R);
257 cast<VPInstruction>(R)->getNumOperandsForOpcode() == -1u) ||
258 (RepR && std::tuple_size_v<Ops_t> ==
259 RepR->getNumOperandsWithoutMask())) &&
260 "non-variadic recipe with matched opcode does not have the "
261 "expected number of operands");
262 return false;
263 }
264
265 // If the recipe has more operands than expected, we only support matching
266 // masked VPInstructions or predicated VPReplicateRecipes, where the number
267 // of operands of the matcher matches the number of operands excluding the
268 // mask.
269 if (R->getNumOperands() > std::tuple_size<Ops_t>::value) {
270 if (auto *VPI = dyn_cast<VPInstruction>(R)) {
271 if (!VPI->isMasked() ||
272 VPI->getNumOperandsWithoutMask() != std::tuple_size<Ops_t>::value)
273 return false;
274 } else if (auto *RepR = dyn_cast<VPReplicateRecipe>(R)) {
275 if (!RepR->isPredicated() ||
276 RepR->getNumOperandsWithoutMask() != std::tuple_size<Ops_t>::value)
277 return false;
278 } else {
279 return false;
280 }
281 }
282
283 auto IdxSeq = std::make_index_sequence<std::tuple_size<Ops_t>::value>();
284 if (all_of_tuple_elements(IdxSeq, [R](auto Op, unsigned Idx) {
285 return Op.match(R->getOperand(Idx));
286 }))
287 return true;
288
289 return Commutative &&
290 all_of_tuple_elements(IdxSeq, [R](auto Op, unsigned Idx) {
291 return Op.match(R->getOperand(R->getNumOperands() - Idx - 1));
292 });
293 }
294
295private:
296 template <typename RecipeTy>
297 static bool matchRecipeAndOpcode(const VPRecipeBase *R) {
298 auto *DefR = dyn_cast<RecipeTy>(R);
299 if constexpr (Opcode && is_detected<hasOpcode_t, RecipeTy>::value)
300 return DefR && DefR->getOpcode() == Opcode;
301 return DefR;
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
351template <typename Op0_t>
353m_Freeze(const Op0_t &Op0) {
355}
356
360
361template <typename Op0_t>
366
371
372template <typename Op0_t, typename Op1_t>
374m_BranchOnTwoConds(const Op0_t &Op0, const Op1_t &Op1) {
376}
377
381
382template <typename Op0_t, typename Op1_t>
384m_BranchOnCount(const Op0_t &Op0, const Op1_t &Op1) {
386}
387
388inline auto m_Branch() {
390}
391
392template <typename Op0_t>
397
398template <typename Op0_t>
403
404template <typename Op0_t>
409
410template <typename Op0_t, typename Op1_t>
412m_ExtractElement(const Op0_t &Op0, const Op1_t &Op1) {
414}
415
416template <typename Op0_t, typename Op1_t, typename Op2_t>
418m_InsertElement(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
420}
421
422template <typename Op0_t, typename Op1_t>
424m_ExtractLane(const Op0_t &Op0, const Op1_t &Op1) {
426}
427
428template <typename Op0_t>
433
434template <typename Op0_t>
441
442template <typename... Op_t>
444m_ExtractVectorForPart(const Op_t &...Op) {
445 static_assert(sizeof...(Op) == 2 || sizeof...(Op) == 0,
446 "Expected two operands (or none for a wildcard match)");
448}
449
450template <typename Op0_t>
455
456template <typename... Op_t>
458m_WideActiveLaneMask(const Op_t &...Op) {
459 static_assert(sizeof...(Op) == 3 || sizeof...(Op) == 0,
460 "Expected three operands (or none for a wildcard match)");
462}
463
467
468template <typename Op0_t>
470m_AnyOf(const Op0_t &Op0) {
472}
473
474template <typename Op0_t>
479
480template <typename Op0_t>
485
486template <typename Op0_t, typename Op1_t, typename Op2_t>
488 Op2_t>
489m_ExtractLastActive(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
491}
492
493template <typename Op0_t>
498
499/// Match FindIV result pattern:
500/// select(icmp ne ComputeReductionResult(ReducedIV), Sentinel),
501/// ComputeReductionResult(ReducedIV), Start.
502template <typename Op0_t, typename Op1_t>
503inline bool matchFindIVResult(VPInstruction *VPI, Op0_t ReducedIV, Op1_t Start) {
505 m_ComputeReductionResult(ReducedIV),
506 m_VPValue()),
507 m_ComputeReductionResult(ReducedIV), Start));
508}
509
510template <typename Op0_t>
512m_Reverse(const Op0_t &Op0) {
514}
515
519
520template <typename Op0_t>
525
526template <unsigned Opcode, typename Op0_t>
530
531template <typename Op0_t>
535
536template <typename Op0_t>
538m_TruncOrSelf(const Op0_t &Op0) {
539 return m_CombineOr(m_Trunc(Op0), Op0);
540}
541
542template <typename Op0_t>
546
547template <typename Op0_t>
551
552template <typename Op0_t>
556
557template <typename Op0_t>
559m_BitCast(const Op0_t &Op0) {
561}
562
563template <typename Op0_t>
565m_PtrToAddr(const Op0_t &Op0) {
567}
568
569template <typename Op0_t>
573
574template <typename Op0_t>
577m_ZExtOrSExt(const Op0_t &Op0) {
578 return m_CombineOr(m_ZExt(Op0), m_SExt(Op0));
579}
580
581template <typename Op0_t> inline auto m_WidenAnyExtend(const Op0_t &Op0) {
583}
584
585template <typename Op0_t> inline auto m_AnyNeg(const Op0_t &Op0) {
586 return m_CombineOr(m_Sub(m_ZeroInt(), Op0), m_FNeg(Op0));
587}
588
589template <typename Op0_t>
591m_ZExtOrSelf(const Op0_t &Op0) {
592 return m_CombineOr(m_ZExt(Op0), Op0);
593}
594
595template <typename Op0_t> inline auto m_ZExtOrTrunc(const Op0_t &Op0) {
596 return m_CombineOr(m_ZExt(Op0), m_Trunc(Op0));
597}
598
599template <typename Op0_t> inline auto m_ZExtOrTruncOrSelf(const Op0_t &Op0) {
600 return m_CombineOr(m_ZExtOrTrunc(Op0), Op0);
601}
602
603template <unsigned Opcode, typename Op0_t, typename Op1_t>
605 const Op1_t &Op1) {
607}
608
609template <unsigned Opcode, typename Op0_t, typename Op1_t>
611m_c_Binary(const Op0_t &Op0, const Op1_t &Op1) {
613}
614
615template <typename Op0_t, typename Op1_t>
620
621template <typename Op0_t, typename Op1_t>
623m_c_Add(const Op0_t &Op0, const Op1_t &Op1) {
625}
626
627template <typename Op0_t, typename Op1_t>
632
633template <typename Op0_t, typename Op1_t>
638
639template <typename Op0_t, typename Op1_t>
641m_c_Mul(const Op0_t &Op0, const Op1_t &Op1) {
643}
644
645template <typename Op0_t, typename Op1_t>
650
651template <typename Op0_t, typename Op1_t>
653m_LShr(const Op0_t &Op0, const Op1_t &Op1) {
655}
656
657template <typename Op0_t, typename Op1_t>
659m_AShr(const Op0_t &Op0, const Op1_t &Op1) {
661}
662
663template <typename Op0_t, typename Op1_t>
665m_FMul(const Op0_t &Op0, const Op1_t &Op1) {
667}
668
669template <typename Op0_t, typename Op1_t>
671m_FAdd(const Op0_t &Op0, const Op1_t &Op1) {
673}
674
675template <typename Op0_t, typename Op1_t>
677m_c_FAdd(const Op0_t &Op0, const Op1_t &Op1) {
679}
680
681template <typename Op0_t, typename Op1_t>
683m_UDiv(const Op0_t &Op0, const Op1_t &Op1) {
685}
686
687template <typename Op0_t, typename Op1_t>
689m_URem(const Op0_t &Op0, const Op1_t &Op1) {
691}
692
693template <typename Op0_t, typename Op1_t>
695m_SDiv(const Op0_t &Op0, const Op1_t &Op1) {
697}
698
699template <typename Op0_t, typename Op1_t>
701m_SRem(const Op0_t &Op0, const Op1_t &Op1) {
703}
704
705/// Match a binary AND operation.
706template <typename Op0_t, typename Op1_t>
708m_c_BinaryAnd(const Op0_t &Op0, const Op1_t &Op1) {
710}
711
712/// Match a binary OR operation. Note that while conceptually the operands can
713/// be matched commutatively, \p Commutative defaults to false in line with the
714/// IR-based pattern matching infrastructure. Use m_c_BinaryOr for a commutative
715/// version of the matcher.
716template <typename Op0_t, typename Op1_t>
718m_BinaryOr(const Op0_t &Op0, const Op1_t &Op1) {
720}
721
722template <typename Op0_t, typename Op1_t>
724m_c_BinaryOr(const Op0_t &Op0, const Op1_t &Op1) {
726}
727
728/// Cmp_match is a variant of BinaryRecipe_match that also binds the comparison
729/// predicate. Opcodes must either be Instruction::ICmp or Instruction::FCmp, or
730/// both.
731template <typename Op0_t, typename Op1_t, unsigned... Opcodes>
732struct Cmp_match {
733 static_assert((sizeof...(Opcodes) == 1 || sizeof...(Opcodes) == 2) &&
734 "Expected one or two opcodes");
735 static_assert(
736 ((Opcodes == Instruction::ICmp || Opcodes == Instruction::FCmp) && ...) &&
737 "Expected a compare instruction opcode");
738
742
744 : Predicate(&Pred), Op0(Op0), Op1(Op1) {}
745 Cmp_match(const Op0_t &Op0, const Op1_t &Op1) : Op0(Op0), Op1(Op1) {}
746
747 bool match(const VPValue *V) const {
748 auto *DefR = V->getDefiningRecipe();
749 return DefR && match(DefR);
750 }
751
752 bool match(const VPRecipeBase *V) const {
753 if ((m_Binary<Opcodes>(Op0, Op1).match(V) || ...)) {
754 if (Predicate)
755 *Predicate = cast<VPRecipeWithIRFlags>(V)->getPredicate();
756 return true;
757 }
758 return false;
759 }
760};
761
762/// SpecificCmp_match is a variant of Cmp_match that matches the comparison
763/// predicate, instead of binding it.
764template <typename Op0_t, typename Op1_t, unsigned... Opcodes>
769
772
773 bool match(const VPValue *V) const {
774 auto *DefR = V->getDefiningRecipe();
775 return DefR && match(DefR);
776 }
777
778 bool match(const VPRecipeBase *V) const {
779 CmpPredicate CurrentPred;
780 return Cmp_match<Op0_t, Op1_t, Opcodes...>(CurrentPred, Op0, Op1)
781 .match(V) &&
783 }
784};
785
786template <typename Op0_t, typename Op1_t>
791
792template <typename Op0_t, typename Op1_t>
793inline auto m_c_ICmp(const Op0_t &Op0, const Op1_t &Op1) {
796}
797
798template <typename Op0_t, typename Op1_t>
799inline Cmp_match<Op0_t, Op1_t, Instruction::ICmp>
800m_ICmp(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1) {
802}
803
804template <typename Op0_t, typename Op1_t>
805inline SpecificCmp_match<Op0_t, Op1_t, Instruction::ICmp>
806m_SpecificICmp(CmpPredicate MatchPred, const Op0_t &Op0, const Op1_t &Op1) {
808 Op1);
809}
810
811template <typename Op0_t, typename Op1_t>
812inline Cmp_match<Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp>
813m_Cmp(const Op0_t &Op0, const Op1_t &Op1) {
815 Op1);
816}
817
818template <typename Op0_t, typename Op1_t>
824
825template <typename Op0_t, typename Op1_t>
826inline Cmp_match<Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp>
827m_Cmp(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1) {
829 Pred, Op0, Op1);
830}
831
832template <typename Op0_t, typename Op1_t>
833inline SpecificCmp_match<Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp>
834m_SpecificCmp(CmpPredicate MatchPred, const Op0_t &Op0, const Op1_t &Op1) {
836 MatchPred, Op0, Op1);
837}
838
839template <typename Op0_t, typename Op1_t>
840inline auto m_GetElementPtr(const Op0_t &Op0, const Op1_t &Op1) {
841 return m_CombineOr(
842 Recipe_match<std::tuple<Op0_t, Op1_t>, Instruction::GetElementPtr,
843 /*Commutative*/ false, VPReplicateRecipe, VPWidenGEPRecipe>(
844 Op0, Op1),
847}
848
849/// Match a VPBlendRecipe with 2 incoming values ([I0, I1, M1] ==
850/// normalized([I0, M0, I1, M1])) as select(M1, I1, I0), mirroring how it is
851/// lowered.
852template <typename Op0_t, typename Op1_t, typename Op2_t> struct Blend2_match {
855 Op2_t FalseOp;
856
857 Blend2_match(const Op0_t &MaskOp, const Op1_t &TrueOp, const Op2_t &FalseOp)
859
860 template <typename T> bool match(const T *Val) const {
861 auto *Blend = dyn_cast<VPBlendRecipe>(Val);
862 if (!Blend || Blend->getNumIncomingValues() != 2)
863 return false;
864 return MaskOp.match(Blend->getMask(1)) &&
865 TrueOp.match(Blend->getIncomingValue(1)) &&
866 FalseOp.match(Blend->getIncomingValue(0));
867 }
868};
869
870/// Match recipe recipe with Select opcode, i.e. excluding VPBlendRecipe.
871template <typename Op0_t, typename Op1_t, typename Op2_t>
873m_Select(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
875 {Op0, Op1, Op2});
876}
877
878/// Match recipe with Select opcode or an equivalent VPBlendRecipe with 2
879/// incoming values.
880template <typename Op0_t, typename Op1_t, typename Op2_t>
881inline auto m_SelectLike(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
882 return m_CombineOr(m_Select(Op0, Op1, Op2),
883 Blend2_match<Op0_t, Op1_t, Op2_t>(Op0, Op1, Op2));
884}
885
886template <typename Op0_t> inline auto m_Not(const Op0_t &Op0) {
889}
890
891template <typename Op0_t, typename Op1_t, typename Op2_t>
892inline auto m_c_Select(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
893 return m_CombineOr(m_Select(Op0, Op1, Op2), m_Select(m_Not(Op0), Op2, Op1));
894}
895
896template <typename Op0_t, typename Op1_t>
897inline auto m_LogicalAnd(const Op0_t &Op0, const Op1_t &Op1) {
898 return m_CombineOr(
900 m_Select(Op0, Op1, m_False()));
901}
902
903template <typename Op0_t, typename Op1_t> struct RemoveMask_match {
906
908
909 template <typename OpTy> bool match(OpTy *V) const {
910 if (m_Specific(In).match(V)) {
911 Out = nullptr;
912 return true;
913 }
914 return m_LogicalAnd(m_Specific(In), m_VPValue(Out)).match(V);
915 }
916};
917
918/// Match a specific mask \p In, or a combination of it (logical-and In, Out).
919/// Returns the remaining part \p Out if so, or nullptr otherwise.
920template <typename Op0_t, typename Op1_t>
922 Op1_t &Out) {
923 return RemoveMask_match<Op0_t, Op1_t>(In, Out);
924}
925
926template <typename Op0_t, typename Op1_t>
927inline auto m_c_LogicalAnd(const Op0_t &Op0, const Op1_t &Op1) {
928 return m_CombineOr(
930 m_c_Select(Op0, Op1, m_False()));
931}
932
933template <typename Op0_t, typename Op1_t>
934inline auto m_LogicalOr(const Op0_t &Op0, const Op1_t &Op1) {
935 return m_CombineOr(
937 m_Select(Op0, m_True(), Op1));
938}
939
940template <typename Op0_t, typename Op1_t>
941inline auto m_c_LogicalOr(const Op0_t &Op0, const Op1_t &Op1) {
942 return m_CombineOr(m_c_Select(Op0, m_True(), Op1),
943 m_c_Select(Op1, m_True(), Op0));
944}
945
946/// Match the canonical induction variable (IV) of any loop region.
948 template <typename ArgTy> bool match(const ArgTy *V) const {
949 const auto *RV = dyn_cast<VPRegionValue>(V);
950 return RV && RV->getDefiningRegion()->getCanonicalIV() == RV;
951 }
952};
953
954inline canonical_iv_match m_CanonicalIV() { return {}; }
955
956/// Match the abstract header mask of any loop region.
958 template <typename ArgTy> bool match(const ArgTy *V) const {
959 const auto *RV = dyn_cast<VPRegionValue>(V);
960 return RV && RV->getDefiningRegion()->getHeaderMask() == RV;
961 }
962};
963
964inline header_mask_match m_HeaderMask() { return {}; }
965
966/// Match a canonical VPWidenIntOrFpInductionRecipe optionally capturing it.
969
972
973 template <typename ArgTy> bool match(ArgTy *V) const {
975 if (!WidenIV || !WidenIV->isCanonical())
976 return false;
977 if (Capture)
978 *Capture = WidenIV;
979 return true;
980 }
981};
982
984
985/// Match a canonical VPWidenIntOrFpInductionRecipe, capturing it.
986inline canonical_widen_iv_match
990
991template <typename Op0_t, typename Op1_t, typename Op2_t>
992inline auto m_ScalarIVSteps(const Op0_t &Op0, const Op1_t &Op1,
993 const Op2_t &Op2) {
995 VPScalarIVStepsRecipe>({Op0, Op1, Op2});
996}
997
998template <typename Op0_t, typename Op1_t, typename Op2_t>
999inline auto m_DerivedIV(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
1001 VPDerivedIVRecipe>({Op0, Op1, Op2});
1002}
1003
1004template <typename Addr_t, typename Mask_t> struct Load_match {
1005 Addr_t Addr;
1006 Mask_t Mask;
1007
1008 Load_match(Addr_t Addr, Mask_t Mask) : Addr(Addr), Mask(Mask) {}
1009
1010 template <typename OpTy> bool match(const OpTy *V) const {
1012 if (!Load || !Addr.match(Load->getAddr()) || !Load->isMasked() ||
1013 !Mask.match(Load->getMask()))
1014 return false;
1015 return true;
1016 }
1017};
1018
1019/// Match a (possibly reversed) masked load.
1020template <typename Addr_t, typename Mask_t>
1022 const Mask_t &Mask) {
1023 return Load_match<Addr_t, Mask_t>(Addr, Mask);
1024}
1025
1026template <typename Addr_t, typename Val_t, typename Mask_t> struct Store_match {
1027 Addr_t Addr;
1028 Val_t Val;
1029 Mask_t Mask;
1030
1031 Store_match(Addr_t Addr, Val_t Val, Mask_t Mask)
1032 : Addr(Addr), Val(Val), Mask(Mask) {}
1033
1034 template <typename OpTy> bool match(const OpTy *V) const {
1036 if (!Store || !Addr.match(Store->getAddr()) ||
1037 !Val.match(Store->getStoredValue()) || !Store->isMasked() ||
1038 !Mask.match(Store->getMask()))
1039 return false;
1040 return true;
1041 }
1042};
1043
1044/// Match a (possibly reversed) masked store.
1045template <typename Addr_t, typename Val_t, typename Mask_t>
1046inline Store_match<Addr_t, Val_t, Mask_t>
1047m_MaskedStore(const Addr_t &Addr, const Val_t &Val, const Mask_t &Mask) {
1048 return Store_match<Addr_t, Val_t, Mask_t>(Addr, Val, Mask);
1049}
1050
1051template <typename Op0_t, typename Op1_t>
1054 /*Commutative*/ false, VPVectorPointerRecipe>;
1055
1056template <typename Op0_t, typename Op1_t>
1061
1062template <typename Op0_t, typename Op1_t>
1065 /*Commutative*/ false, VPActiveLaneMaskPHIRecipe>;
1066
1067template <typename Op0_t, typename Op1_t>
1069m_ActiveLaneMaskPhi(const Op0_t &Op0, const Op1_t &Op1) {
1071}
1072
1073template <typename Op0_t>
1076 /*Commutative*/ false, VPWidenLoadRecipe>;
1077
1078template <typename Op0_t>
1082
1083template <typename Op0_t, typename Op1_t>
1086 /*Commutative*/ false, VPWidenStoreRecipe>;
1087
1088template <typename Op0_t, typename Op1_t>
1093
1094template <typename Op0_t, typename Op1_t>
1097 /*Commutative*/ false, VPVectorEndPointerRecipe>;
1098
1099template <typename Op0_t, typename Op1_t>
1104
1105/// Match a call argument at a given argument index.
1106template <typename Opnd_t> struct Argument_match {
1107 /// Call argument index to match.
1108 unsigned OpI;
1109 Opnd_t Val;
1110
1111 Argument_match(unsigned OpIdx, const Opnd_t &V) : OpI(OpIdx), Val(V) {}
1112
1113 template <typename OpTy> bool match(OpTy *V) const {
1114 if (const auto *R = dyn_cast<VPWidenIntrinsicRecipe>(V))
1115 return Val.match(R->getOperand(OpI));
1116 if (const auto *R = dyn_cast<VPWidenCallRecipe>(V))
1117 return Val.match(R->getOperand(OpI));
1118 if (const auto *R = dyn_cast<VPReplicateRecipe>(V))
1119 if (R->getOpcode() == Instruction::Call)
1120 return Val.match(R->getOperand(OpI));
1121 if (const auto *R = dyn_cast<VPInstruction>(V))
1122 if (R->getOpcode() == Instruction::Call ||
1123 R->getOpcode() == VPInstruction::Intrinsic)
1124 return Val.match(R->getOperand(OpI));
1125 return false;
1126 }
1127};
1128
1129/// Match a call argument.
1130template <unsigned OpI, typename Opnd_t>
1131inline Argument_match<Opnd_t> m_Argument(const Opnd_t &Op) {
1132 return Argument_match<Opnd_t>(OpI, Op);
1133}
1134
1135/// Intrinsic matchers.
1137 unsigned ID;
1138
1140
1141 template <typename OpTy> bool match(OpTy *V) const {
1142 return vputils::getIntrinsicID(V) == ID;
1143 }
1144};
1145
1146/// Match intrinsic calls with a runtime intrinsic ID.
1148 return IntrinsicID_match(IntrID);
1149}
1150
1152 template <Intrinsic::ID IntrID, typename... Ts, size_t... Is>
1153 static auto impl(std::index_sequence<Is...>, const Ts &...Ops) {
1154 return m_CombineAnd(IntrinsicID_match(IntrID), m_Argument<Is>(Ops)...);
1155 }
1156};
1157
1158/// Match intrinsic calls like this:
1159/// m_Intrinsic<Intrinsic::fabs>(m_VPValue(X), ...)
1160template <Intrinsic::ID IntrID, typename... Ts>
1161inline auto m_Intrinsic(const Ts &...Ops) {
1163 std::make_index_sequence<sizeof...(Ts)>{}, Ops...);
1164}
1165
1166template <Intrinsic::ID IntrID, typename... T>
1167inline auto m_WidenIntrinsic(const T &...Ops) {
1169}
1170
1171/// Match VPValues that represent live-ins: VPIRValues and (plain)
1172/// VPSymbolicValues. VPRegionValues (which inherit from VPSymbolicValue) are
1173/// not live-ins and are excluded.
1175 template <typename ITy> bool match(ITy *V) const {
1176 return isa<VPIRValue>(V) ||
1178 }
1179};
1180
1181inline auto m_VScale() { return m_Intrinsic<Intrinsic::vscale>(); }
1182
1184
1185/// Match a GEP recipe (VPWidenGEPRecipe, VPInstruction, or VPReplicateRecipe)
1186/// and bind the source element type and operands.
1190
1193
1194 template <typename ITy> bool match(ITy *V) const {
1195 return matchRecipeAndBind<VPWidenGEPRecipe>(V) ||
1196 matchRecipeAndBind<VPInstruction>(V) ||
1197 matchRecipeAndBind<VPReplicateRecipe>(V);
1198 }
1199
1200private:
1201 template <typename RecipeTy> bool matchRecipeAndBind(const VPValue *V) const {
1202 auto *DefR = dyn_cast<RecipeTy>(V);
1203 if (!DefR)
1204 return false;
1205
1206 if constexpr (std::is_same_v<RecipeTy, VPWidenGEPRecipe>) {
1207 SourceElementType = DefR->getSourceElementType();
1208 } else if (DefR->getOpcode() == Instruction::GetElementPtr) {
1209 SourceElementType = cast<GetElementPtrInst>(DefR->getUnderlyingInstr())
1210 ->getSourceElementType();
1211 } else if constexpr (std::is_same_v<RecipeTy, VPInstruction>) {
1212 if (DefR->getOpcode() == VPInstruction::PtrAdd) {
1213 // PtrAdd is a byte-offset GEP with i8 element type.
1214 LLVMContext &Ctx = DefR->getParent()->getPlan()->getContext();
1216 } else {
1217 return false;
1218 }
1219 } else {
1220 return false;
1221 }
1222
1223 Operands = ArrayRef<VPValue *>(DefR->op_begin(), DefR->op_end());
1224 return true;
1225 }
1226};
1227
1228/// Match a GEP recipe with any number of operands and bind source element type
1229/// and operands.
1230inline GetElementPtr_match m_GetElementPtr(Type *&SourceElementType,
1232 return GetElementPtr_match(SourceElementType, Operands);
1233}
1234
1235template <typename SubPattern_t> struct OneUse_match {
1236 SubPattern_t SubPattern;
1237
1238 OneUse_match(const SubPattern_t &SP) : SubPattern(SP) {}
1239
1240 template <typename OpTy> bool match(OpTy *V) const {
1241 return V->hasOneUse() && SubPattern.match(V);
1242 }
1243};
1244
1245template <typename T> inline OneUse_match<T> m_OneUse(const T &SubPattern) {
1246 return SubPattern;
1247}
1248
1251 return V;
1252}
1253
1254template <typename Op0_t, typename Op1_t>
1255inline auto m_VPPhi(const Op0_t &Op0, const Op1_t &Op1) {
1256 return Recipe_match<std::tuple<Op0_t, Op1_t>, Instruction::PHI,
1257 /*Commutative*/ false, VPInstruction>({Op0, Op1});
1258}
1259
1260/// Return the sole user of \p V matching pattern \p P, casting it to \p
1261/// RecipeTy, or nullptr.
1262template <typename RecipeTy, typename MatchT>
1263RecipeTy *findSingleUser(VPValue *V, const MatchT &P) {
1264 return find_singleton<RecipeTy>(V->users(), [&P](VPUser *U, bool) {
1265 return match(U, P) ? cast<RecipeTy>(U) : nullptr;
1266 });
1267}
1268
1269/// Return the sole user of \p V that is a VPInstruction with \p Opcode, or
1270/// nullptr.
1271template <unsigned Opcode> VPInstruction *findSingleUser(VPValue *V) {
1273}
1274
1275/// Return the sole user of \p V that is a \p RecipeTy, or nullptr.
1276template <typename RecipeTy> RecipeTy *findSingleUser(VPValue *V) {
1278}
1279} // namespace llvm::VPlanPatternMatch
1280
1281#endif
SDValue Pred
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t 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 library features backported from future STL versions.
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:1572
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:550
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:76
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:297
A recipe for generating the active lane mask for the vector loop that is used to predicate the vector...
Definition VPlan.h:4170
A recipe for converting Current into Start + Current * Step.
Definition VPlan.h:4303
This is a concrete Recipe that models a single VPlan-level instruction.
Definition VPlan.h:1322
@ ExtractLastActive
Extracts the last active lane from a set of vectors.
Definition VPlan.h:1437
@ Intrinsic
Calls a scalar intrinsic. The intrinsic ID is the last operand.
Definition VPlan.h:1449
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:2890
VPReplicateRecipe replicates a given instruction producing multiple scalar copies of the original sca...
Definition VPlan.h:3495
A recipe for handling phi nodes of integer and floating-point inductions, producing their scalar valu...
Definition VPlan.h:4364
VPSingleDefRecipe is a base class for recipes that model a sequence of one or more output IR that def...
Definition VPlan.h:605
This class augments VPValue with operands which provide the inverse def-use edges from VPValue's user...
Definition VPlanValue.h:396
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:2317
A recipe to compute the pointers for widened memory accesses of SourceElementTy, with the Stride expr...
Definition VPlan.h:2399
VPWidenCastRecipe is a recipe to create vector cast instructions.
Definition VPlan.h:1899
A recipe for handling GEP instructions.
Definition VPlan.h:2257
A recipe for handling phi nodes of integer and floating-point inductions, producing their vector valu...
Definition VPlan.h:2643
VPWidenRecipe is a recipe for producing a widened instruction using the opcode and operands of the re...
Definition VPlan.h:1832
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::PtrToAddr, Op0_t > m_PtrToAddr(const Op0_t &Op0)
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.
RecipeTy * findSingleUser(VPValue *V, const MatchT &P)
Return the sole user of V matching pattern P, casting it to RecipeTy, or nullptr.
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::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)
Recipe_match< std::tuple< Op0_t, Op1_t >, 0, false, VPWidenStoreRecipe > VPWidenStoreRecipe_match
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()
VPWidenStoreRecipe_match< Op0_t, Op1_t > m_WidenStore(const Op0_t &Op0, const Op1_t &Op1)
auto m_ZExtOrTrunc(const Op0_t &Op0)
AllRecipe_match< Instruction::AShr, Op0_t, Op1_t > m_AShr(const Op0_t &Op0, const Op1_t &Op1)
decltype(std::declval< T & >().getOpcode()) hasOpcode_t
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)
VPWidenLoadRecipe_match< Op0_t > m_WidenLoad(const Op0_t &Op0)
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)
Recipe_match< std::tuple< Op0_t, Op1_t >, 0, false, VPVectorPointerRecipe > VectorPointerRecipe_match
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)
ActiveLaneMaskPHIRecipe_match< Op0_t, Op1_t > m_ActiveLaneMaskPhi(const Op0_t &Op0, const Op1_t &Op1)
VectorPointerRecipe_match< Op0_t, Op1_t > m_VecPtr(const Op0_t &Op0, const Op1_t &Op1)
VPInstruction_match< VPInstruction::ExtractLastLane, Op0_t > m_ExtractLastLane(const Op0_t &Op0)
auto m_c_Cmp(const Op0_t &Op0, const Op1_t &Op1)
specific_intval< 0 > m_SpecificInt(uint64_t V)
int_pred_ty< is_zero_int, 1 > m_False()
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)
Recipe_match< std::tuple< Op0_t, Op1_t >, 0, false, VPActiveLaneMaskPHIRecipe > ActiveLaneMaskPHIRecipe_match
canonical_iv_match m_CanonicalIV()
AllRecipe_match< Instruction::SExt, Op0_t > m_SExt(const Op0_t &Op0)
Recipe_match< std::tuple< Op0_t >, 0, false, VPWidenLoadRecipe > VPWidenLoadRecipe_match
VPInstruction_commutative_match< Opcode, Op0_t, Op1_t > m_c_VPInstruction(const Op0_t &Op0, const Op1_t &Op1)
auto m_VPValue()
Match an arbitrary VPValue and ignore it.
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)
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.
RemoveMask_match< Op0_t, Op1_t > m_RemoveMask(const Op0_t &In, Op1_t &Out)
Match a specific mask In, or a combination of it (logical-and In, Out).
int_pred_ty< is_one, 1 > m_True()
VPInstruction_match< VPInstruction::WideActiveLaneMask, Op_t... > m_WideActiveLaneMask(const Op_t &...Op)
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)
VPInstruction_match< VPInstruction::ExtractVectorForPart, Op_t... > m_ExtractVectorForPart(const Op_t &...Op)
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)
auto m_c_ICmp(const Op0_t &Op0, const Op1_t &Op1)
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:98
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).
T * find_singleton(R &&Range, Predicate P, bool AllowRepeats=false)
Return the single value in Range that satisfies P(<member of Range> *, AllowRepeats)->T * returning n...
Definition STLExtras.h:1853
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
typename detail::detector< void, Op, Args... >::value_t is_detected
Detects if a given trait holds for some set of arguments 'Args'.
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:1933
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:879
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:274
A recipe for widening load operations, using the address to load from and an optional mask.
Definition VPlan.h:3910
A recipe for widening store operations, using the stored value, the address to store to and an option...
Definition VPlan.h:4018
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.
bool match(const VPSingleDefRecipe *R) const
bool match(const VPValue *V) const
bool match(const VPRecipeBase *R) const
RemoveMask_match(const Op0_t &In, Op1_t &Out)
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 VPRecipeBase *R) const
bool match(const VPValue *VPV) const