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
54 specificval_ty(const VPValue *V) : Val(V) {}
55
56 bool match(const VPValue *VPV) const { return VPV == Val; }
57};
58
59inline specificval_ty m_Specific(const VPValue *VPV) { return VPV; }
60
61/// Like m_Specific(), but works if the specific value to match is determined
62/// as part of the same match() expression. For example:
63/// m_Mul(m_VPValue(X), m_Specific(X)) is incorrect, because m_Specific() will
64/// bind X before the pattern match starts.
65/// m_Mul(m_VPValue(X), m_Deferred(X)) is correct, and will check against
66/// whichever value m_VPValue(X) populated.
67inline match_deferred<VPValue> m_Deferred(VPValue *const &V) { return V; }
68
69/// Match an integer constant if Pred::isValue returns true for the APInt. \p
70/// BitWidth optionally specifies the bitwidth the matched constant must have.
71/// If it is 0, the matched constant can have any bitwidth.
72template <typename Pred, unsigned BitWidth = 0> struct int_pred_ty {
73 Pred P;
74
75 int_pred_ty(Pred P) : P(std::move(P)) {}
76 int_pred_ty() : P() {}
77
78 bool match(const VPValue *VPV) const {
79 auto *VPI = dyn_cast<VPInstruction>(VPV);
80 if (VPI && VPI->getOpcode() == VPInstruction::Broadcast)
81 VPV = VPI->getOperand(0);
82 auto *CI = dyn_cast<VPConstantInt>(VPV);
83 if (!CI)
84 return false;
85
86 if (BitWidth != 0 && CI->getBitWidth() != BitWidth)
87 return false;
88 return P.isValue(CI->getAPInt());
89 }
90};
91
92/// Match a specified signed or unsigned integer value.
96
99
100 bool isValue(const APInt &C) const {
102 }
103};
104
105template <unsigned Bitwidth = 0>
107
111
113 return specific_intval<0>(
114 is_specific_int(APInt(64, V, /*isSigned=*/true), /*IsSigned=*/true));
115}
116
118 bool isValue(const APInt &C) const { return C.isAllOnes(); }
119};
120
121/// Match an integer or vector with all bits set.
122/// For vectors, this includes constants with undefined elements.
126
128 bool isValue(const APInt &C) const { return C.isZero(); }
129};
130
131struct is_one {
132 bool isValue(const APInt &C) const { return C.isOne(); }
133};
134
135/// Match an integer 0 or a vector with all elements equal to 0.
136/// For vectors, this includes constants with undefined elements.
140
141/// Match an integer 1 or a vector with all elements equal to 1.
142/// For vectors, this includes constants with undefined elements.
144
146
147inline int_pred_ty<is_one, 1> m_True() { return {}; }
148
150 const APInt *&Res;
151
152 bind_apint(const APInt *&Res) : Res(Res) {}
153
154 bool match(const VPValue *VPV) const {
155 auto *CI = dyn_cast<VPConstantInt>(VPV);
156 if (!CI)
157 return false;
158 Res = &CI->getAPInt();
159 return true;
160 }
161};
162
163inline bind_apint m_APInt(const APInt *&C) { return C; }
164
167
169
170 bool match(const VPValue *VPV) const {
171 const APInt *APConst;
172 if (!bind_apint(APConst).match(VPV))
173 return false;
174 if (auto C = APConst->tryZExtValue()) {
175 Res = *C;
176 return true;
177 }
178 return false;
179 }
180};
181
183 bool match(const VPValue *V) const {
184 return isa<VPIRValue>(V) &&
186 }
187};
188
189/// Match a VPIRValue that's poison.
190inline match_poison m_Poison() { return match_poison(); }
191
192/// Match a plain integer constant no wider than 64-bits, capturing it if we
193/// match.
195
196/// Match a VPValue, capturing it if we match.
197inline match_bind<VPValue> m_VPValue(VPValue *&V) { return V; }
198
199/// Match against the nested pattern, and capture the value if we match.
200template <typename Op_t> inline auto m_VPValue(VPValue *&V, const Op_t &Op) {
201 return m_CombineAnd(Op, m_VPValue(V));
202}
203
204/// Match a VPIRValue.
206
207/// Match a VPSingleDefRecipe, capturing if we match.
210 return V;
211}
212
213/// Match a VPInstruction, capturing if we match.
217
218template <typename T>
219using hasOpcode_t = decltype(std::declval<T &>().getOpcode()); // NOLINT
220
221template <typename Ops_t, unsigned Opcode, bool Commutative,
222 typename... RecipeTys>
224 Ops_t Ops;
225
226 template <typename... OpTy> Recipe_match(OpTy... Ops) : Ops(Ops...) {
227 static_assert(std::tuple_size<Ops_t>::value == sizeof...(Ops) &&
228 "number of operands in constructor doesn't match Ops_t");
229 static_assert((!Commutative || std::tuple_size<Ops_t>::value == 2) &&
230 "only binary ops can be commutative");
231 }
232
233 bool match(const VPValue *V) const {
234 auto *DefR = V->getDefiningRecipe();
235 return DefR && match(DefR);
236 }
237
238 bool match(const VPSingleDefRecipe *R) const {
239 return match(static_cast<const VPRecipeBase *>(R));
240 }
241
242 bool match(const VPRecipeBase *R) const {
243 if (std::tuple_size_v<Ops_t> == 0) {
244 auto *VPI = dyn_cast<VPInstruction>(R);
245 return VPI && VPI->getOpcode() == Opcode;
246 }
247
248 if ((!matchRecipeAndOpcode<RecipeTys>(R) && ...))
249 return false;
250
251 if (R->getNumOperands() < std::tuple_size<Ops_t>::value) {
252 [[maybe_unused]] auto *RepR = dyn_cast<VPReplicateRecipe>(R);
254 cast<VPInstruction>(R)->getNumOperandsForOpcode() == -1u) ||
255 (RepR && std::tuple_size_v<Ops_t> ==
256 RepR->getNumOperandsWithoutMask())) &&
257 "non-variadic recipe with matched opcode does not have the "
258 "expected number of operands");
259 return false;
260 }
261
262 // If the recipe has more operands than expected, we only support matching
263 // masked VPInstructions or predicated VPReplicateRecipes, where the number
264 // of operands of the matcher matches the number of operands excluding the
265 // mask.
266 if (R->getNumOperands() > std::tuple_size<Ops_t>::value) {
267 if (auto *VPI = dyn_cast<VPInstruction>(R)) {
268 if (!VPI->isMasked() ||
269 VPI->getNumOperandsWithoutMask() != std::tuple_size<Ops_t>::value)
270 return false;
271 } else if (auto *RepR = dyn_cast<VPReplicateRecipe>(R)) {
272 if (!RepR->isPredicated() ||
273 RepR->getNumOperandsWithoutMask() != std::tuple_size<Ops_t>::value)
274 return false;
275 } else {
276 return false;
277 }
278 }
279
280 auto IdxSeq = std::make_index_sequence<std::tuple_size<Ops_t>::value>();
281 if (all_of_tuple_elements(IdxSeq, [R](auto Op, unsigned Idx) {
282 return Op.match(R->getOperand(Idx));
283 }))
284 return true;
285
286 return Commutative &&
287 all_of_tuple_elements(IdxSeq, [R](auto Op, unsigned Idx) {
288 return Op.match(R->getOperand(R->getNumOperands() - Idx - 1));
289 });
290 }
291
292private:
293 template <typename RecipeTy>
294 static bool matchRecipeAndOpcode(const VPRecipeBase *R) {
295 auto *DefR = dyn_cast<RecipeTy>(R);
296 if constexpr (Opcode && is_detected<hasOpcode_t, RecipeTy>::value)
297 return DefR && DefR->getOpcode() == Opcode;
298 return DefR;
299 }
300
301 /// Helper to check if predicate \p P holds on all tuple elements in Ops using
302 /// the provided index sequence.
303 template <typename Fn, std::size_t... Is>
304 bool all_of_tuple_elements(std::index_sequence<Is...>,
305 [[maybe_unused]] Fn P) const {
306 return (P(std::get<Is>(Ops), Is) && ...);
307 }
308};
309
310template <unsigned Opcode, typename... OpTys>
312 Recipe_match<std::tuple<OpTys...>, Opcode, /*Commutative*/ false,
315
316template <unsigned Opcode, typename... OpTys>
318 Recipe_match<std::tuple<OpTys...>, Opcode, /*Commutative*/ true,
320
321template <unsigned Opcode, typename... OpTys>
322using VPInstruction_match = Recipe_match<std::tuple<OpTys...>, Opcode,
323 /*Commutative*/ false, VPInstruction>;
324
325template <unsigned Opcode, typename... OpTys>
327 Recipe_match<std::tuple<OpTys...>, Opcode,
328 /*Commutative*/ true, VPInstruction>;
329
330template <unsigned Opcode, typename... OpTys>
331inline VPInstruction_match<Opcode, OpTys...>
332m_VPInstruction(const OpTys &...Ops) {
333 return VPInstruction_match<Opcode, OpTys...>(Ops...);
334}
335
336template <unsigned Opcode, typename Op0_t, typename Op1_t>
338m_c_VPInstruction(const Op0_t &Op0, const Op1_t &Op1) {
340}
341
342/// BuildVector is matches only its opcode, w/o matching its operands as the
343/// number of operands is not fixed.
347
348/// BuildStructVector matches only its opcode, w/o matching its operands as the
349/// number of operands is not fixed.
354
355template <typename Op0_t>
357m_Freeze(const Op0_t &Op0) {
359}
360
364
365template <typename Op0_t>
370
375
376template <typename Op0_t, typename Op1_t>
378m_BranchOnTwoConds(const Op0_t &Op0, const Op1_t &Op1) {
380}
381
385
386template <typename Op0_t, typename Op1_t>
388m_BranchOnCount(const Op0_t &Op0, const Op1_t &Op1) {
390}
391
392inline auto m_Branch() {
394}
395
396template <typename Op0_t>
401
402template <typename Op0_t>
407
408template <typename Op0_t>
413
414template <typename Op0_t, typename Op1_t>
416m_ExtractElement(const Op0_t &Op0, const Op1_t &Op1) {
418}
419
420template <typename Op0_t, typename Op1_t, typename Op2_t>
422m_InsertElement(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
424}
425
426template <typename Op0_t, typename Op1_t>
428m_ExtractLane(const Op0_t &Op0, const Op1_t &Op1) {
430}
431
432template <typename Op0_t>
437
438template <typename Op0_t>
445
446template <typename Op0_t, typename Op1_t>
451
452template <typename Op0_t>
457
458template <typename Op0_t, typename Op1_t, typename Op2_t>
460 Op2_t>
461m_WideActiveLaneMask(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
463}
464
468
469template <typename Op0_t>
471m_AnyOf(const Op0_t &Op0) {
473}
474
475template <typename Op0_t>
480
481template <typename Op0_t>
486
487template <typename Op0_t, typename Op1_t, typename Op2_t>
489 Op2_t>
490m_ExtractLastActive(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
492}
493
494template <typename Op0_t>
499
500/// Match FindIV result pattern:
501/// select(icmp ne ComputeReductionResult(ReducedIV), Sentinel),
502/// ComputeReductionResult(ReducedIV), Start.
503template <typename Op0_t, typename Op1_t>
504inline bool matchFindIVResult(VPInstruction *VPI, Op0_t ReducedIV, Op1_t Start) {
506 m_ComputeReductionResult(ReducedIV),
507 m_VPValue()),
508 m_ComputeReductionResult(ReducedIV), Start));
509}
510
511template <typename Op0_t>
513m_Reverse(const Op0_t &Op0) {
515}
516
520
521template <typename Op0_t>
526
527template <unsigned Opcode, typename Op0_t>
531
532template <typename Op0_t>
536
537template <typename Op0_t>
539m_TruncOrSelf(const Op0_t &Op0) {
540 return m_CombineOr(m_Trunc(Op0), Op0);
541}
542
543template <typename Op0_t>
547
548template <typename Op0_t>
552
553template <typename Op0_t>
557
558template <typename Op0_t>
560m_BitCast(const Op0_t &Op0) {
562}
563
564template <typename Op0_t>
566m_PtrToAddr(const Op0_t &Op0) {
568}
569
570template <typename Op0_t>
574
575template <typename Op0_t>
578m_ZExtOrSExt(const Op0_t &Op0) {
579 return m_CombineOr(m_ZExt(Op0), m_SExt(Op0));
580}
581
582template <typename Op0_t> inline auto m_WidenAnyExtend(const Op0_t &Op0) {
584}
585
586template <typename Op0_t> inline auto m_AnyNeg(const Op0_t &Op0) {
587 return m_CombineOr(m_Sub(m_ZeroInt(), Op0), m_FNeg(Op0));
588}
589
590template <typename Op0_t>
592m_ZExtOrSelf(const Op0_t &Op0) {
593 return m_CombineOr(m_ZExt(Op0), Op0);
594}
595
596template <typename Op0_t> inline auto m_ZExtOrTrunc(const Op0_t &Op0) {
597 return m_CombineOr(m_ZExt(Op0), m_Trunc(Op0));
598}
599
600template <typename Op0_t> inline auto m_ZExtOrTruncOrSelf(const Op0_t &Op0) {
601 return m_CombineOr(m_ZExtOrTrunc(Op0), Op0);
602}
603
604template <unsigned Opcode, typename Op0_t, typename Op1_t>
606 const Op1_t &Op1) {
608}
609
610template <unsigned Opcode, typename Op0_t, typename Op1_t>
612m_c_Binary(const Op0_t &Op0, const Op1_t &Op1) {
614}
615
616template <typename Op0_t, typename Op1_t>
621
622template <typename Op0_t, typename Op1_t>
624m_c_Add(const Op0_t &Op0, const Op1_t &Op1) {
626}
627
628template <typename Op0_t, typename Op1_t>
633
634template <typename Op0_t, typename Op1_t>
639
640template <typename Op0_t, typename Op1_t>
642m_c_Mul(const Op0_t &Op0, const Op1_t &Op1) {
644}
645
646template <typename Op0_t, typename Op1_t>
651
652template <typename Op0_t, typename Op1_t>
654m_LShr(const Op0_t &Op0, const Op1_t &Op1) {
656}
657
658template <typename Op0_t, typename Op1_t>
660m_AShr(const Op0_t &Op0, const Op1_t &Op1) {
662}
663
664template <typename Op0_t, typename Op1_t>
666m_FMul(const Op0_t &Op0, const Op1_t &Op1) {
668}
669
670template <typename Op0_t, typename Op1_t>
672m_FAdd(const Op0_t &Op0, const Op1_t &Op1) {
674}
675
676template <typename Op0_t, typename Op1_t>
678m_c_FAdd(const Op0_t &Op0, const Op1_t &Op1) {
680}
681
682template <typename Op0_t, typename Op1_t>
684m_UDiv(const Op0_t &Op0, const Op1_t &Op1) {
686}
687
688template <typename Op0_t, typename Op1_t>
690m_URem(const Op0_t &Op0, const Op1_t &Op1) {
692}
693
694template <typename Op0_t, typename Op1_t>
696m_SDiv(const Op0_t &Op0, const Op1_t &Op1) {
698}
699
700template <typename Op0_t, typename Op1_t>
702m_SRem(const Op0_t &Op0, const Op1_t &Op1) {
704}
705
706/// Match a binary AND operation.
707template <typename Op0_t, typename Op1_t>
709m_c_BinaryAnd(const Op0_t &Op0, const Op1_t &Op1) {
711}
712
713/// Match a binary OR operation. Note that while conceptually the operands can
714/// be matched commutatively, \p Commutative defaults to false in line with the
715/// IR-based pattern matching infrastructure. Use m_c_BinaryOr for a commutative
716/// version of the matcher.
717template <typename Op0_t, typename Op1_t>
719m_BinaryOr(const Op0_t &Op0, const Op1_t &Op1) {
721}
722
723template <typename Op0_t, typename Op1_t>
725m_c_BinaryOr(const Op0_t &Op0, const Op1_t &Op1) {
727}
728
729/// Cmp_match is a variant of BinaryRecipe_match that also binds the comparison
730/// predicate. Opcodes must either be Instruction::ICmp or Instruction::FCmp, or
731/// both.
732template <typename Op0_t, typename Op1_t, unsigned... Opcodes>
733struct Cmp_match {
734 static_assert((sizeof...(Opcodes) == 1 || sizeof...(Opcodes) == 2) &&
735 "Expected one or two opcodes");
736 static_assert(
737 ((Opcodes == Instruction::ICmp || Opcodes == Instruction::FCmp) && ...) &&
738 "Expected a compare instruction opcode");
739
743
744 Cmp_match(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1)
745 : Predicate(&Pred), Op0(Op0), Op1(Op1) {}
746 Cmp_match(const Op0_t &Op0, const Op1_t &Op1) : Op0(Op0), Op1(Op1) {}
747
748 bool match(const VPValue *V) const {
749 auto *DefR = V->getDefiningRecipe();
750 return DefR && match(DefR);
751 }
752
753 bool match(const VPRecipeBase *V) const {
754 if ((m_Binary<Opcodes>(Op0, Op1).match(V) || ...)) {
755 if (Predicate)
756 *Predicate = cast<VPRecipeWithIRFlags>(V)->getPredicate();
757 return true;
758 }
759 return false;
760 }
761};
762
763/// SpecificCmp_match is a variant of Cmp_match that matches the comparison
764/// predicate, instead of binding it.
765template <typename Op0_t, typename Op1_t, unsigned... Opcodes>
770
772 : Predicate(Pred), Op0(LHS), Op1(RHS) {}
773
774 bool match(const VPValue *V) const {
775 auto *DefR = V->getDefiningRecipe();
776 return DefR && match(DefR);
777 }
778
779 bool match(const VPRecipeBase *V) const {
780 CmpPredicate CurrentPred;
781 return Cmp_match<Op0_t, Op1_t, Opcodes...>(CurrentPred, Op0, Op1)
782 .match(V) &&
784 }
785};
786
787template <typename Op0_t, typename Op1_t>
792
793template <typename Op0_t, typename Op1_t>
794inline auto m_c_ICmp(const Op0_t &Op0, const Op1_t &Op1) {
797}
798
799template <typename Op0_t, typename Op1_t>
800inline Cmp_match<Op0_t, Op1_t, Instruction::ICmp>
801m_ICmp(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1) {
802 return Cmp_match<Op0_t, Op1_t, Instruction::ICmp>(Pred, Op0, Op1);
803}
804
805template <typename Op0_t, typename Op1_t>
806inline SpecificCmp_match<Op0_t, Op1_t, Instruction::ICmp>
807m_SpecificICmp(CmpPredicate MatchPred, const Op0_t &Op0, const Op1_t &Op1) {
809 Op1);
810}
811
812template <typename Op0_t, typename Op1_t>
813inline Cmp_match<Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp>
814m_Cmp(const Op0_t &Op0, const Op1_t &Op1) {
816 Op1);
817}
818
819template <typename Op0_t, typename Op1_t>
825
826template <typename Op0_t, typename Op1_t>
827inline Cmp_match<Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp>
828m_Cmp(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1) {
830 Pred, Op0, Op1);
831}
832
833template <typename Op0_t, typename Op1_t>
834inline SpecificCmp_match<Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp>
835m_SpecificCmp(CmpPredicate MatchPred, const Op0_t &Op0, const Op1_t &Op1) {
837 MatchPred, Op0, Op1);
838}
839
840template <typename Op0_t, typename Op1_t>
841inline auto m_GetElementPtr(const Op0_t &Op0, const Op1_t &Op1) {
842 return m_CombineOr(
843 Recipe_match<std::tuple<Op0_t, Op1_t>, Instruction::GetElementPtr,
844 /*Commutative*/ false, VPReplicateRecipe, VPWidenGEPRecipe>(
845 Op0, Op1),
848}
849
850/// Match a VPBlendRecipe with 2 incoming values ([I0, I1, M1] ==
851/// normalized([I0, M0, I1, M1])) as select(M1, I1, I0), mirroring how it is
852/// lowered.
853template <typename Op0_t, typename Op1_t, typename Op2_t> struct Blend2_match {
856 Op2_t FalseOp;
857
858 Blend2_match(const Op0_t &MaskOp, const Op1_t &TrueOp, const Op2_t &FalseOp)
860
861 template <typename T> bool match(const T *Val) const {
862 auto *Blend = dyn_cast<VPBlendRecipe>(Val);
863 if (!Blend || Blend->getNumIncomingValues() != 2)
864 return false;
865 return MaskOp.match(Blend->getMask(1)) &&
866 TrueOp.match(Blend->getIncomingValue(1)) &&
867 FalseOp.match(Blend->getIncomingValue(0));
868 }
869};
870
871/// Match recipe recipe with Select opcode, i.e. excluding VPBlendRecipe.
872template <typename Op0_t, typename Op1_t, typename Op2_t>
874m_Select(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
876 {Op0, Op1, Op2});
877}
878
879/// Match recipe with Select opcode or an equivalent VPBlendRecipe with 2
880/// incoming values.
881template <typename Op0_t, typename Op1_t, typename Op2_t>
882inline auto m_SelectLike(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
883 return m_CombineOr(m_Select(Op0, Op1, Op2),
884 Blend2_match<Op0_t, Op1_t, Op2_t>(Op0, Op1, Op2));
885}
886
887template <typename Op0_t> inline auto m_Not(const Op0_t &Op0) {
890}
891
892template <typename Op0_t, typename Op1_t, typename Op2_t>
893inline auto m_c_Select(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
894 return m_CombineOr(m_Select(Op0, Op1, Op2), m_Select(m_Not(Op0), Op2, Op1));
895}
896
897template <typename Op0_t, typename Op1_t>
898inline auto m_LogicalAnd(const Op0_t &Op0, const Op1_t &Op1) {
899 return m_CombineOr(
901 m_Select(Op0, Op1, m_False()));
902}
903
904template <typename Op0_t, typename Op1_t> struct RemoveMask_match {
907
909
910 template <typename OpTy> bool match(OpTy *V) const {
911 if (m_Specific(In).match(V)) {
912 Out = nullptr;
913 return true;
914 }
915 return m_LogicalAnd(m_Specific(In), m_VPValue(Out)).match(V);
916 }
917};
918
919/// Match a specific mask \p In, or a combination of it (logical-and In, Out).
920/// Returns the remaining part \p Out if so, or nullptr otherwise.
921template <typename Op0_t, typename Op1_t>
923 Op1_t &Out) {
924 return RemoveMask_match<Op0_t, Op1_t>(In, Out);
925}
926
927template <typename Op0_t, typename Op1_t>
928inline auto m_c_LogicalAnd(const Op0_t &Op0, const Op1_t &Op1) {
929 return m_CombineOr(
931 m_c_Select(Op0, Op1, m_False()));
932}
933
934template <typename Op0_t, typename Op1_t>
935inline auto m_LogicalOr(const Op0_t &Op0, const Op1_t &Op1) {
936 return m_CombineOr(
938 m_Select(Op0, m_True(), Op1));
939}
940
941template <typename Op0_t, typename Op1_t>
942inline auto m_c_LogicalOr(const Op0_t &Op0, const Op1_t &Op1) {
943 return m_CombineOr(m_c_Select(Op0, m_True(), Op1),
944 m_c_Select(Op1, m_True(), Op0));
945}
946
947/// Match the canonical induction variable (IV) of any loop region.
949 template <typename ArgTy> bool match(const ArgTy *V) const {
950 const auto *RV = dyn_cast<VPRegionValue>(V);
951 return RV && RV->getDefiningRegion()->getCanonicalIV() == RV;
952 }
953};
954
955inline canonical_iv_match m_CanonicalIV() { return {}; }
956
957/// Match the abstract header mask of any loop region.
959 template <typename ArgTy> bool match(const ArgTy *V) const {
960 const auto *RV = dyn_cast<VPRegionValue>(V);
961 return RV && RV->getDefiningRegion()->getHeaderMask() == RV;
962 }
963};
964
965inline header_mask_match m_HeaderMask() { return {}; }
966
967/// Match a canonical VPWidenIntOrFpInductionRecipe optionally capturing it.
970
973
974 template <typename ArgTy> bool match(ArgTy *V) const {
976 if (!WidenIV || !WidenIV->isCanonical())
977 return false;
978 if (Capture)
979 *Capture = WidenIV;
980 return true;
981 }
982};
983
985
986/// Match a canonical VPWidenIntOrFpInductionRecipe, capturing it.
987inline canonical_widen_iv_match
991
992template <typename Op0_t, typename Op1_t, typename Op2_t>
993inline auto m_ScalarIVSteps(const Op0_t &Op0, const Op1_t &Op1,
994 const Op2_t &Op2) {
996 VPScalarIVStepsRecipe>({Op0, Op1, Op2});
997}
998
999template <typename Op0_t, typename Op1_t, typename Op2_t>
1000inline auto m_DerivedIV(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
1002 VPDerivedIVRecipe>({Op0, Op1, Op2});
1003}
1004
1005template <typename Addr_t, typename Mask_t> struct Load_match {
1006 Addr_t Addr;
1007 Mask_t Mask;
1008
1009 Load_match(Addr_t Addr, Mask_t Mask) : Addr(Addr), Mask(Mask) {}
1010
1011 template <typename OpTy> bool match(const OpTy *V) const {
1013 if (!Load || !Addr.match(Load->getAddr()) || !Load->isMasked() ||
1014 !Mask.match(Load->getMask()))
1015 return false;
1016 return true;
1017 }
1018};
1019
1020/// Match a (possibly reversed) masked load.
1021template <typename Addr_t, typename Mask_t>
1023 const Mask_t &Mask) {
1024 return Load_match<Addr_t, Mask_t>(Addr, Mask);
1025}
1026
1027template <typename Addr_t, typename Val_t, typename Mask_t> struct Store_match {
1028 Addr_t Addr;
1029 Val_t Val;
1030 Mask_t Mask;
1031
1032 Store_match(Addr_t Addr, Val_t Val, Mask_t Mask)
1033 : Addr(Addr), Val(Val), Mask(Mask) {}
1034
1035 template <typename OpTy> bool match(const OpTy *V) const {
1037 if (!Store || !Addr.match(Store->getAddr()) ||
1038 !Val.match(Store->getStoredValue()) || !Store->isMasked() ||
1039 !Mask.match(Store->getMask()))
1040 return false;
1041 return true;
1042 }
1043};
1044
1045/// Match a (possibly reversed) masked store.
1046template <typename Addr_t, typename Val_t, typename Mask_t>
1047inline Store_match<Addr_t, Val_t, Mask_t>
1048m_MaskedStore(const Addr_t &Addr, const Val_t &Val, const Mask_t &Mask) {
1049 return Store_match<Addr_t, Val_t, Mask_t>(Addr, Val, Mask);
1050}
1051
1052template <typename Op0_t, typename Op1_t>
1055 /*Commutative*/ false, VPVectorPointerRecipe>;
1056
1057template <typename Op0_t, typename Op1_t>
1062
1063template <typename Op0_t>
1066 /*Commutative*/ false, VPWidenLoadRecipe>;
1067
1068template <typename Op0_t>
1072
1073template <typename Op0_t, typename Op1_t>
1076 /*Commutative*/ false, VPWidenStoreRecipe>;
1077
1078template <typename Op0_t, typename Op1_t>
1083
1084template <typename Op0_t, typename Op1_t>
1087 /*Commutative*/ false, VPVectorEndPointerRecipe>;
1088
1089template <typename Op0_t, typename Op1_t>
1094
1095/// Match a call argument at a given argument index.
1096template <typename Opnd_t> struct Argument_match {
1097 /// Call argument index to match.
1098 unsigned OpI;
1099 Opnd_t Val;
1100
1101 Argument_match(unsigned OpIdx, const Opnd_t &V) : OpI(OpIdx), Val(V) {}
1102
1103 template <typename OpTy> bool match(OpTy *V) const {
1104 if (const auto *R = dyn_cast<VPWidenIntrinsicRecipe>(V))
1105 return Val.match(R->getOperand(OpI));
1106 if (const auto *R = dyn_cast<VPWidenCallRecipe>(V))
1107 return Val.match(R->getOperand(OpI));
1108 if (const auto *R = dyn_cast<VPReplicateRecipe>(V))
1109 if (R->getOpcode() == Instruction::Call)
1110 return Val.match(R->getOperand(OpI));
1111 if (const auto *R = dyn_cast<VPInstruction>(V))
1112 if (R->getOpcode() == Instruction::Call ||
1113 R->getOpcode() == VPInstruction::Intrinsic)
1114 return Val.match(R->getOperand(OpI));
1115 return false;
1116 }
1117};
1118
1119/// Match a call argument.
1120template <unsigned OpI, typename Opnd_t>
1121inline Argument_match<Opnd_t> m_Argument(const Opnd_t &Op) {
1122 return Argument_match<Opnd_t>(OpI, Op);
1123}
1124
1125/// Intrinsic matchers.
1127 unsigned ID;
1128
1130
1131 template <typename OpTy> bool match(OpTy *V) const {
1132 return vputils::getIntrinsicID(V) == ID;
1133 }
1134};
1135
1136/// Match intrinsic calls with a runtime intrinsic ID.
1138 return IntrinsicID_match(IntrID);
1139}
1140
1142 template <Intrinsic::ID IntrID, typename... Ts, size_t... Is>
1143 static auto impl(std::index_sequence<Is...>, const Ts &...Ops) {
1144 return m_CombineAnd(IntrinsicID_match(IntrID), m_Argument<Is>(Ops)...);
1145 }
1146};
1147
1148/// Match intrinsic calls like this:
1149/// m_Intrinsic<Intrinsic::fabs>(m_VPValue(X), ...)
1150template <Intrinsic::ID IntrID, typename... Ts>
1151inline auto m_Intrinsic(const Ts &...Ops) {
1153 std::make_index_sequence<sizeof...(Ts)>{}, Ops...);
1154}
1155
1156template <Intrinsic::ID IntrID, typename... T>
1157inline auto m_WidenIntrinsic(const T &...Ops) {
1159}
1160
1161/// Match VPValues that represent live-ins: VPIRValues and (plain)
1162/// VPSymbolicValues. VPRegionValues (which inherit from VPSymbolicValue) are
1163/// not live-ins and are excluded.
1165 template <typename ITy> bool match(ITy *V) const {
1166 return isa<VPIRValue>(V) ||
1168 }
1169};
1170
1171inline auto m_VScale() { return m_Intrinsic<Intrinsic::vscale>(); }
1172
1174
1175/// Match a GEP recipe (VPWidenGEPRecipe, VPInstruction, or VPReplicateRecipe)
1176/// and bind the source element type and operands.
1180
1183
1184 template <typename ITy> bool match(ITy *V) const {
1185 return matchRecipeAndBind<VPWidenGEPRecipe>(V) ||
1186 matchRecipeAndBind<VPInstruction>(V) ||
1187 matchRecipeAndBind<VPReplicateRecipe>(V);
1188 }
1189
1190private:
1191 template <typename RecipeTy> bool matchRecipeAndBind(const VPValue *V) const {
1192 auto *DefR = dyn_cast<RecipeTy>(V);
1193 if (!DefR)
1194 return false;
1195
1196 if constexpr (std::is_same_v<RecipeTy, VPWidenGEPRecipe>) {
1197 SourceElementType = DefR->getSourceElementType();
1198 } else if (DefR->getOpcode() == Instruction::GetElementPtr) {
1199 SourceElementType = cast<GetElementPtrInst>(DefR->getUnderlyingInstr())
1200 ->getSourceElementType();
1201 } else if constexpr (std::is_same_v<RecipeTy, VPInstruction>) {
1202 if (DefR->getOpcode() == VPInstruction::PtrAdd) {
1203 // PtrAdd is a byte-offset GEP with i8 element type.
1204 LLVMContext &Ctx = DefR->getParent()->getPlan()->getContext();
1206 } else {
1207 return false;
1208 }
1209 } else {
1210 return false;
1211 }
1212
1213 Operands = ArrayRef<VPValue *>(DefR->op_begin(), DefR->op_end());
1214 return true;
1215 }
1216};
1217
1218/// Match a GEP recipe with any number of operands and bind source element type
1219/// and operands.
1220inline GetElementPtr_match m_GetElementPtr(Type *&SourceElementType,
1222 return GetElementPtr_match(SourceElementType, Operands);
1223}
1224
1225template <typename SubPattern_t> struct OneUse_match {
1226 SubPattern_t SubPattern;
1227
1228 OneUse_match(const SubPattern_t &SP) : SubPattern(SP) {}
1229
1230 template <typename OpTy> bool match(OpTy *V) const {
1231 return V->hasOneUse() && SubPattern.match(V);
1232 }
1233};
1234
1235template <typename T> inline OneUse_match<T> m_OneUse(const T &SubPattern) {
1236 return SubPattern;
1237}
1238
1241 return V;
1242}
1243
1244template <typename Op0_t, typename Op1_t>
1245inline auto m_VPPhi(const Op0_t &Op0, const Op1_t &Op1) {
1246 return Recipe_match<std::tuple<Op0_t, Op1_t>, Instruction::PHI,
1247 /*Commutative*/ false, VPInstruction>({Op0, Op1});
1248}
1249
1250/// If \p V is used by a recipe matching pattern \p P, return it. Otherwise
1251/// return nullptr;
1252template <typename MatchT>
1253VPRecipeBase *findUserOf(VPValue *V, const MatchT &P) {
1254 auto It = find_if(V->users(), match_fn(P));
1255 return It == V->user_end() ? nullptr : cast<VPRecipeBase>(*It);
1256}
1257
1258/// If \p V is used by a VPInstruction with \p Opcode, return it. Otherwise
1259/// return nullptr.
1260template <unsigned Opcode> VPInstruction *findUserOf(VPValue *V) {
1262}
1263
1264template <typename RecipeTy> RecipeTy *findUserOf(VPValue *V) {
1266}
1267} // namespace llvm::VPlanPatternMatch
1268
1269#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
unsigned uint64_t
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static constexpr Value * getValue(Ty &ValueOrUse)
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
#define T
#define P(N)
SI Fold Operands
This file contains 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:68
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
static LLVM_ABI IntegerType * getInt8Ty(LLVMContext &C)
Definition Type.cpp:297
A recipe for converting Current into Start + Current * Step.
Definition VPlan.h:4213
This is a concrete Recipe that models a single VPlan-level instruction.
Definition VPlan.h:1303
@ ExtractLastActive
Extracts the last active lane from a set of vectors.
Definition VPlan.h:1421
@ Intrinsic
Calls a scalar intrinsic. The intrinsic ID is the last operand.
Definition VPlan.h:1433
VPRecipeBase is a base class modeling a sequence of one or more output IR instructions.
Definition VPlan.h:403
A recipe for handling reduction phis.
Definition VPlan.h:2865
VPReplicateRecipe replicates a given instruction producing multiple scalar copies of the original sca...
Definition VPlan.h:3415
A recipe for handling phi nodes of integer and floating-point inductions, producing their scalar valu...
Definition VPlan.h:4274
VPSingleDefRecipe is a base class for recipes that model a sequence of one or more output IR that def...
Definition VPlan.h:611
This class augments VPValue with operands which provide the inverse def-use edges from VPValue's user...
Definition VPlanValue.h:397
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:2288
A recipe to compute the pointers for widened memory accesses of SourceElementTy, with the Stride expr...
Definition VPlan.h:2370
VPWidenCastRecipe is a recipe to create vector cast instructions.
Definition VPlan.h:1896
A recipe for handling GEP instructions.
Definition VPlan.h:2228
A recipe for handling phi nodes of integer and floating-point inductions, producing their vector valu...
Definition VPlan.h:2614
VPWidenRecipe is a recipe for producing a widened instruction using the opcode and operands of the re...
Definition VPlan.h:1829
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.
AllRecipe_commutative_match< Opcode, Op0_t, Op1_t > m_c_Binary(const Op0_t &Op0, const Op1_t &Op1)
AllRecipe_commutative_match< Instruction::Add, Op0_t, Op1_t > m_c_Add(const Op0_t &Op0, const Op1_t &Op1)
AllRecipe_commutative_match< Instruction::Or, Op0_t, Op1_t > m_c_BinaryOr(const Op0_t &Op0, const Op1_t &Op1)
bool matchFindIVResult(VPInstruction *VPI, Op0_t ReducedIV, Op1_t Start)
Match FindIV result pattern: select(icmp ne ComputeReductionResult(ReducedIV), Sentinel),...
VPInstruction_match< VPInstruction::ComputeReductionResult, Op0_t > m_ComputeReductionResult(const Op0_t &Op0)
IntrinsicID_match m_Intrinsic(Intrinsic::ID IntrID)
Match intrinsic calls with a runtime intrinsic ID.
auto m_WidenAnyExtend(const Op0_t &Op0)
match_bind< VPIRValue > m_VPIRValue(VPIRValue *&V)
Match a VPIRValue.
VPInstruction_match< VPInstruction::WideActiveLaneMask, Op0_t, Op1_t, Op2_t > m_WideActiveLaneMask(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
VPInstruction_match< VPInstruction::StepVector > m_StepVector()
auto m_c_LogicalOr(const Op0_t &Op0, const Op1_t &Op1)
match_deferred< VPValue > m_Deferred(VPValue *const &V)
Like m_Specific(), but works if the specific value to match is determined as part of the same match()...
match_combine_or< AllRecipe_match< Instruction::ZExt, Op0_t >, AllRecipe_match< Instruction::SExt, Op0_t > > m_ZExtOrSExt(const Op0_t &Op0)
auto m_VPPhi(const Op0_t &Op0, const Op1_t &Op1)
SpecificCmp_match< Op0_t, Op1_t, Instruction::ICmp > m_SpecificICmp(CmpPredicate MatchPred, const Op0_t &Op0, const Op1_t &Op1)
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)
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)
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
VPInstruction_match< VPInstruction::ExtractVectorForPart, Op0_t, Op1_t > m_ExtractVectorForPart(const Op0_t &Op0, const Op1_t &Op1)
specific_intval< 0 > m_SpecificSInt(int64_t V)
AllRecipe_match< Instruction::FAdd, Op0_t, Op1_t > m_FAdd(const Op0_t &Op0, const Op1_t &Op1)
VectorEndPointerRecipe_match< Op0_t, Op1_t > m_VecEndPtr(const Op0_t &Op0, const Op1_t &Op1)
VPInstruction_match< VPInstruction::ExtractLastPart, Op0_t > m_ExtractLastPart(const Op0_t &Op0)
VPRecipeBase * findUserOf(VPValue *V, const MatchT &P)
If V is used by a recipe matching pattern P, return it.
AllRecipe_match< Instruction::BitCast, Op0_t > m_BitCast(const Op0_t &Op0)
VPInstruction_match< VPInstruction::Broadcast, Op0_t > m_Broadcast(const Op0_t &Op0)
bool match(Val *V, const Pattern &P)
header_mask_match m_HeaderMask()
OneUse_match< T > m_OneUse(const T &SubPattern)
VPInstruction_match< VPInstruction::ExplicitVectorLength, Op0_t > m_EVL(const Op0_t &Op0)
VPInstruction_match< VPInstruction::BuildVector > m_BuildVector()
BuildVector is matches only its opcode, w/o matching its operands as the number of operands is not fi...
AllRecipe_match< Instruction::Trunc, Op0_t > m_Trunc(const Op0_t &Op0)
VPInstruction_match< VPInstruction::ExtractPenultimateElement, Op0_t > m_ExtractPenultimateElement(const Op0_t &Op0)
AllRecipe_match< Instruction::Shl, Op0_t, Op1_t > m_Shl(const Op0_t &Op0, const Op1_t &Op1)
Recipe_match< std::tuple< Op0_t, Op1_t >, 0, false, VPVectorEndPointerRecipe > VectorEndPointerRecipe_match
match_bind< VPInstruction > m_VPInstruction(VPInstruction *&V)
Match a VPInstruction, capturing if we match.
AllRecipe_match< Instruction::SDiv, Op0_t, Op1_t > m_SDiv(const Op0_t &Op0, const Op1_t &Op1)
match_combine_or< AllRecipe_match< Instruction::ZExt, Op0_t >, Op0_t > m_ZExtOrSelf(const Op0_t &Op0)
VPInstruction_match< VPInstruction::FirstActiveLane, Op0_t > m_FirstActiveLane(const Op0_t &Op0)
Argument_match< Opnd_t > m_Argument(const Opnd_t &Op)
Match a call argument.
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()
AllRecipe_match< Instruction::FNeg, Op0_t > m_FNeg(const Op0_t &Op0)
AllRecipe_match< Instruction::UDiv, Op0_t, Op1_t > m_UDiv(const Op0_t &Op0, const Op1_t &Op1)
auto m_Not(const Op0_t &Op0)
auto m_DerivedIV(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
auto m_c_LogicalAnd(const Op0_t &Op0, const Op1_t &Op1)
int_pred_ty< is_one > m_One()
Match an integer 1 or a vector with all elements equal to 1.
Recipe_match< std::tuple< OpTys... >, Opcode, false, VPWidenRecipe, VPReplicateRecipe, VPWidenCastRecipe, VPInstruction > AllRecipe_match
AllRecipe_match< Instruction::SRem, Op0_t, Op1_t > m_SRem(const Op0_t &Op0, const Op1_t &Op1)
VPInstruction_match< VPInstruction::BranchOnCond > m_BranchOnCond()
match_bind< VPReductionPHIRecipe > m_ReductionPhi(VPReductionPHIRecipe *&V)
auto m_ScalarIVSteps(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
VPInstruction_match< VPInstruction::ExtractLane, Op0_t, Op1_t > m_ExtractLane(const Op0_t &Op0, const Op1_t &Op1)
VPInstruction_match< VPInstruction::BuildStructVector > m_BuildStructVector()
BuildStructVector matches only its opcode, w/o matching its operands as the number of operands is not...
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:93
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
@ Load
The value being inserted comes from a load (InsertElement only).
@ Store
The extracted value is stored (ExtractElement only).
auto cast_or_null(const Y &Val)
Definition Casting.h:714
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
constexpr unsigned BitWidth
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
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1788
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878
Matcher to bind the captured value.
Matcher for a specific value, but stores a reference to the value, not the value itself.
A VPValue representing a live-in from the input IR or a constant.
Definition VPlanValue.h:275
A recipe for widening load operations, using the address to load from and an optional mask.
Definition VPlan.h:3832
A recipe for widening store operations, using the stored value, the address to store to and an option...
Definition VPlan.h:3937
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 VPValue *VPV) const