LLVM 23.0.0git
VPlanPatternMatch.h
Go to the documentation of this file.
1//===- VPlanPatternMatch.h - Match on VPValues and recipes ------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file provides a simple and efficient mechanism for performing general
10// tree-based pattern matches on the VPlan values and recipes, based on
11// LLVM's IR pattern matchers.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_TRANSFORM_VECTORIZE_VPLANPATTERNMATCH_H
16#define LLVM_TRANSFORM_VECTORIZE_VPLANPATTERNMATCH_H
17
18#include "VPlan.h"
19#include "VPlanUtils.h"
21
22using namespace llvm::PatternMatchHelpers;
23
25
26template <typename Val, typename Pattern> bool match(Val *V, const Pattern &P) {
27 return P.match(V);
28}
29
30template <typename Pattern> bool match(VPUser *U, const Pattern &P) {
31 auto *R = dyn_cast<VPRecipeBase>(U);
32 return R && match(R, P);
33}
34
35template <typename Pattern> bool match(VPSingleDefRecipe *R, const Pattern &P) {
36 return P.match(static_cast<const VPRecipeBase *>(R));
37}
38
39/// A match functor that can be used as a UnaryPredicate in functional
40/// algorithms like all_of.
41template <typename Pattern> auto match_fn(const Pattern &P) {
42 return [&P](auto *V) { return match(V, P); };
43}
44
45/// Match an arbitrary VPValue and ignore it.
46inline auto m_VPValue() { return m_Isa<VPValue>(); }
47
48/// Match a specified VPValue.
50 const VPValue *Val;
51
52 specificval_ty(const VPValue *V) : Val(V) {}
53
54 bool match(const VPValue *VPV) const { return VPV == Val; }
55};
56
57inline specificval_ty m_Specific(const VPValue *VPV) { return VPV; }
58
59/// Like m_Specific(), but works if the specific value to match is determined
60/// as part of the same match() expression. For example:
61/// m_Mul(m_VPValue(X), m_Specific(X)) is incorrect, because m_Specific() will
62/// bind X before the pattern match starts.
63/// m_Mul(m_VPValue(X), m_Deferred(X)) is correct, and will check against
64/// whichever value m_VPValue(X) populated.
65inline match_deferred<VPValue> m_Deferred(VPValue *const &V) { return V; }
66
67/// Match an integer constant if Pred::isValue returns true for the APInt. \p
68/// BitWidth optionally specifies the bitwidth the matched constant must have.
69/// If it is 0, the matched constant can have any bitwidth.
70template <typename Pred, unsigned BitWidth = 0> struct int_pred_ty {
71 Pred P;
72
73 int_pred_ty(Pred P) : P(std::move(P)) {}
74 int_pred_ty() : P() {}
75
76 bool match(const VPValue *VPV) const {
77 auto *VPI = dyn_cast<VPInstruction>(VPV);
78 if (VPI && VPI->getOpcode() == VPInstruction::Broadcast)
79 VPV = VPI->getOperand(0);
80 auto *CI = dyn_cast<VPConstantInt>(VPV);
81 if (!CI)
82 return false;
83
84 if (BitWidth != 0 && CI->getBitWidth() != BitWidth)
85 return false;
86 return P.isValue(CI->getAPInt());
87 }
88};
89
90/// Match a specified signed or unsigned integer value.
94
97
98 bool isValue(const APInt &C) const {
100 }
101};
102
103template <unsigned Bitwidth = 0>
105
109
111 return specific_intval<0>(
112 is_specific_int(APInt(64, V, /*isSigned=*/true), /*IsSigned=*/true));
113}
114
118
122
124 bool isValue(const APInt &C) const { return C.isAllOnes(); }
125};
126
127/// Match an integer or vector with all bits set.
128/// For vectors, this includes constants with undefined elements.
132
134 bool isValue(const APInt &C) const { return C.isZero(); }
135};
136
137struct is_one {
138 bool isValue(const APInt &C) const { return C.isOne(); }
139};
140
141/// Match an integer 0 or a vector with all elements equal to 0.
142/// For vectors, this includes constants with undefined elements.
146
147/// Match an integer 1 or a vector with all elements equal to 1.
148/// For vectors, this includes constants with undefined elements.
150
152 const APInt *&Res;
153
154 bind_apint(const APInt *&Res) : Res(Res) {}
155
156 bool match(const VPValue *VPV) const {
157 auto *CI = dyn_cast<VPConstantInt>(VPV);
158 if (!CI)
159 return false;
160 Res = &CI->getAPInt();
161 return true;
162 }
163};
164
165inline bind_apint m_APInt(const APInt *&C) { return C; }
166
169
171
172 bool match(const VPValue *VPV) const {
173 const APInt *APConst;
174 if (!bind_apint(APConst).match(VPV))
175 return false;
176 if (auto C = APConst->tryZExtValue()) {
177 Res = *C;
178 return true;
179 }
180 return false;
181 }
182};
183
185 bool match(const VPValue *V) const {
186 return isa<VPIRValue>(V) &&
188 }
189};
190
191/// Match a VPIRValue that's poison.
192inline match_poison m_Poison() { return match_poison(); }
193
194/// Match a plain integer constant no wider than 64-bits, capturing it if we
195/// match.
197
198/// Match a VPValue, capturing it if we match.
199inline match_bind<VPValue> m_VPValue(VPValue *&V) { return V; }
200
201/// Match a VPIRValue.
203
204/// Match a VPSingleDefRecipe, capturing if we match.
207 return V;
208}
209
210/// Match a VPInstruction, capturing if we match.
214
215template <typename Ops_t, unsigned Opcode, bool Commutative,
216 typename... RecipeTys>
218 Ops_t Ops;
219
220 template <typename... OpTy> Recipe_match(OpTy... Ops) : Ops(Ops...) {
221 static_assert(std::tuple_size<Ops_t>::value == sizeof...(Ops) &&
222 "number of operands in constructor doesn't match Ops_t");
223 static_assert((!Commutative || std::tuple_size<Ops_t>::value == 2) &&
224 "only binary ops can be commutative");
225 }
226
227 bool match(const VPValue *V) const {
228 auto *DefR = V->getDefiningRecipe();
229 return DefR && match(DefR);
230 }
231
232 bool match(const VPSingleDefRecipe *R) const {
233 return match(static_cast<const VPRecipeBase *>(R));
234 }
235
236 bool match(const VPRecipeBase *R) const {
237 if (std::tuple_size_v<Ops_t> == 0) {
238 auto *VPI = dyn_cast<VPInstruction>(R);
239 return VPI && VPI->getOpcode() == Opcode;
240 }
241
242 if ((!matchRecipeAndOpcode<RecipeTys>(R) && ...))
243 return false;
244
245 if (R->getNumOperands() < std::tuple_size<Ops_t>::value) {
246 [[maybe_unused]] auto *RepR = dyn_cast<VPReplicateRecipe>(R);
248 cast<VPInstruction>(R)->getNumOperandsForOpcode() == -1u) ||
249 (RepR && std::tuple_size_v<Ops_t> ==
250 RepR->getNumOperandsWithoutMask())) &&
251 "non-variadic recipe with matched opcode does not have the "
252 "expected number of operands");
253 return false;
254 }
255
256 // If the recipe has more operands than expected, we only support matching
257 // masked VPInstructions or predicated VPReplicateRecipes, where the number
258 // of operands of the matcher matches the number of operands excluding the
259 // mask.
260 if (R->getNumOperands() > std::tuple_size<Ops_t>::value) {
261 if (auto *VPI = dyn_cast<VPInstruction>(R)) {
262 if (!VPI->isMasked() ||
263 VPI->getNumOperandsWithoutMask() != std::tuple_size<Ops_t>::value)
264 return false;
265 } else if (auto *RepR = dyn_cast<VPReplicateRecipe>(R)) {
266 if (!RepR->isPredicated() ||
267 RepR->getNumOperandsWithoutMask() != std::tuple_size<Ops_t>::value)
268 return false;
269 } else {
270 return false;
271 }
272 }
273
274 auto IdxSeq = std::make_index_sequence<std::tuple_size<Ops_t>::value>();
275 if (all_of_tuple_elements(IdxSeq, [R](auto Op, unsigned Idx) {
276 return Op.match(R->getOperand(Idx));
277 }))
278 return true;
279
280 return Commutative &&
281 all_of_tuple_elements(IdxSeq, [R](auto Op, unsigned Idx) {
282 return Op.match(R->getOperand(R->getNumOperands() - Idx - 1));
283 });
284 }
285
286private:
287 template <typename RecipeTy>
288 static bool matchRecipeAndOpcode(const VPRecipeBase *R) {
289 auto *DefR = dyn_cast<RecipeTy>(R);
290 // Check for recipes that do not have opcodes.
291 if constexpr (std::is_same_v<RecipeTy, VPScalarIVStepsRecipe> ||
292 std::is_same_v<RecipeTy, VPDerivedIVRecipe> ||
293 std::is_same_v<RecipeTy, VPVectorEndPointerRecipe>)
294 return DefR;
295 else
296 return DefR && DefR->getOpcode() == Opcode;
297 }
298
299 /// Helper to check if predicate \p P holds on all tuple elements in Ops using
300 /// the provided index sequence.
301 template <typename Fn, std::size_t... Is>
302 bool all_of_tuple_elements(std::index_sequence<Is...>,
303 [[maybe_unused]] Fn P) const {
304 return (P(std::get<Is>(Ops), Is) && ...);
305 }
306};
307
308template <unsigned Opcode, typename... OpTys>
310 Recipe_match<std::tuple<OpTys...>, Opcode, /*Commutative*/ false,
313
314template <unsigned Opcode, typename... OpTys>
316 Recipe_match<std::tuple<OpTys...>, Opcode, /*Commutative*/ true,
318
319template <unsigned Opcode, typename... OpTys>
320using VPInstruction_match = Recipe_match<std::tuple<OpTys...>, Opcode,
321 /*Commutative*/ false, VPInstruction>;
322
323template <unsigned Opcode, typename... OpTys>
325 Recipe_match<std::tuple<OpTys...>, Opcode,
326 /*Commutative*/ true, VPInstruction>;
327
328template <unsigned Opcode, typename... OpTys>
329inline VPInstruction_match<Opcode, OpTys...>
330m_VPInstruction(const OpTys &...Ops) {
331 return VPInstruction_match<Opcode, OpTys...>(Ops...);
332}
333
334template <unsigned Opcode, typename Op0_t, typename Op1_t>
336m_c_VPInstruction(const Op0_t &Op0, const Op1_t &Op1) {
338}
339
340/// BuildVector is matches only its opcode, w/o matching its operands as the
341/// number of operands is not fixed.
345
346/// BuildStructVector matches only its opcode, w/o matching its operands as the
347/// number of operands is not fixed.
352
353template <typename Op0_t>
355m_Freeze(const Op0_t &Op0) {
357}
358
362
363template <typename Op0_t>
365m_BranchOnCond(const Op0_t &Op0) {
367}
368
373
374template <typename Op0_t, typename Op1_t>
376m_BranchOnTwoConds(const Op0_t &Op0, const Op1_t &Op1) {
378}
379
380template <typename Op0_t>
382m_Broadcast(const Op0_t &Op0) {
384}
385
386template <typename Op0_t>
388m_EVL(const Op0_t &Op0) {
390}
391
392template <typename Op0_t>
397
398template <typename Op0_t, typename Op1_t>
400m_ExtractElement(const Op0_t &Op0, const Op1_t &Op1) {
402}
403
404template <typename Op0_t, typename Op1_t, typename Op2_t>
406m_InsertElement(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
408}
409
410template <typename Op0_t, typename Op1_t>
412m_ExtractLane(const Op0_t &Op0, const Op1_t &Op1) {
414}
415
416template <typename Op0_t>
421
422template <typename Op0_t>
428}
429
430template <typename Op0_t>
435
436template <typename Op0_t, typename Op1_t, typename Op2_t>
438m_ActiveLaneMask(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
440}
441
445
446template <typename Op0_t, typename Op1_t>
448m_BranchOnCount(const Op0_t &Op0, const Op1_t &Op1) {
450}
451
455
456template <typename Op0_t>
458m_AnyOf(const Op0_t &Op0) {
460}
461
462template <typename Op0_t>
467
468template <typename Op0_t>
470m_LastActiveLane(const Op0_t &Op0) {
472}
473
474template <typename Op0_t, typename Op1_t, typename Op2_t>
476 Op2_t>
477m_ExtractLastActive(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
479}
480
481template <typename Op0_t>
486
487/// Match FindIV result pattern:
488/// select(icmp ne ComputeReductionResult(ReducedIV), Sentinel),
489/// ComputeReductionResult(ReducedIV), Start.
490template <typename Op0_t, typename Op1_t>
491inline bool matchFindIVResult(VPInstruction *VPI, Op0_t ReducedIV, Op1_t Start) {
493 m_ComputeReductionResult(ReducedIV),
494 m_VPValue()),
495 m_ComputeReductionResult(ReducedIV), Start));
496}
497
498template <typename Op0_t>
500m_Reverse(const Op0_t &Op0) {
502}
503
507
508template <typename Op0_t>
510m_ExitingIVValue(const Op0_t &Op0) {
512}
513
514template <unsigned Opcode, typename Op0_t>
515inline AllRecipe_match<Opcode, Op0_t> m_Unary(const Op0_t &Op0) {
517}
518
519template <typename Op0_t>
523
524template <typename Op0_t>
526m_TruncOrSelf(const Op0_t &Op0) {
527 return m_CombineOr(m_Trunc(Op0), Op0);
528}
529
530template <typename Op0_t>
534
535template <typename Op0_t>
539
540template <typename Op0_t>
544
545template <typename Op0_t>
549
550template <typename Op0_t>
553m_ZExtOrSExt(const Op0_t &Op0) {
554 return m_CombineOr(m_ZExt(Op0), m_SExt(Op0));
555}
556
557template <typename Op0_t> inline auto m_WidenAnyExtend(const Op0_t &Op0) {
559}
560
561template <typename Op0_t> inline auto m_AnyNeg(const Op0_t &Op0) {
562 return m_CombineOr(m_Sub(m_ZeroInt(), Op0), m_FNeg(Op0));
563}
564
565template <typename Op0_t>
567m_ZExtOrSelf(const Op0_t &Op0) {
568 return m_CombineOr(m_ZExt(Op0), Op0);
569}
570
571template <typename Op0_t> inline auto m_ZExtOrTruncOrSelf(const Op0_t &Op0) {
572 return m_CombineOr(m_ZExt(Op0), m_Trunc(Op0), Op0);
573}
574
575template <unsigned Opcode, typename Op0_t, typename Op1_t>
577 const Op1_t &Op1) {
579}
580
581template <unsigned Opcode, typename Op0_t, typename Op1_t>
583m_c_Binary(const Op0_t &Op0, const Op1_t &Op1) {
585}
586
587template <typename Op0_t, typename Op1_t>
589 const Op1_t &Op1) {
591}
592
593template <typename Op0_t, typename Op1_t>
595m_c_Add(const Op0_t &Op0, const Op1_t &Op1) {
597}
598
599template <typename Op0_t, typename Op1_t>
601 const Op1_t &Op1) {
603}
604
605template <typename Op0_t, typename Op1_t>
607 const Op1_t &Op1) {
609}
610
611template <typename Op0_t, typename Op1_t>
613m_c_Mul(const Op0_t &Op0, const Op1_t &Op1) {
615}
616
617template <typename Op0_t, typename Op1_t>
619 const Op1_t &Op1) {
621}
622
623template <typename Op0_t, typename Op1_t>
625m_LShr(const Op0_t &Op0, const Op1_t &Op1) {
627}
628
629template <typename Op0_t, typename Op1_t>
631m_FMul(const Op0_t &Op0, const Op1_t &Op1) {
633}
634
635template <typename Op0_t, typename Op1_t>
637m_FAdd(const Op0_t &Op0, const Op1_t &Op1) {
639}
640
641template <typename Op0_t, typename Op1_t>
643m_c_FAdd(const Op0_t &Op0, const Op1_t &Op1) {
645}
646
647template <typename Op0_t, typename Op1_t>
649m_UDiv(const Op0_t &Op0, const Op1_t &Op1) {
651}
652
653template <typename Op0_t, typename Op1_t>
655m_URem(const Op0_t &Op0, const Op1_t &Op1) {
657}
658
659template <typename Op0_t, typename Op1_t>
661m_SRem(const Op0_t &Op0, const Op1_t &Op1) {
663}
664
665/// Match a binary AND operation.
666template <typename Op0_t, typename Op1_t>
668m_c_BinaryAnd(const Op0_t &Op0, const Op1_t &Op1) {
670}
671
672/// Match a binary OR operation. Note that while conceptually the operands can
673/// be matched commutatively, \p Commutative defaults to false in line with the
674/// IR-based pattern matching infrastructure. Use m_c_BinaryOr for a commutative
675/// version of the matcher.
676template <typename Op0_t, typename Op1_t>
678m_BinaryOr(const Op0_t &Op0, const Op1_t &Op1) {
680}
681
682template <typename Op0_t, typename Op1_t>
684m_c_BinaryOr(const Op0_t &Op0, const Op1_t &Op1) {
686}
687
688/// Cmp_match is a variant of BinaryRecipe_match that also binds the comparison
689/// predicate. Opcodes must either be Instruction::ICmp or Instruction::FCmp, or
690/// both.
691template <typename Op0_t, typename Op1_t, unsigned... Opcodes>
692struct Cmp_match {
693 static_assert((sizeof...(Opcodes) == 1 || sizeof...(Opcodes) == 2) &&
694 "Expected one or two opcodes");
695 static_assert(
696 ((Opcodes == Instruction::ICmp || Opcodes == Instruction::FCmp) && ...) &&
697 "Expected a compare instruction opcode");
698
700 Op0_t Op0;
702
703 Cmp_match(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1)
704 : Predicate(&Pred), Op0(Op0), Op1(Op1) {}
705 Cmp_match(const Op0_t &Op0, const Op1_t &Op1) : Op0(Op0), Op1(Op1) {}
706
707 bool match(const VPValue *V) const {
708 auto *DefR = V->getDefiningRecipe();
709 return DefR && match(DefR);
710 }
711
712 bool match(const VPRecipeBase *V) const {
713 if ((m_Binary<Opcodes>(Op0, Op1).match(V) || ...)) {
714 if (Predicate)
715 *Predicate = cast<VPRecipeWithIRFlags>(V)->getPredicate();
716 return true;
717 }
718 return false;
719 }
720};
721
722/// SpecificCmp_match is a variant of Cmp_match that matches the comparison
723/// predicate, instead of binding it.
724template <typename Op0_t, typename Op1_t, unsigned... Opcodes>
727 Op0_t Op0;
729
730 SpecificCmp_match(CmpPredicate Pred, const Op0_t &LHS, const Op1_t &RHS)
731 : Predicate(Pred), Op0(LHS), Op1(RHS) {}
732
733 bool match(const VPValue *V) const {
734 auto *DefR = V->getDefiningRecipe();
735 return DefR && match(DefR);
736 }
737
738 bool match(const VPRecipeBase *V) const {
739 CmpPredicate CurrentPred;
740 return Cmp_match<Op0_t, Op1_t, Opcodes...>(CurrentPred, Op0, Op1)
741 .match(V) &&
743 }
744};
745
746template <typename Op0_t, typename Op1_t>
748 const Op1_t &Op1) {
750}
751
752template <typename Op0_t, typename Op1_t>
753inline Cmp_match<Op0_t, Op1_t, Instruction::ICmp>
754m_ICmp(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1) {
755 return Cmp_match<Op0_t, Op1_t, Instruction::ICmp>(Pred, Op0, Op1);
756}
757
758template <typename Op0_t, typename Op1_t>
759inline SpecificCmp_match<Op0_t, Op1_t, Instruction::ICmp>
760m_SpecificICmp(CmpPredicate MatchPred, const Op0_t &Op0, const Op1_t &Op1) {
762 Op1);
763}
764
765template <typename Op0_t, typename Op1_t>
766inline Cmp_match<Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp>
767m_Cmp(const Op0_t &Op0, const Op1_t &Op1) {
769 Op1);
770}
771
772template <typename Op0_t, typename Op1_t>
773inline Cmp_match<Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp>
774m_Cmp(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1) {
776 Pred, Op0, Op1);
777}
778
779template <typename Op0_t, typename Op1_t>
780inline SpecificCmp_match<Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp>
781m_SpecificCmp(CmpPredicate MatchPred, const Op0_t &Op0, const Op1_t &Op1) {
783 MatchPred, Op0, Op1);
784}
785
786template <typename Op0_t, typename Op1_t>
787inline auto m_GetElementPtr(const Op0_t &Op0, const Op1_t &Op1) {
788 return m_CombineOr(
789 Recipe_match<std::tuple<Op0_t, Op1_t>, Instruction::GetElementPtr,
790 /*Commutative*/ false, VPReplicateRecipe, VPWidenGEPRecipe>(
791 Op0, Op1),
794}
795
796/// Match a VPBlendRecipe with 2 incoming values ([I0, I1, M1] ==
797/// normalized([I0, M0, I1, M1])) as select(M1, I1, I0), mirroring how it is
798/// lowered.
799template <typename Op0_t, typename Op1_t, typename Op2_t> struct Blend2_match {
800 Op0_t MaskOp;
802 Op2_t FalseOp;
803
804 Blend2_match(const Op0_t &MaskOp, const Op1_t &TrueOp, const Op2_t &FalseOp)
806
807 template <typename T> bool match(const T *Val) const {
808 auto *Blend = dyn_cast<VPBlendRecipe>(Val);
809 if (!Blend || Blend->getNumIncomingValues() != 2)
810 return false;
811 return MaskOp.match(Blend->getMask(1)) &&
812 TrueOp.match(Blend->getIncomingValue(1)) &&
813 FalseOp.match(Blend->getIncomingValue(0));
814 }
815};
816
817/// Match recipe recipe with Select opcode, i.e. excluding VPBlendRecipe.
818template <typename Op0_t, typename Op1_t, typename Op2_t>
820m_Select(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
822 {Op0, Op1, Op2});
823}
824
825/// Match recipe with Select opcode or an equivalent VPBlendRecipe with 2
826/// incoming values.
827template <typename Op0_t, typename Op1_t, typename Op2_t>
828inline auto m_SelectLike(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
829 return m_CombineOr(m_Select(Op0, Op1, Op2),
830 Blend2_match<Op0_t, Op1_t, Op2_t>(Op0, Op1, Op2));
831}
832
833template <typename Op0_t> inline auto m_Not(const Op0_t &Op0) {
836}
837
838template <typename Op0_t, typename Op1_t, typename Op2_t>
839inline auto m_c_Select(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
840 return m_CombineOr(m_Select(Op0, Op1, Op2), m_Select(m_Not(Op0), Op2, Op1));
841}
842
843template <typename Op0_t, typename Op1_t>
844inline auto m_LogicalAnd(const Op0_t &Op0, const Op1_t &Op1) {
845 return m_CombineOr(
847 m_Select(Op0, Op1, m_False()));
848}
849
850template <typename Op0_t, typename Op1_t>
851inline auto m_c_LogicalAnd(const Op0_t &Op0, const Op1_t &Op1) {
852 return m_CombineOr(
854 m_c_Select(Op0, Op1, m_False()));
855}
856
857template <typename Op0_t, typename Op1_t>
858inline auto m_LogicalOr(const Op0_t &Op0, const Op1_t &Op1) {
859 return m_CombineOr(
861 m_Select(Op0, m_True(), Op1));
862}
863
864template <typename Op0_t, typename Op1_t>
865inline auto m_c_LogicalOr(const Op0_t &Op0, const Op1_t &Op1) {
866 return m_c_Select(Op0, m_True(), Op1);
867}
868
869/// Match the canonical induction variable (IV) of any loop region.
871 template <typename ArgTy> bool match(const ArgTy *V) const {
872 const auto *RV = dyn_cast<VPRegionValue>(V);
873 return RV && RV->getDefiningRegion()->getCanonicalIV() == RV;
874 }
875};
876
877inline canonical_iv_match m_CanonicalIV() { return {}; }
878
879/// Match a canonical VPWidenIntOrFpInductionRecipe optionally capturing it.
882
885
886 template <typename ArgTy> bool match(ArgTy *V) const {
888 if (!WidenIV || !WidenIV->isCanonical())
889 return false;
890 if (Capture)
891 *Capture = WidenIV;
892 return true;
893 }
894};
895
897
898/// Match a canonical VPWidenIntOrFpInductionRecipe, capturing it.
899inline canonical_widen_iv_match
903
904template <typename Op0_t, typename Op1_t, typename Op2_t>
905inline auto m_ScalarIVSteps(const Op0_t &Op0, const Op1_t &Op1,
906 const Op2_t &Op2) {
908 VPScalarIVStepsRecipe>({Op0, Op1, Op2});
909}
910
911template <typename Op0_t, typename Op1_t, typename Op2_t>
912inline auto m_DerivedIV(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
914 VPDerivedIVRecipe>({Op0, Op1, Op2});
915}
916
917template <typename Addr_t, typename Mask_t> struct Load_match {
918 Addr_t Addr;
919 Mask_t Mask;
920
921 Load_match(Addr_t Addr, Mask_t Mask) : Addr(Addr), Mask(Mask) {}
922
923 template <typename OpTy> bool match(const OpTy *V) const {
924 auto *Load = dyn_cast<VPWidenLoadRecipe>(V);
925 if (!Load || !Addr.match(Load->getAddr()) || !Load->isMasked() ||
926 !Mask.match(Load->getMask()))
927 return false;
928 return true;
929 }
930};
931
932/// Match a (possibly reversed) masked load.
933template <typename Addr_t, typename Mask_t>
934inline Load_match<Addr_t, Mask_t> m_MaskedLoad(const Addr_t &Addr,
935 const Mask_t &Mask) {
936 return Load_match<Addr_t, Mask_t>(Addr, Mask);
937}
938
939template <typename Addr_t, typename Val_t, typename Mask_t> struct Store_match {
940 Addr_t Addr;
941 Val_t Val;
942 Mask_t Mask;
943
944 Store_match(Addr_t Addr, Val_t Val, Mask_t Mask)
945 : Addr(Addr), Val(Val), Mask(Mask) {}
946
947 template <typename OpTy> bool match(const OpTy *V) const {
948 auto *Store = dyn_cast<VPWidenStoreRecipe>(V);
949 if (!Store || !Addr.match(Store->getAddr()) ||
950 !Val.match(Store->getStoredValue()) || !Store->isMasked() ||
951 !Mask.match(Store->getMask()))
952 return false;
953 return true;
954 }
955};
956
957/// Match a (possibly reversed) masked store.
958template <typename Addr_t, typename Val_t, typename Mask_t>
959inline Store_match<Addr_t, Val_t, Mask_t>
960m_MaskedStore(const Addr_t &Addr, const Val_t &Val, const Mask_t &Mask) {
961 return Store_match<Addr_t, Val_t, Mask_t>(Addr, Val, Mask);
962}
963
964template <typename Op0_t, typename Op1_t>
967 /*Commutative*/ false, VPVectorEndPointerRecipe>;
968
969template <typename Op0_t, typename Op1_t>
974
975/// Match a call argument at a given argument index.
976template <typename Opnd_t> struct Argument_match {
977 /// Call argument index to match.
978 unsigned OpI;
979 Opnd_t Val;
980
981 Argument_match(unsigned OpIdx, const Opnd_t &V) : OpI(OpIdx), Val(V) {}
982
983 template <typename OpTy> bool match(OpTy *V) const {
984 if (const auto *R = dyn_cast<VPWidenIntrinsicRecipe>(V))
985 return Val.match(R->getOperand(OpI));
986 if (const auto *R = dyn_cast<VPWidenCallRecipe>(V))
987 return Val.match(R->getOperand(OpI));
988 if (const auto *R = dyn_cast<VPReplicateRecipe>(V))
989 if (R->getOpcode() == Instruction::Call)
990 return Val.match(R->getOperand(OpI));
991 if (const auto *R = dyn_cast<VPInstruction>(V))
992 if (R->getOpcode() == Instruction::Call)
993 return Val.match(R->getOperand(OpI));
994 return false;
995 }
996};
997
998/// Match a call argument.
999template <unsigned OpI, typename Opnd_t>
1000inline Argument_match<Opnd_t> m_Argument(const Opnd_t &Op) {
1001 return Argument_match<Opnd_t>(OpI, Op);
1002}
1003
1004/// Intrinsic matchers.
1006 unsigned ID;
1007
1009
1010 template <typename OpTy> bool match(OpTy *V) const {
1011 return vputils::getIntrinsicID(V) == ID;
1012 }
1013};
1014
1015/// Intrinsic matches are combinations of ID matchers, and argument
1016/// matchers. Higher arity matcher are defined recursively in terms of and-ing
1017/// them with lower arity matchers. Here's some convenient typedefs for up to
1018/// several arguments, and more can be added as needed
1019template <typename T0 = void, typename T1 = void, typename T2 = void,
1020 typename T3 = void>
1021struct m_Intrinsic_Ty;
1022template <typename T0> struct m_Intrinsic_Ty<T0> {
1024};
1025template <typename T0, typename T1> struct m_Intrinsic_Ty<T0, T1> {
1026 using Ty =
1028};
1029template <typename T0, typename T1, typename T2>
1034template <typename T0, typename T1, typename T2, typename T3>
1039
1040/// Match intrinsic calls like this:
1041/// m_Intrinsic<Intrinsic::fabs>(m_VPValue(X), ...)
1042template <Intrinsic::ID IntrID> inline IntrinsicID_match m_Intrinsic() {
1043 return IntrinsicID_match(IntrID);
1044}
1045
1046/// Match intrinsic calls with a runtime intrinsic ID.
1048 return IntrinsicID_match(IntrID);
1049}
1050
1051template <Intrinsic::ID IntrID, typename T0>
1052inline typename m_Intrinsic_Ty<T0>::Ty m_Intrinsic(const T0 &Op0) {
1054}
1055
1056template <Intrinsic::ID IntrID, typename T0, typename T1>
1057inline typename m_Intrinsic_Ty<T0, T1>::Ty m_Intrinsic(const T0 &Op0,
1058 const T1 &Op1) {
1060}
1061
1062template <Intrinsic::ID IntrID, typename T0, typename T1, typename T2>
1063inline typename m_Intrinsic_Ty<T0, T1, T2>::Ty
1064m_Intrinsic(const T0 &Op0, const T1 &Op1, const T2 &Op2) {
1065 return m_CombineAnd(m_Intrinsic<IntrID>(Op0, Op1), m_Argument<2>(Op2));
1066}
1067
1068template <Intrinsic::ID IntrID, typename T0, typename T1, typename T2,
1069 typename T3>
1071m_Intrinsic(const T0 &Op0, const T1 &Op1, const T2 &Op2, const T3 &Op3) {
1072 return m_CombineAnd(m_Intrinsic<IntrID>(Op0, Op1, Op2), m_Argument<3>(Op3));
1073}
1074
1075template <Intrinsic::ID IntrID, typename... T>
1076inline auto m_WidenIntrinsic(const T &...Ops) {
1078}
1079
1081
1082/// Match a GEP recipe (VPWidenGEPRecipe, VPInstruction, or VPReplicateRecipe)
1083/// and bind the source element type and operands.
1087
1090
1091 template <typename ITy> bool match(ITy *V) const {
1092 return matchRecipeAndBind<VPWidenGEPRecipe>(V) ||
1093 matchRecipeAndBind<VPInstruction>(V) ||
1094 matchRecipeAndBind<VPReplicateRecipe>(V);
1095 }
1096
1097private:
1098 template <typename RecipeTy> bool matchRecipeAndBind(const VPValue *V) const {
1099 auto *DefR = dyn_cast<RecipeTy>(V);
1100 if (!DefR)
1101 return false;
1102
1103 if constexpr (std::is_same_v<RecipeTy, VPWidenGEPRecipe>) {
1104 SourceElementType = DefR->getSourceElementType();
1105 } else if (DefR->getOpcode() == Instruction::GetElementPtr) {
1106 SourceElementType = cast<GetElementPtrInst>(DefR->getUnderlyingInstr())
1107 ->getSourceElementType();
1108 } else if constexpr (std::is_same_v<RecipeTy, VPInstruction>) {
1109 if (DefR->getOpcode() == VPInstruction::PtrAdd) {
1110 // PtrAdd is a byte-offset GEP with i8 element type.
1111 LLVMContext &Ctx = DefR->getParent()->getPlan()->getContext();
1113 } else {
1114 return false;
1115 }
1116 } else {
1117 return false;
1118 }
1119
1120 Operands = ArrayRef<VPValue *>(DefR->op_begin(), DefR->op_end());
1121 return true;
1122 }
1123};
1124
1125/// Match a GEP recipe with any number of operands and bind source element type
1126/// and operands.
1127inline GetElementPtr_match m_GetElementPtr(Type *&SourceElementType,
1128 ArrayRef<VPValue *> &Operands) {
1129 return GetElementPtr_match(SourceElementType, Operands);
1130}
1131
1132template <typename SubPattern_t> struct OneUse_match {
1133 SubPattern_t SubPattern;
1134
1135 OneUse_match(const SubPattern_t &SP) : SubPattern(SP) {}
1136
1137 template <typename OpTy> bool match(OpTy *V) const {
1138 return V->hasOneUse() && SubPattern.match(V);
1139 }
1140};
1141
1142template <typename T> inline OneUse_match<T> m_OneUse(const T &SubPattern) {
1143 return SubPattern;
1144}
1145
1148 return V;
1149}
1150
1151template <typename Op0_t, typename Op1_t>
1152inline auto m_VPPhi(const Op0_t &Op0, const Op1_t &Op1) {
1153 return Recipe_match<std::tuple<Op0_t, Op1_t>, Instruction::PHI,
1154 /*Commutative*/ false, VPInstruction>({Op0, Op1});
1155}
1156
1157/// If \p V is used by a recipe matching pattern \p P, return it. Otherwise
1158/// return nullptr;
1159template <typename MatchT>
1160VPRecipeBase *findUserOf(VPValue *V, const MatchT &P) {
1161 auto It = find_if(V->users(), match_fn(P));
1162 return It == V->user_end() ? nullptr : cast<VPRecipeBase>(*It);
1163}
1164
1165/// If \p V is used by a VPInstruction with \p Opcode, return it. Otherwise
1166/// return nullptr.
1167template <unsigned Opcode> VPInstruction *findUserOf(VPValue *V) {
1169}
1170
1171template <typename RecipeTy> RecipeTy *findUserOf(VPValue *V) {
1173}
1174} // namespace llvm::VPlanPatternMatch
1175
1176#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static constexpr Value * getValue(Ty &ValueOrUse)
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
#define T
MachineInstr unsigned OpIdx
#define P(N)
This file contains the declarations of the Vectorization Plan base classes:
Class for arbitrary precision integers.
Definition APInt.h:78
std::optional< uint64_t > tryZExtValue() const
Get zero extended value if possible.
Definition APInt.h:1575
static bool isSameValue(const APInt &I1, const APInt &I2, bool SignedCompare=false)
Determine if two APInts have the same value, after zero-extending or sign-extending (if SignedCompare...
Definition APInt.h:555
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
@ ICMP_NE
not equal
Definition InstrTypes.h:762
An abstraction over a floating-point predicate, and a pack of an integer predicate with samesign info...
static LLVM_ABI std::optional< CmpPredicate > getMatching(CmpPredicate A, CmpPredicate B)
Compares two CmpPredicates taking samesign into account and returns the canonicalized CmpPredicate if...
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
static LLVM_ABI IntegerType * getInt8Ty(LLVMContext &C)
Definition Type.cpp:307
A recipe for converting the input value IV value to the corresponding value of an IV with different s...
Definition VPlan.h:4175
This is a concrete Recipe that models a single VPlan-level instruction.
Definition VPlan.h:1226
@ ExtractLastActive
Extracts the last active lane from a set of vectors.
Definition VPlan.h:1328
VPRecipeBase is a base class modeling a sequence of one or more output IR instructions.
Definition VPlan.h:402
A recipe for handling reduction phis.
Definition VPlan.h:2851
VPReplicateRecipe replicates a given instruction producing multiple scalar copies of the original sca...
Definition VPlan.h:3385
A recipe for handling phi nodes of integer and floating-point inductions, producing their scalar valu...
Definition VPlan.h:4235
VPSingleDefRecipe is a base class for recipes that model a sequence of one or more output IR that def...
Definition VPlan.h:609
This class augments VPValue with operands which provide the inverse def-use edges from VPValue's user...
Definition VPlanValue.h:385
This is the base class of the VPlan Def/Use graph, used for modeling the data flow into,...
Definition VPlanValue.h:50
A recipe to compute a pointer to the last element of each part of a widened memory access for widened...
Definition VPlan.h:2266
VPWidenCastRecipe is a recipe to create vector cast instructions.
Definition VPlan.h:1878
A recipe for handling GEP instructions.
Definition VPlan.h:2206
A recipe for handling phi nodes of integer and floating-point inductions, producing their vector valu...
Definition VPlan.h:2610
VPWidenRecipe is a recipe for producing a widened instruction using the opcode and operands of the re...
Definition VPlan.h:1817
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
match_combine_or< Ty... > m_CombineOr(const Ty &...Ps)
Combine pattern matchers matching any of Ps patterns.
match_combine_and< Ty... > m_CombineAnd(const Ty &...Ps)
Combine pattern matchers matching all of Ps patterns.
auto m_Cmp()
Matches any compare instruction and ignore it.
auto m_LogicalOr()
Matches L || R where L and R are arbitrary values.
auto m_LogicalAnd()
Matches L && R where L and R are arbitrary values.
auto m_ConstantInt()
Match an arbitrary ConstantInt and ignore it.
VPInstruction_match< VPInstruction::ExtractLastLane, VPInstruction_match< VPInstruction::ExtractLastPart, Op0_t > > m_ExtractLastLaneOfLastPart(const Op0_t &Op0)
AllRecipe_match< Instruction::Select, Op0_t, Op1_t, Op2_t > m_Select(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
Match recipe recipe with Select opcode, i.e. excluding VPBlendRecipe.
VPInstruction_match< Instruction::Freeze, Op0_t > m_Freeze(const Op0_t &Op0)
AllRecipe_commutative_match< Instruction::And, Op0_t, Op1_t > m_c_BinaryAnd(const Op0_t &Op0, const Op1_t &Op1)
Match a binary AND operation.
AllRecipe_match< Instruction::ZExt, Op0_t > m_ZExt(const Op0_t &Op0)
AllRecipe_match< Instruction::URem, Op0_t, Op1_t > m_URem(const Op0_t &Op0, const Op1_t &Op1)
AllRecipe_match< Instruction::Or, Op0_t, Op1_t > m_BinaryOr(const Op0_t &Op0, const Op1_t &Op1)
Match a binary OR operation.
int_pred_ty< is_specific_int, Bitwidth > specific_intval
Store_match< Addr_t, Val_t, Mask_t > m_MaskedStore(const Addr_t &Addr, const Val_t &Val, const Mask_t &Mask)
Match a (possibly reversed) masked store.
int_pred_ty< is_zero_int > m_ZeroInt()
Match an integer 0 or a vector with all elements equal to 0.
AllRecipe_match< Instruction::FMul, Op0_t, Op1_t > m_FMul(const Op0_t &Op0, const Op1_t &Op1)
SpecificCmp_match< Op0_t, Op1_t, Instruction::ICmp, Instruction::FCmp > m_SpecificCmp(CmpPredicate MatchPred, const Op0_t &Op0, const Op1_t &Op1)
VPInstruction_match< VPInstruction::AnyOf > m_AnyOf()
int_pred_ty< is_all_ones > m_AllOnes()
Match an integer or vector with all bits set.
AllRecipe_commutative_match< Opcode, Op0_t, Op1_t > m_c_Binary(const Op0_t &Op0, const Op1_t &Op1)
AllRecipe_commutative_match< Instruction::Add, Op0_t, Op1_t > m_c_Add(const Op0_t &Op0, const Op1_t &Op1)
AllRecipe_commutative_match< Instruction::Or, Op0_t, Op1_t > m_c_BinaryOr(const Op0_t &Op0, const Op1_t &Op1)
bool matchFindIVResult(VPInstruction *VPI, Op0_t ReducedIV, Op1_t Start)
Match FindIV result pattern: select(icmp ne ComputeReductionResult(ReducedIV), Sentinel),...
VPInstruction_match< VPInstruction::ComputeReductionResult, Op0_t > m_ComputeReductionResult(const Op0_t &Op0)
auto m_WidenAnyExtend(const Op0_t &Op0)
match_bind< VPIRValue > m_VPIRValue(VPIRValue *&V)
Match a VPIRValue.
VPInstruction_match< VPInstruction::StepVector > m_StepVector()
auto m_c_LogicalOr(const Op0_t &Op0, const Op1_t &Op1)
match_deferred< VPValue > m_Deferred(VPValue *const &V)
Like m_Specific(), but works if the specific value to match is determined as part of the same match()...
match_combine_or< AllRecipe_match< Instruction::ZExt, Op0_t >, AllRecipe_match< Instruction::SExt, Op0_t > > m_ZExtOrSExt(const Op0_t &Op0)
auto m_VPPhi(const Op0_t &Op0, const Op1_t &Op1)
SpecificCmp_match< Op0_t, Op1_t, Instruction::ICmp > m_SpecificICmp(CmpPredicate MatchPred, const Op0_t &Op0, const Op1_t &Op1)
auto m_SelectLike(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
Match recipe with Select opcode or an equivalent VPBlendRecipe with 2 incoming values.
AllRecipe_match< Instruction::Add, Op0_t, Op1_t > m_Add(const Op0_t &Op0, const Op1_t &Op1)
match_poison m_Poison()
Match a VPIRValue that's poison.
auto m_c_Select(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
Recipe_match< std::tuple< OpTys... >, Opcode, false, VPInstruction > VPInstruction_match
VPInstruction_match< VPInstruction::BranchOnTwoConds > m_BranchOnTwoConds()
VPInstruction_match< Instruction::InsertElement, Op0_t, Op1_t, Op2_t > m_InsertElement(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
AllRecipe_match< Opcode, Op0_t, Op1_t > m_Binary(const Op0_t &Op0, const Op1_t &Op1)
AllRecipe_match< Instruction::LShr, Op0_t, Op1_t > m_LShr(const Op0_t &Op0, const Op1_t &Op1)
VPInstruction_match< VPInstruction::LastActiveLane, Op0_t > m_LastActiveLane(const Op0_t &Op0)
AllRecipe_match< Opcode, Op0_t > m_Unary(const Op0_t &Op0)
auto m_WidenIntrinsic(const T &...Ops)
Recipe_match< std::tuple< OpTys... >, Opcode, true, VPInstruction > VPInstruction_commutative_match
AllRecipe_commutative_match< Instruction::FAdd, Op0_t, Op1_t > m_c_FAdd(const Op0_t &Op0, const Op1_t &Op1)
Load_match< Addr_t, Mask_t > m_MaskedLoad(const Addr_t &Addr, const Mask_t &Mask)
Match a (possibly reversed) masked load.
VPInstruction_match< VPInstruction::ExtractLastActive, Op0_t, Op1_t, Op2_t > m_ExtractLastActive(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
match_combine_or< AllRecipe_match< Instruction::Trunc, Op0_t >, Op0_t > m_TruncOrSelf(const Op0_t &Op0)
AllRecipe_match< Instruction::FPExt, Op0_t > m_FPExt(const Op0_t &Op0)
AllRecipe_commutative_match< Instruction::Mul, Op0_t, Op1_t > m_c_Mul(const Op0_t &Op0, const Op1_t &Op1)
canonical_widen_iv_match m_CanonicalWidenIV()
auto match_fn(const Pattern &P)
A match functor that can be used as a UnaryPredicate in functional algorithms like all_of.
Cmp_match< Op0_t, Op1_t, Instruction::ICmp > m_ICmp(const Op0_t &Op0, const Op1_t &Op1)
AllRecipe_match< Instruction::Mul, Op0_t, Op1_t > m_Mul(const Op0_t &Op0, const Op1_t &Op1)
specificval_ty m_Specific(const VPValue *VPV)
VPInstruction_match< VPInstruction::ExitingIVValue, Op0_t > m_ExitingIVValue(const Op0_t &Op0)
VPInstruction_match< Instruction::ExtractElement, Op0_t, Op1_t > m_ExtractElement(const Op0_t &Op0, const Op1_t &Op1)
specific_intval< 1 > m_False()
VPInstruction_match< VPInstruction::ExtractLastLane, Op0_t > m_ExtractLastLane(const Op0_t &Op0)
specific_intval< 0 > m_SpecificInt(uint64_t V)
VPInstruction_match< VPInstruction::ActiveLaneMask, Op0_t, Op1_t, Op2_t > m_ActiveLaneMask(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
match_bind< VPSingleDefRecipe > m_VPSingleDefRecipe(VPSingleDefRecipe *&V)
Match a VPSingleDefRecipe, capturing if we match.
VPInstruction_match< VPInstruction::BranchOnCount > m_BranchOnCount()
auto m_GetElementPtr(const Op0_t &Op0, const Op1_t &Op1)
auto m_ZExtOrTruncOrSelf(const Op0_t &Op0)
AllRecipe_match< Instruction::Sub, Op0_t, Op1_t > m_Sub(const Op0_t &Op0, const Op1_t &Op1)
canonical_iv_match m_CanonicalIV()
AllRecipe_match< Instruction::SExt, Op0_t > m_SExt(const Op0_t &Op0)
VPInstruction_commutative_match< Opcode, Op0_t, Op1_t > m_c_VPInstruction(const Op0_t &Op0, const Op1_t &Op1)
specific_intval< 1 > m_True()
auto m_VPValue()
Match an arbitrary VPValue and ignore it.
IntrinsicID_match m_Intrinsic()
Match intrinsic calls like this: m_Intrinsic<Intrinsic::fabs>(m_VPValue(X), ...)
Recipe_match< std::tuple< OpTys... >, Opcode, true, VPWidenRecipe, VPReplicateRecipe, VPInstruction > AllRecipe_commutative_match
specific_intval< 0 > m_SpecificSInt(int64_t V)
AllRecipe_match< Instruction::FAdd, Op0_t, Op1_t > m_FAdd(const Op0_t &Op0, const Op1_t &Op1)
VectorEndPointerRecipe_match< Op0_t, Op1_t > m_VecEndPtr(const Op0_t &Op0, const Op1_t &Op1)
VPInstruction_match< VPInstruction::ExtractLastPart, Op0_t > m_ExtractLastPart(const Op0_t &Op0)
VPRecipeBase * findUserOf(VPValue *V, const MatchT &P)
If V is used by a recipe matching pattern P, return it.
VPInstruction_match< VPInstruction::Broadcast, Op0_t > m_Broadcast(const Op0_t &Op0)
bool match(Val *V, const Pattern &P)
OneUse_match< T > m_OneUse(const T &SubPattern)
VPInstruction_match< VPInstruction::ExplicitVectorLength, Op0_t > m_EVL(const Op0_t &Op0)
VPInstruction_match< VPInstruction::BuildVector > m_BuildVector()
BuildVector is matches only its opcode, w/o matching its operands as the number of operands is not fi...
AllRecipe_match< Instruction::Trunc, Op0_t > m_Trunc(const Op0_t &Op0)
VPInstruction_match< VPInstruction::ExtractPenultimateElement, Op0_t > m_ExtractPenultimateElement(const Op0_t &Op0)
AllRecipe_match< Instruction::Shl, Op0_t, Op1_t > m_Shl(const Op0_t &Op0, const Op1_t &Op1)
Recipe_match< std::tuple< Op0_t, Op1_t >, 0, false, VPVectorEndPointerRecipe > VectorEndPointerRecipe_match
match_bind< VPInstruction > m_VPInstruction(VPInstruction *&V)
Match a VPInstruction, capturing if we match.
match_combine_or< AllRecipe_match< Instruction::ZExt, Op0_t >, Op0_t > m_ZExtOrSelf(const Op0_t &Op0)
VPInstruction_match< VPInstruction::FirstActiveLane, Op0_t > m_FirstActiveLane(const Op0_t &Op0)
Argument_match< Opnd_t > m_Argument(const Opnd_t &Op)
Match a call argument.
AllRecipe_match< Instruction::FNeg, Op0_t > m_FNeg(const Op0_t &Op0)
AllRecipe_match< Instruction::UDiv, Op0_t, Op1_t > m_UDiv(const Op0_t &Op0, const Op1_t &Op1)
auto m_Not(const Op0_t &Op0)
auto m_DerivedIV(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
auto m_c_LogicalAnd(const Op0_t &Op0, const Op1_t &Op1)
int_pred_ty< is_one > m_One()
Match an integer 1 or a vector with all elements equal to 1.
Recipe_match< std::tuple< OpTys... >, Opcode, false, VPWidenRecipe, VPReplicateRecipe, VPWidenCastRecipe, VPInstruction > AllRecipe_match
AllRecipe_match< Instruction::SRem, Op0_t, Op1_t > m_SRem(const Op0_t &Op0, const Op1_t &Op1)
VPInstruction_match< VPInstruction::BranchOnCond > m_BranchOnCond()
match_bind< VPReductionPHIRecipe > m_ReductionPhi(VPReductionPHIRecipe *&V)
auto m_ScalarIVSteps(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
VPInstruction_match< VPInstruction::ExtractLane, Op0_t, Op1_t > m_ExtractLane(const Op0_t &Op0, const Op1_t &Op1)
VPInstruction_match< VPInstruction::BuildStructVector > m_BuildStructVector()
BuildStructVector matches only its opcode, w/o matching its operands as the number of operands is not...
bind_apint m_APInt(const APInt *&C)
auto m_AnyNeg(const Op0_t &Op0)
VPInstruction_match< VPInstruction::Reverse, Op0_t > m_Reverse(const Op0_t &Op0)
Intrinsic::ID getIntrinsicID(const Ty *R)
Return the intrinsic ID underlying a call.
Definition VPlanUtils.h:81
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
auto cast_or_null(const Y &Val)
Definition Casting.h:714
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
constexpr unsigned BitWidth
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1917
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1772
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:860
Matcher to bind the captured value.
Matcher for a specific value, but stores a reference to the value, not the value itself.
Intrinsic matches are combinations of ID matchers, and argument matchers.
A VPValue representing a live-in from the input IR or a constant.
Definition VPlanValue.h:247
Match a call argument at a given argument index.
unsigned OpI
Call argument index to match.
Argument_match(unsigned OpIdx, const Opnd_t &V)
Match a VPBlendRecipe with 2 incoming values ([I0, I1, M1] == normalized([I0, M0, I1,...
Blend2_match(const Op0_t &MaskOp, const Op1_t &TrueOp, const Op2_t &FalseOp)
Cmp_match is a variant of BinaryRecipe_match that also binds the comparison predicate.
Cmp_match(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1)
Cmp_match(const Op0_t &Op0, const Op1_t &Op1)
bool match(const VPValue *V) const
bool match(const VPRecipeBase *V) const
Match a GEP recipe (VPWidenGEPRecipe, VPInstruction, or VPReplicateRecipe) and bind the source elemen...
GetElementPtr_match(Type *&SourceElementType, ArrayRef< VPValue * > &Operands)
Load_match(Addr_t Addr, Mask_t Mask)
bool match(const VPSingleDefRecipe *R) const
bool match(const VPValue *V) const
bool match(const VPRecipeBase *R) const
SpecificCmp_match is a variant of Cmp_match that matches the comparison predicate,...
SpecificCmp_match(CmpPredicate Pred, const Op0_t &LHS, const Op1_t &RHS)
bool match(const VPRecipeBase *V) const
Store_match(Addr_t Addr, Val_t Val, Mask_t Mask)
bool match(const VPValue *VPV) const
bool match(const VPValue *VPV) const
Match the canonical induction variable (IV) of any loop region.
Match a canonical VPWidenIntOrFpInductionRecipe optionally capturing it.
canonical_widen_iv_match(VPWidenIntOrFpInductionRecipe *&V)
Match an integer constant if Pred::isValue returns true for the APInt.
bool match(const VPValue *VPV) const
bool isValue(const APInt &C) const
Match a specified signed or unsigned integer value.
is_specific_int(APInt Val, bool IsSigned=false)
match_combine_and< typename m_Intrinsic_Ty< T0, T1 >::Ty, Argument_match< T2 > > Ty
match_combine_and< typename m_Intrinsic_Ty< T0 >::Ty, Argument_match< T1 > > Ty
match_combine_and< IntrinsicID_match, Argument_match< T0 > > Ty
Intrinsic matches are combinations of ID matchers, and argument matchers.
match_combine_and< typename m_Intrinsic_Ty< T0, T1, T2 >::Ty, Argument_match< T3 > > Ty
bool match(const VPValue *V) const
bool match(const VPValue *VPV) const