LLVM  13.0.0git
PatternMatch.h
Go to the documentation of this file.
1 //===- PatternMatch.h - Match on the LLVM IR --------------------*- 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 LLVM IR. The power of these routines is
11 // that it allows you to write concise patterns that are expressive and easy to
12 // understand. The other major advantage of this is that it allows you to
13 // trivially capture/bind elements in the pattern to variables. For example,
14 // you can do something like this:
15 //
16 // Value *Exp = ...
17 // Value *X, *Y; ConstantInt *C1, *C2; // (X & C1) | (Y & C2)
18 // if (match(Exp, m_Or(m_And(m_Value(X), m_ConstantInt(C1)),
19 // m_And(m_Value(Y), m_ConstantInt(C2))))) {
20 // ... Pattern is matched and variables are bound ...
21 // }
22 //
23 // This is primarily useful to things like the instruction combiner, but can
24 // also be useful for static analysis tools or code generators.
25 //
26 //===----------------------------------------------------------------------===//
27 
28 #ifndef LLVM_IR_PATTERNMATCH_H
29 #define LLVM_IR_PATTERNMATCH_H
30 
31 #include "llvm/ADT/APFloat.h"
32 #include "llvm/ADT/APInt.h"
33 #include "llvm/IR/Constant.h"
34 #include "llvm/IR/Constants.h"
35 #include "llvm/IR/DataLayout.h"
36 #include "llvm/IR/InstrTypes.h"
37 #include "llvm/IR/Instruction.h"
38 #include "llvm/IR/Instructions.h"
39 #include "llvm/IR/IntrinsicInst.h"
40 #include "llvm/IR/Intrinsics.h"
41 #include "llvm/IR/Operator.h"
42 #include "llvm/IR/Value.h"
43 #include "llvm/Support/Casting.h"
44 #include <cstdint>
45 
46 namespace llvm {
47 namespace PatternMatch {
48 
49 template <typename Val, typename Pattern> bool match(Val *V, const Pattern &P) {
50  return const_cast<Pattern &>(P).match(V);
51 }
52 
53 template <typename Pattern> bool match(ArrayRef<int> Mask, const Pattern &P) {
54  return const_cast<Pattern &>(P).match(Mask);
55 }
56 
57 template <typename SubPattern_t> struct OneUse_match {
58  SubPattern_t SubPattern;
59 
60  OneUse_match(const SubPattern_t &SP) : SubPattern(SP) {}
61 
62  template <typename OpTy> bool match(OpTy *V) {
63  return V->hasOneUse() && SubPattern.match(V);
64  }
65 };
66 
67 template <typename T> inline OneUse_match<T> m_OneUse(const T &SubPattern) {
68  return SubPattern;
69 }
70 
71 template <typename Class> struct class_match {
72  template <typename ITy> bool match(ITy *V) { return isa<Class>(V); }
73 };
74 
75 /// Match an arbitrary value and ignore it.
77 
78 /// Match an arbitrary unary operation and ignore it.
81 }
82 
83 /// Match an arbitrary binary operation and ignore it.
86 }
87 
88 /// Matches any compare instruction and ignore it.
90 
91 struct undef_match {
92  static bool check(const Value *V) {
93  if (isa<UndefValue>(V))
94  return true;
95 
96  const auto *CA = dyn_cast<ConstantAggregate>(V);
97  if (!CA)
98  return false;
99 
102 
103  // Either UndefValue, PoisonValue, or an aggregate that only contains
104  // these is accepted by matcher.
105  // CheckValue returns false if CA cannot satisfy this constraint.
106  auto CheckValue = [&](const ConstantAggregate *CA) {
107  for (const Value *Op : CA->operand_values()) {
108  if (isa<UndefValue>(Op))
109  continue;
110 
111  const auto *CA = dyn_cast<ConstantAggregate>(Op);
112  if (!CA)
113  return false;
114  if (Seen.insert(CA).second)
115  Worklist.emplace_back(CA);
116  }
117 
118  return true;
119  };
120 
121  if (!CheckValue(CA))
122  return false;
123 
124  while (!Worklist.empty()) {
125  if (!CheckValue(Worklist.pop_back_val()))
126  return false;
127  }
128  return true;
129  }
130  template <typename ITy> bool match(ITy *V) { return check(V); }
131 };
132 
133 /// Match an arbitrary undef constant. This matches poison as well.
134 /// If this is an aggregate and contains a non-aggregate element that is
135 /// neither undef nor poison, the aggregate is not matched.
136 inline auto m_Undef() { return undef_match(); }
137 
138 /// Match an arbitrary poison constant.
140 
141 /// Match an arbitrary Constant and ignore it.
143 
144 /// Match an arbitrary ConstantInt and ignore it.
146  return class_match<ConstantInt>();
147 }
148 
149 /// Match an arbitrary ConstantFP and ignore it.
151  return class_match<ConstantFP>();
152 }
153 
154 /// Match an arbitrary ConstantExpr and ignore it.
156  return class_match<ConstantExpr>();
157 }
158 
159 /// Match an arbitrary basic block value and ignore it.
161  return class_match<BasicBlock>();
162 }
163 
164 /// Inverting matcher
165 template <typename Ty> struct match_unless {
166  Ty M;
167 
168  match_unless(const Ty &Matcher) : M(Matcher) {}
169 
170  template <typename ITy> bool match(ITy *V) { return !M.match(V); }
171 };
172 
173 /// Match if the inner matcher does *NOT* match.
174 template <typename Ty> inline match_unless<Ty> m_Unless(const Ty &M) {
175  return match_unless<Ty>(M);
176 }
177 
178 /// Matching combinators
179 template <typename LTy, typename RTy> struct match_combine_or {
180  LTy L;
181  RTy R;
182 
183  match_combine_or(const LTy &Left, const RTy &Right) : L(Left), R(Right) {}
184 
185  template <typename ITy> bool match(ITy *V) {
186  if (L.match(V))
187  return true;
188  if (R.match(V))
189  return true;
190  return false;
191  }
192 };
193 
194 template <typename LTy, typename RTy> struct match_combine_and {
195  LTy L;
196  RTy R;
197 
198  match_combine_and(const LTy &Left, const RTy &Right) : L(Left), R(Right) {}
199 
200  template <typename ITy> bool match(ITy *V) {
201  if (L.match(V))
202  if (R.match(V))
203  return true;
204  return false;
205  }
206 };
207 
208 /// Combine two pattern matchers matching L || R
209 template <typename LTy, typename RTy>
210 inline match_combine_or<LTy, RTy> m_CombineOr(const LTy &L, const RTy &R) {
211  return match_combine_or<LTy, RTy>(L, R);
212 }
213 
214 /// Combine two pattern matchers matching L && R
215 template <typename LTy, typename RTy>
216 inline match_combine_and<LTy, RTy> m_CombineAnd(const LTy &L, const RTy &R) {
217  return match_combine_and<LTy, RTy>(L, R);
218 }
219 
220 struct apint_match {
221  const APInt *&Res;
223 
225  : Res(Res), AllowUndef(AllowUndef) {}
226 
227  template <typename ITy> bool match(ITy *V) {
228  if (auto *CI = dyn_cast<ConstantInt>(V)) {
229  Res = &CI->getValue();
230  return true;
231  }
232  if (V->getType()->isVectorTy())
233  if (const auto *C = dyn_cast<Constant>(V))
234  if (auto *CI = dyn_cast_or_null<ConstantInt>(
235  C->getSplatValue(AllowUndef))) {
236  Res = &CI->getValue();
237  return true;
238  }
239  return false;
240  }
241 };
242 // Either constexpr if or renaming ConstantFP::getValueAPF to
243 // ConstantFP::getValue is needed to do it via single template
244 // function for both apint/apfloat.
246  const APFloat *&Res;
248 
250  : Res(Res), AllowUndef(AllowUndef) {}
251 
252  template <typename ITy> bool match(ITy *V) {
253  if (auto *CI = dyn_cast<ConstantFP>(V)) {
254  Res = &CI->getValueAPF();
255  return true;
256  }
257  if (V->getType()->isVectorTy())
258  if (const auto *C = dyn_cast<Constant>(V))
259  if (auto *CI = dyn_cast_or_null<ConstantFP>(
260  C->getSplatValue(AllowUndef))) {
261  Res = &CI->getValueAPF();
262  return true;
263  }
264  return false;
265  }
266 };
267 
268 /// Match a ConstantInt or splatted ConstantVector, binding the
269 /// specified pointer to the contained APInt.
270 inline apint_match m_APInt(const APInt *&Res) {
271  // Forbid undefs by default to maintain previous behavior.
272  return apint_match(Res, /* AllowUndef */ false);
273 }
274 
275 /// Match APInt while allowing undefs in splat vector constants.
276 inline apint_match m_APIntAllowUndef(const APInt *&Res) {
277  return apint_match(Res, /* AllowUndef */ true);
278 }
279 
280 /// Match APInt while forbidding undefs in splat vector constants.
281 inline apint_match m_APIntForbidUndef(const APInt *&Res) {
282  return apint_match(Res, /* AllowUndef */ false);
283 }
284 
285 /// Match a ConstantFP or splatted ConstantVector, binding the
286 /// specified pointer to the contained APFloat.
287 inline apfloat_match m_APFloat(const APFloat *&Res) {
288  // Forbid undefs by default to maintain previous behavior.
289  return apfloat_match(Res, /* AllowUndef */ false);
290 }
291 
292 /// Match APFloat while allowing undefs in splat vector constants.
294  return apfloat_match(Res, /* AllowUndef */ true);
295 }
296 
297 /// Match APFloat while forbidding undefs in splat vector constants.
299  return apfloat_match(Res, /* AllowUndef */ false);
300 }
301 
302 template <int64_t Val> struct constantint_match {
303  template <typename ITy> bool match(ITy *V) {
304  if (const auto *CI = dyn_cast<ConstantInt>(V)) {
305  const APInt &CIV = CI->getValue();
306  if (Val >= 0)
307  return CIV == static_cast<uint64_t>(Val);
308  // If Val is negative, and CI is shorter than it, truncate to the right
309  // number of bits. If it is larger, then we have to sign extend. Just
310  // compare their negated values.
311  return -CIV == -Val;
312  }
313  return false;
314  }
315 };
316 
317 /// Match a ConstantInt with a specific value.
318 template <int64_t Val> inline constantint_match<Val> m_ConstantInt() {
319  return constantint_match<Val>();
320 }
321 
322 /// This helper class is used to match constant scalars, vector splats,
323 /// and fixed width vectors that satisfy a specified predicate.
324 /// For fixed width vector constants, undefined elements are ignored.
325 template <typename Predicate, typename ConstantVal>
326 struct cstval_pred_ty : public Predicate {
327  template <typename ITy> bool match(ITy *V) {
328  if (const auto *CV = dyn_cast<ConstantVal>(V))
329  return this->isValue(CV->getValue());
330  if (const auto *VTy = dyn_cast<VectorType>(V->getType())) {
331  if (const auto *C = dyn_cast<Constant>(V)) {
332  if (const auto *CV = dyn_cast_or_null<ConstantVal>(C->getSplatValue()))
333  return this->isValue(CV->getValue());
334 
335  // Number of elements of a scalable vector unknown at compile time
336  auto *FVTy = dyn_cast<FixedVectorType>(VTy);
337  if (!FVTy)
338  return false;
339 
340  // Non-splat vector constant: check each element for a match.
341  unsigned NumElts = FVTy->getNumElements();
342  assert(NumElts != 0 && "Constant vector with no elements?");
343  bool HasNonUndefElements = false;
344  for (unsigned i = 0; i != NumElts; ++i) {
345  Constant *Elt = C->getAggregateElement(i);
346  if (!Elt)
347  return false;
348  if (isa<UndefValue>(Elt))
349  continue;
350  auto *CV = dyn_cast<ConstantVal>(Elt);
351  if (!CV || !this->isValue(CV->getValue()))
352  return false;
353  HasNonUndefElements = true;
354  }
355  return HasNonUndefElements;
356  }
357  }
358  return false;
359  }
360 };
361 
362 /// specialization of cstval_pred_ty for ConstantInt
363 template <typename Predicate>
365 
366 /// specialization of cstval_pred_ty for ConstantFP
367 template <typename Predicate>
369 
370 /// This helper class is used to match scalar and vector constants that
371 /// satisfy a specified predicate, and bind them to an APInt.
372 template <typename Predicate> struct api_pred_ty : public Predicate {
373  const APInt *&Res;
374 
375  api_pred_ty(const APInt *&R) : Res(R) {}
376 
377  template <typename ITy> bool match(ITy *V) {
378  if (const auto *CI = dyn_cast<ConstantInt>(V))
379  if (this->isValue(CI->getValue())) {
380  Res = &CI->getValue();
381  return true;
382  }
383  if (V->getType()->isVectorTy())
384  if (const auto *C = dyn_cast<Constant>(V))
385  if (auto *CI = dyn_cast_or_null<ConstantInt>(C->getSplatValue()))
386  if (this->isValue(CI->getValue())) {
387  Res = &CI->getValue();
388  return true;
389  }
390 
391  return false;
392  }
393 };
394 
395 /// This helper class is used to match scalar and vector constants that
396 /// satisfy a specified predicate, and bind them to an APFloat.
397 /// Undefs are allowed in splat vector constants.
398 template <typename Predicate> struct apf_pred_ty : public Predicate {
399  const APFloat *&Res;
400 
401  apf_pred_ty(const APFloat *&R) : Res(R) {}
402 
403  template <typename ITy> bool match(ITy *V) {
404  if (const auto *CI = dyn_cast<ConstantFP>(V))
405  if (this->isValue(CI->getValue())) {
406  Res = &CI->getValue();
407  return true;
408  }
409  if (V->getType()->isVectorTy())
410  if (const auto *C = dyn_cast<Constant>(V))
411  if (auto *CI = dyn_cast_or_null<ConstantFP>(
412  C->getSplatValue(/* AllowUndef */ true)))
413  if (this->isValue(CI->getValue())) {
414  Res = &CI->getValue();
415  return true;
416  }
417 
418  return false;
419  }
420 };
421 
422 ///////////////////////////////////////////////////////////////////////////////
423 //
424 // Encapsulate constant value queries for use in templated predicate matchers.
425 // This allows checking if constants match using compound predicates and works
426 // with vector constants, possibly with relaxed constraints. For example, ignore
427 // undef values.
428 //
429 ///////////////////////////////////////////////////////////////////////////////
430 
431 struct is_any_apint {
432  bool isValue(const APInt &C) { return true; }
433 };
434 /// Match an integer or vector with any integral constant.
435 /// For vectors, this includes constants with undefined elements.
437  return cst_pred_ty<is_any_apint>();
438 }
439 
440 struct is_all_ones {
441  bool isValue(const APInt &C) { return C.isAllOnesValue(); }
442 };
443 /// Match an integer or vector with all bits set.
444 /// For vectors, this includes constants with undefined elements.
446  return cst_pred_ty<is_all_ones>();
447 }
448 
450  bool isValue(const APInt &C) { return C.isMaxSignedValue(); }
451 };
452 /// Match an integer or vector with values having all bits except for the high
453 /// bit set (0x7f...).
454 /// For vectors, this includes constants with undefined elements.
457 }
459  return V;
460 }
461 
462 struct is_negative {
463  bool isValue(const APInt &C) { return C.isNegative(); }
464 };
465 /// Match an integer or vector of negative values.
466 /// For vectors, this includes constants with undefined elements.
468  return cst_pred_ty<is_negative>();
469 }
471  return V;
472 }
473 
475  bool isValue(const APInt &C) { return C.isNonNegative(); }
476 };
477 /// Match an integer or vector of non-negative values.
478 /// For vectors, this includes constants with undefined elements.
481 }
483  return V;
484 }
485 
487  bool isValue(const APInt &C) { return C.isStrictlyPositive(); }
488 };
489 /// Match an integer or vector of strictly positive values.
490 /// For vectors, this includes constants with undefined elements.
493 }
495  return V;
496 }
497 
499  bool isValue(const APInt &C) { return C.isNonPositive(); }
500 };
501 /// Match an integer or vector of non-positive values.
502 /// For vectors, this includes constants with undefined elements.
505 }
506 inline api_pred_ty<is_nonpositive> m_NonPositive(const APInt *&V) { return V; }
507 
508 struct is_one {
509  bool isValue(const APInt &C) { return C.isOneValue(); }
510 };
511 /// Match an integer 1 or a vector with all elements equal to 1.
512 /// For vectors, this includes constants with undefined elements.
514  return cst_pred_ty<is_one>();
515 }
516 
517 struct is_zero_int {
518  bool isValue(const APInt &C) { return C.isNullValue(); }
519 };
520 /// Match an integer 0 or a vector with all elements equal to 0.
521 /// For vectors, this includes constants with undefined elements.
523  return cst_pred_ty<is_zero_int>();
524 }
525 
526 struct is_zero {
527  template <typename ITy> bool match(ITy *V) {
528  auto *C = dyn_cast<Constant>(V);
529  // FIXME: this should be able to do something for scalable vectors
530  return C && (C->isNullValue() || cst_pred_ty<is_zero_int>().match(C));
531  }
532 };
533 /// Match any null constant or a vector with all elements equal to 0.
534 /// For vectors, this includes constants with undefined elements.
535 inline is_zero m_Zero() {
536  return is_zero();
537 }
538 
539 struct is_power2 {
540  bool isValue(const APInt &C) { return C.isPowerOf2(); }
541 };
542 /// Match an integer or vector power-of-2.
543 /// For vectors, this includes constants with undefined elements.
545  return cst_pred_ty<is_power2>();
546 }
548  return V;
549 }
550 
552  bool isValue(const APInt &C) { return (-C).isPowerOf2(); }
553 };
554 /// Match a integer or vector negated power-of-2.
555 /// For vectors, this includes constants with undefined elements.
558 }
560  return V;
561 }
562 
564  bool isValue(const APInt &C) { return !C || C.isPowerOf2(); }
565 };
566 /// Match an integer or vector of 0 or power-of-2 values.
567 /// For vectors, this includes constants with undefined elements.
570 }
572  return V;
573 }
574 
575 struct is_sign_mask {
576  bool isValue(const APInt &C) { return C.isSignMask(); }
577 };
578 /// Match an integer or vector with only the sign bit(s) set.
579 /// For vectors, this includes constants with undefined elements.
581  return cst_pred_ty<is_sign_mask>();
582 }
583 
585  bool isValue(const APInt &C) { return C.isMask(); }
586 };
587 /// Match an integer or vector with only the low bit(s) set.
588 /// For vectors, this includes constants with undefined elements.
591 }
592 
595  const APInt *Thr;
596  bool isValue(const APInt &C) {
597  switch (Pred) {
598  case ICmpInst::Predicate::ICMP_EQ:
599  return C.eq(*Thr);
600  case ICmpInst::Predicate::ICMP_NE:
601  return C.ne(*Thr);
602  case ICmpInst::Predicate::ICMP_UGT:
603  return C.ugt(*Thr);
604  case ICmpInst::Predicate::ICMP_UGE:
605  return C.uge(*Thr);
606  case ICmpInst::Predicate::ICMP_ULT:
607  return C.ult(*Thr);
608  case ICmpInst::Predicate::ICMP_ULE:
609  return C.ule(*Thr);
610  case ICmpInst::Predicate::ICMP_SGT:
611  return C.sgt(*Thr);
612  case ICmpInst::Predicate::ICMP_SGE:
613  return C.sge(*Thr);
614  case ICmpInst::Predicate::ICMP_SLT:
615  return C.slt(*Thr);
616  case ICmpInst::Predicate::ICMP_SLE:
617  return C.sle(*Thr);
618  default:
619  llvm_unreachable("Unhandled ICmp predicate");
620  }
621  }
622 };
623 /// Match an integer or vector with every element comparing 'pred' (eg/ne/...)
624 /// to Threshold. For vectors, this includes constants with undefined elements.
625 inline cst_pred_ty<icmp_pred_with_threshold>
628  P.Pred = Predicate;
629  P.Thr = &Threshold;
630  return P;
631 }
632 
633 struct is_nan {
634  bool isValue(const APFloat &C) { return C.isNaN(); }
635 };
636 /// Match an arbitrary NaN constant. This includes quiet and signalling nans.
637 /// For vectors, this includes constants with undefined elements.
639  return cstfp_pred_ty<is_nan>();
640 }
641 
642 struct is_nonnan {
643  bool isValue(const APFloat &C) { return !C.isNaN(); }
644 };
645 /// Match a non-NaN FP constant.
646 /// For vectors, this includes constants with undefined elements.
648  return cstfp_pred_ty<is_nonnan>();
649 }
650 
651 struct is_inf {
652  bool isValue(const APFloat &C) { return C.isInfinity(); }
653 };
654 /// Match a positive or negative infinity FP constant.
655 /// For vectors, this includes constants with undefined elements.
657  return cstfp_pred_ty<is_inf>();
658 }
659 
660 struct is_noninf {
661  bool isValue(const APFloat &C) { return !C.isInfinity(); }
662 };
663 /// Match a non-infinity FP constant, i.e. finite or NaN.
664 /// For vectors, this includes constants with undefined elements.
666  return cstfp_pred_ty<is_noninf>();
667 }
668 
669 struct is_finite {
670  bool isValue(const APFloat &C) { return C.isFinite(); }
671 };
672 /// Match a finite FP constant, i.e. not infinity or NaN.
673 /// For vectors, this includes constants with undefined elements.
675  return cstfp_pred_ty<is_finite>();
676 }
677 inline apf_pred_ty<is_finite> m_Finite(const APFloat *&V) { return V; }
678 
680  bool isValue(const APFloat &C) { return C.isFiniteNonZero(); }
681 };
682 /// Match a finite non-zero FP constant.
683 /// For vectors, this includes constants with undefined elements.
686 }
688  return V;
689 }
690 
692  bool isValue(const APFloat &C) { return C.isZero(); }
693 };
694 /// Match a floating-point negative zero or positive zero.
695 /// For vectors, this includes constants with undefined elements.
698 }
699 
701  bool isValue(const APFloat &C) { return C.isPosZero(); }
702 };
703 /// Match a floating-point positive zero.
704 /// For vectors, this includes constants with undefined elements.
707 }
708 
710  bool isValue(const APFloat &C) { return C.isNegZero(); }
711 };
712 /// Match a floating-point negative zero.
713 /// For vectors, this includes constants with undefined elements.
716 }
717 
719  bool isValue(const APFloat &C) { return C.isNonZero(); }
720 };
721 /// Match a floating-point non-zero.
722 /// For vectors, this includes constants with undefined elements.
725 }
726 
727 ///////////////////////////////////////////////////////////////////////////////
728 
729 template <typename Class> struct bind_ty {
730  Class *&VR;
731 
732  bind_ty(Class *&V) : VR(V) {}
733 
734  template <typename ITy> bool match(ITy *V) {
735  if (auto *CV = dyn_cast<Class>(V)) {
736  VR = CV;
737  return true;
738  }
739  return false;
740  }
741 };
742 
743 /// Match a value, capturing it if we match.
744 inline bind_ty<Value> m_Value(Value *&V) { return V; }
745 inline bind_ty<const Value> m_Value(const Value *&V) { return V; }
746 
747 /// Match an instruction, capturing it if we match.
749 /// Match a unary operator, capturing it if we match.
751 /// Match a binary operator, capturing it if we match.
753 /// Match a with overflow intrinsic, capturing it if we match.
755 inline bind_ty<const WithOverflowInst>
757  return I;
758 }
759 
760 /// Match a Constant, capturing the value if we match.
761 inline bind_ty<Constant> m_Constant(Constant *&C) { return C; }
762 
763 /// Match a ConstantInt, capturing the value if we match.
764 inline bind_ty<ConstantInt> m_ConstantInt(ConstantInt *&CI) { return CI; }
765 
766 /// Match a ConstantFP, capturing the value if we match.
768 
769 /// Match a ConstantExpr, capturing the value if we match.
771 
772 /// Match a basic block value, capturing it if we match.
773 inline bind_ty<BasicBlock> m_BasicBlock(BasicBlock *&V) { return V; }
775  return V;
776 }
777 
778 /// Match an arbitrary immediate Constant and ignore it.
779 inline match_combine_and<class_match<Constant>,
780  match_unless<class_match<ConstantExpr>>>
783 }
784 
785 /// Match an immediate Constant, capturing the value if we match.
786 inline match_combine_and<bind_ty<Constant>,
787  match_unless<class_match<ConstantExpr>>>
790 }
791 
792 /// Match a specified Value*.
794  const Value *Val;
795 
796  specificval_ty(const Value *V) : Val(V) {}
797 
798  template <typename ITy> bool match(ITy *V) { return V == Val; }
799 };
800 
801 /// Match if we have a specific specified value.
802 inline specificval_ty m_Specific(const Value *V) { return V; }
803 
804 /// Stores a reference to the Value *, not the Value * itself,
805 /// thus can be used in commutative matchers.
806 template <typename Class> struct deferredval_ty {
807  Class *const &Val;
808 
809  deferredval_ty(Class *const &V) : Val(V) {}
810 
811  template <typename ITy> bool match(ITy *const V) { return V == Val; }
812 };
813 
814 /// A commutative-friendly version of m_Specific().
815 inline deferredval_ty<Value> m_Deferred(Value *const &V) { return V; }
817  return V;
818 }
819 
820 /// Match a specified floating point value or vector of all elements of
821 /// that value.
823  double Val;
824 
825  specific_fpval(double V) : Val(V) {}
826 
827  template <typename ITy> bool match(ITy *V) {
828  if (const auto *CFP = dyn_cast<ConstantFP>(V))
829  return CFP->isExactlyValue(Val);
830  if (V->getType()->isVectorTy())
831  if (const auto *C = dyn_cast<Constant>(V))
832  if (auto *CFP = dyn_cast_or_null<ConstantFP>(C->getSplatValue()))
833  return CFP->isExactlyValue(Val);
834  return false;
835  }
836 };
837 
838 /// Match a specific floating point value or vector with all elements
839 /// equal to the value.
840 inline specific_fpval m_SpecificFP(double V) { return specific_fpval(V); }
841 
842 /// Match a float 1.0 or vector with all elements equal to 1.0.
843 inline specific_fpval m_FPOne() { return m_SpecificFP(1.0); }
844 
846  uint64_t &VR;
847 
848  bind_const_intval_ty(uint64_t &V) : VR(V) {}
849 
850  template <typename ITy> bool match(ITy *V) {
851  if (const auto *CV = dyn_cast<ConstantInt>(V))
852  if (CV->getValue().ule(UINT64_MAX)) {
853  VR = CV->getZExtValue();
854  return true;
855  }
856  return false;
857  }
858 };
859 
860 /// Match a specified integer value or vector of all elements of that
861 /// value.
862 template <bool AllowUndefs>
865 
867 
868  template <typename ITy> bool match(ITy *V) {
869  const auto *CI = dyn_cast<ConstantInt>(V);
870  if (!CI && V->getType()->isVectorTy())
871  if (const auto *C = dyn_cast<Constant>(V))
872  CI = dyn_cast_or_null<ConstantInt>(C->getSplatValue(AllowUndefs));
873 
874  return CI && APInt::isSameValue(CI->getValue(), Val);
875  }
876 };
877 
878 /// Match a specific integer value or vector with all elements equal to
879 /// the value.
882 }
883 
885  return m_SpecificInt(APInt(64, V));
886 }
887 
889  return specific_intval<true>(std::move(V));
890 }
891 
893  return m_SpecificIntAllowUndef(APInt(64, V));
894 }
895 
896 /// Match a ConstantInt and bind to its value. This does not match
897 /// ConstantInts wider than 64-bits.
898 inline bind_const_intval_ty m_ConstantInt(uint64_t &V) { return V; }
899 
900 /// Match a specified basic block value.
903 
905 
906  template <typename ITy> bool match(ITy *V) {
907  const auto *BB = dyn_cast<BasicBlock>(V);
908  return BB && BB == Val;
909  }
910 };
911 
912 /// Match a specific basic block value.
914  return specific_bbval(BB);
915 }
916 
917 /// A commutative-friendly version of m_Specific().
919  return BB;
920 }
921 inline deferredval_ty<const BasicBlock>
922 m_Deferred(const BasicBlock *const &BB) {
923  return BB;
924 }
925 
926 //===----------------------------------------------------------------------===//
927 // Matcher for any binary operator.
928 //
929 template <typename LHS_t, typename RHS_t, bool Commutable = false>
931  LHS_t L;
932  RHS_t R;
933 
934  // The evaluation order is always stable, regardless of Commutability.
935  // The LHS is always matched first.
936  AnyBinaryOp_match(const LHS_t &LHS, const RHS_t &RHS) : L(LHS), R(RHS) {}
937 
938  template <typename OpTy> bool match(OpTy *V) {
939  if (auto *I = dyn_cast<BinaryOperator>(V))
940  return (L.match(I->getOperand(0)) && R.match(I->getOperand(1))) ||
941  (Commutable && L.match(I->getOperand(1)) &&
942  R.match(I->getOperand(0)));
943  return false;
944  }
945 };
946 
947 template <typename LHS, typename RHS>
948 inline AnyBinaryOp_match<LHS, RHS> m_BinOp(const LHS &L, const RHS &R) {
949  return AnyBinaryOp_match<LHS, RHS>(L, R);
950 }
951 
952 //===----------------------------------------------------------------------===//
953 // Matcher for any unary operator.
954 // TODO fuse unary, binary matcher into n-ary matcher
955 //
956 template <typename OP_t> struct AnyUnaryOp_match {
957  OP_t X;
958 
959  AnyUnaryOp_match(const OP_t &X) : X(X) {}
960 
961  template <typename OpTy> bool match(OpTy *V) {
962  if (auto *I = dyn_cast<UnaryOperator>(V))
963  return X.match(I->getOperand(0));
964  return false;
965  }
966 };
967 
968 template <typename OP_t> inline AnyUnaryOp_match<OP_t> m_UnOp(const OP_t &X) {
969  return AnyUnaryOp_match<OP_t>(X);
970 }
971 
972 //===----------------------------------------------------------------------===//
973 // Matchers for specific binary operators.
974 //
975 
976 template <typename LHS_t, typename RHS_t, unsigned Opcode,
977  bool Commutable = false>
979  LHS_t L;
980  RHS_t R;
981 
982  // The evaluation order is always stable, regardless of Commutability.
983  // The LHS is always matched first.
984  BinaryOp_match(const LHS_t &LHS, const RHS_t &RHS) : L(LHS), R(RHS) {}
985 
986  template <typename OpTy> bool match(OpTy *V) {
987  if (V->getValueID() == Value::InstructionVal + Opcode) {
988  auto *I = cast<BinaryOperator>(V);
989  return (L.match(I->getOperand(0)) && R.match(I->getOperand(1))) ||
990  (Commutable && L.match(I->getOperand(1)) &&
991  R.match(I->getOperand(0)));
992  }
993  if (auto *CE = dyn_cast<ConstantExpr>(V))
994  return CE->getOpcode() == Opcode &&
995  ((L.match(CE->getOperand(0)) && R.match(CE->getOperand(1))) ||
996  (Commutable && L.match(CE->getOperand(1)) &&
997  R.match(CE->getOperand(0))));
998  return false;
999  }
1000 };
1001 
1002 template <typename LHS, typename RHS>
1004  const RHS &R) {
1006 }
1007 
1008 template <typename LHS, typename RHS>
1010  const RHS &R) {
1012 }
1013 
1014 template <typename LHS, typename RHS>
1016  const RHS &R) {
1018 }
1019 
1020 template <typename LHS, typename RHS>
1022  const RHS &R) {
1024 }
1025 
1026 template <typename Op_t> struct FNeg_match {
1027  Op_t X;
1028 
1029  FNeg_match(const Op_t &Op) : X(Op) {}
1030  template <typename OpTy> bool match(OpTy *V) {
1031  auto *FPMO = dyn_cast<FPMathOperator>(V);
1032  if (!FPMO) return false;
1033 
1034  if (FPMO->getOpcode() == Instruction::FNeg)
1035  return X.match(FPMO->getOperand(0));
1036 
1037  if (FPMO->getOpcode() == Instruction::FSub) {
1038  if (FPMO->hasNoSignedZeros()) {
1039  // With 'nsz', any zero goes.
1040  if (!cstfp_pred_ty<is_any_zero_fp>().match(FPMO->getOperand(0)))
1041  return false;
1042  } else {
1043  // Without 'nsz', we need fsub -0.0, X exactly.
1044  if (!cstfp_pred_ty<is_neg_zero_fp>().match(FPMO->getOperand(0)))
1045  return false;
1046  }
1047 
1048  return X.match(FPMO->getOperand(1));
1049  }
1050 
1051  return false;
1052  }
1053 };
1054 
1055 /// Match 'fneg X' as 'fsub -0.0, X'.
1056 template <typename OpTy>
1057 inline FNeg_match<OpTy>
1058 m_FNeg(const OpTy &X) {
1059  return FNeg_match<OpTy>(X);
1060 }
1061 
1062 /// Match 'fneg X' as 'fsub +-0.0, X'.
1063 template <typename RHS>
1064 inline BinaryOp_match<cstfp_pred_ty<is_any_zero_fp>, RHS, Instruction::FSub>
1065 m_FNegNSZ(const RHS &X) {
1066  return m_FSub(m_AnyZeroFP(), X);
1067 }
1068 
1069 template <typename LHS, typename RHS>
1071  const RHS &R) {
1073 }
1074 
1075 template <typename LHS, typename RHS>
1077  const RHS &R) {
1079 }
1080 
1081 template <typename LHS, typename RHS>
1083  const RHS &R) {
1085 }
1086 
1087 template <typename LHS, typename RHS>
1089  const RHS &R) {
1091 }
1092 
1093 template <typename LHS, typename RHS>
1095  const RHS &R) {
1097 }
1098 
1099 template <typename LHS, typename RHS>
1101  const RHS &R) {
1103 }
1104 
1105 template <typename LHS, typename RHS>
1107  const RHS &R) {
1109 }
1110 
1111 template <typename LHS, typename RHS>
1113  const RHS &R) {
1115 }
1116 
1117 template <typename LHS, typename RHS>
1119  const RHS &R) {
1121 }
1122 
1123 template <typename LHS, typename RHS>
1125  const RHS &R) {
1127 }
1128 
1129 template <typename LHS, typename RHS>
1131  const RHS &R) {
1133 }
1134 
1135 template <typename LHS, typename RHS>
1137  const RHS &R) {
1139 }
1140 
1141 template <typename LHS, typename RHS>
1143  const RHS &R) {
1145 }
1146 
1147 template <typename LHS, typename RHS>
1149  const RHS &R) {
1151 }
1152 
1153 template <typename LHS_t, typename RHS_t, unsigned Opcode,
1154  unsigned WrapFlags = 0>
1156  LHS_t L;
1157  RHS_t R;
1158 
1159  OverflowingBinaryOp_match(const LHS_t &LHS, const RHS_t &RHS)
1160  : L(LHS), R(RHS) {}
1161 
1162  template <typename OpTy> bool match(OpTy *V) {
1163  if (auto *Op = dyn_cast<OverflowingBinaryOperator>(V)) {
1164  if (Op->getOpcode() != Opcode)
1165  return false;
1167  !Op->hasNoUnsignedWrap())
1168  return false;
1169  if (WrapFlags & OverflowingBinaryOperator::NoSignedWrap &&
1170  !Op->hasNoSignedWrap())
1171  return false;
1172  return L.match(Op->getOperand(0)) && R.match(Op->getOperand(1));
1173  }
1174  return false;
1175  }
1176 };
1177 
1178 template <typename LHS, typename RHS>
1179 inline OverflowingBinaryOp_match<LHS, RHS, Instruction::Add,
1181 m_NSWAdd(const LHS &L, const RHS &R) {
1184  L, R);
1185 }
1186 template <typename LHS, typename RHS>
1187 inline OverflowingBinaryOp_match<LHS, RHS, Instruction::Sub,
1189 m_NSWSub(const LHS &L, const RHS &R) {
1190  return OverflowingBinaryOp_match<LHS, RHS, Instruction::Sub,
1192  L, R);
1193 }
1194 template <typename LHS, typename RHS>
1195 inline OverflowingBinaryOp_match<LHS, RHS, Instruction::Mul,
1197 m_NSWMul(const LHS &L, const RHS &R) {
1198  return OverflowingBinaryOp_match<LHS, RHS, Instruction::Mul,
1200  L, R);
1201 }
1202 template <typename LHS, typename RHS>
1203 inline OverflowingBinaryOp_match<LHS, RHS, Instruction::Shl,
1205 m_NSWShl(const LHS &L, const RHS &R) {
1206  return OverflowingBinaryOp_match<LHS, RHS, Instruction::Shl,
1208  L, R);
1209 }
1210 
1211 template <typename LHS, typename RHS>
1212 inline OverflowingBinaryOp_match<LHS, RHS, Instruction::Add,
1214 m_NUWAdd(const LHS &L, const RHS &R) {
1217  L, R);
1218 }
1219 template <typename LHS, typename RHS>
1220 inline OverflowingBinaryOp_match<LHS, RHS, Instruction::Sub,
1222 m_NUWSub(const LHS &L, const RHS &R) {
1223  return OverflowingBinaryOp_match<LHS, RHS, Instruction::Sub,
1225  L, R);
1226 }
1227 template <typename LHS, typename RHS>
1228 inline OverflowingBinaryOp_match<LHS, RHS, Instruction::Mul,
1230 m_NUWMul(const LHS &L, const RHS &R) {
1231  return OverflowingBinaryOp_match<LHS, RHS, Instruction::Mul,
1233  L, R);
1234 }
1235 template <typename LHS, typename RHS>
1236 inline OverflowingBinaryOp_match<LHS, RHS, Instruction::Shl,
1238 m_NUWShl(const LHS &L, const RHS &R) {
1239  return OverflowingBinaryOp_match<LHS, RHS, Instruction::Shl,
1241  L, R);
1242 }
1243 
1244 //===----------------------------------------------------------------------===//
1245 // Class that matches a group of binary opcodes.
1246 //
1247 template <typename LHS_t, typename RHS_t, typename Predicate>
1249  LHS_t L;
1250  RHS_t R;
1251 
1252  BinOpPred_match(const LHS_t &LHS, const RHS_t &RHS) : L(LHS), R(RHS) {}
1253 
1254  template <typename OpTy> bool match(OpTy *V) {
1255  if (auto *I = dyn_cast<Instruction>(V))
1256  return this->isOpType(I->getOpcode()) && L.match(I->getOperand(0)) &&
1257  R.match(I->getOperand(1));
1258  if (auto *CE = dyn_cast<ConstantExpr>(V))
1259  return this->isOpType(CE->getOpcode()) && L.match(CE->getOperand(0)) &&
1260  R.match(CE->getOperand(1));
1261  return false;
1262  }
1263 };
1264 
1265 struct is_shift_op {
1266  bool isOpType(unsigned Opcode) { return Instruction::isShift(Opcode); }
1267 };
1268 
1270  bool isOpType(unsigned Opcode) {
1271  return Opcode == Instruction::LShr || Opcode == Instruction::AShr;
1272  }
1273 };
1274 
1276  bool isOpType(unsigned Opcode) {
1277  return Opcode == Instruction::LShr || Opcode == Instruction::Shl;
1278  }
1279 };
1280 
1282  bool isOpType(unsigned Opcode) {
1283  return Instruction::isBitwiseLogicOp(Opcode);
1284  }
1285 };
1286 
1287 struct is_idiv_op {
1288  bool isOpType(unsigned Opcode) {
1289  return Opcode == Instruction::SDiv || Opcode == Instruction::UDiv;
1290  }
1291 };
1292 
1293 struct is_irem_op {
1294  bool isOpType(unsigned Opcode) {
1295  return Opcode == Instruction::SRem || Opcode == Instruction::URem;
1296  }
1297 };
1298 
1299 /// Matches shift operations.
1300 template <typename LHS, typename RHS>
1302  const RHS &R) {
1304 }
1305 
1306 /// Matches logical shift operations.
1307 template <typename LHS, typename RHS>
1309  const RHS &R) {
1311 }
1312 
1313 /// Matches logical shift operations.
1314 template <typename LHS, typename RHS>
1315 inline BinOpPred_match<LHS, RHS, is_logical_shift_op>
1316 m_LogicalShift(const LHS &L, const RHS &R) {
1318 }
1319 
1320 /// Matches bitwise logic operations.
1321 template <typename LHS, typename RHS>
1322 inline BinOpPred_match<LHS, RHS, is_bitwiselogic_op>
1323 m_BitwiseLogic(const LHS &L, const RHS &R) {
1325 }
1326 
1327 /// Matches integer division operations.
1328 template <typename LHS, typename RHS>
1330  const RHS &R) {
1332 }
1333 
1334 /// Matches integer remainder operations.
1335 template <typename LHS, typename RHS>
1337  const RHS &R) {
1339 }
1340 
1341 //===----------------------------------------------------------------------===//
1342 // Class that matches exact binary ops.
1343 //
1344 template <typename SubPattern_t> struct Exact_match {
1345  SubPattern_t SubPattern;
1346 
1347  Exact_match(const SubPattern_t &SP) : SubPattern(SP) {}
1348 
1349  template <typename OpTy> bool match(OpTy *V) {
1350  if (auto *PEO = dyn_cast<PossiblyExactOperator>(V))
1351  return PEO->isExact() && SubPattern.match(V);
1352  return false;
1353  }
1354 };
1355 
1356 template <typename T> inline Exact_match<T> m_Exact(const T &SubPattern) {
1357  return SubPattern;
1358 }
1359 
1360 //===----------------------------------------------------------------------===//
1361 // Matchers for CmpInst classes
1362 //
1363 
1364 template <typename LHS_t, typename RHS_t, typename Class, typename PredicateTy,
1365  bool Commutable = false>
1367  PredicateTy &Predicate;
1368  LHS_t L;
1369  RHS_t R;
1370 
1371  // The evaluation order is always stable, regardless of Commutability.
1372  // The LHS is always matched first.
1373  CmpClass_match(PredicateTy &Pred, const LHS_t &LHS, const RHS_t &RHS)
1374  : Predicate(Pred), L(LHS), R(RHS) {}
1375 
1376  template <typename OpTy> bool match(OpTy *V) {
1377  if (auto *I = dyn_cast<Class>(V)) {
1378  if (L.match(I->getOperand(0)) && R.match(I->getOperand(1))) {
1379  Predicate = I->getPredicate();
1380  return true;
1381  } else if (Commutable && L.match(I->getOperand(1)) &&
1382  R.match(I->getOperand(0))) {
1383  Predicate = I->getSwappedPredicate();
1384  return true;
1385  }
1386  }
1387  return false;
1388  }
1389 };
1390 
1391 template <typename LHS, typename RHS>
1392 inline CmpClass_match<LHS, RHS, CmpInst, CmpInst::Predicate>
1393 m_Cmp(CmpInst::Predicate &Pred, const LHS &L, const RHS &R) {
1395 }
1396 
1397 template <typename LHS, typename RHS>
1398 inline CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate>
1399 m_ICmp(ICmpInst::Predicate &Pred, const LHS &L, const RHS &R) {
1401 }
1402 
1403 template <typename LHS, typename RHS>
1404 inline CmpClass_match<LHS, RHS, FCmpInst, FCmpInst::Predicate>
1405 m_FCmp(FCmpInst::Predicate &Pred, const LHS &L, const RHS &R) {
1407 }
1408 
1409 //===----------------------------------------------------------------------===//
1410 // Matchers for instructions with a given opcode and number of operands.
1411 //
1412 
1413 /// Matches instructions with Opcode and three operands.
1414 template <typename T0, unsigned Opcode> struct OneOps_match {
1415  T0 Op1;
1416 
1417  OneOps_match(const T0 &Op1) : Op1(Op1) {}
1418 
1419  template <typename OpTy> bool match(OpTy *V) {
1420  if (V->getValueID() == Value::InstructionVal + Opcode) {
1421  auto *I = cast<Instruction>(V);
1422  return Op1.match(I->getOperand(0));
1423  }
1424  return false;
1425  }
1426 };
1427 
1428 /// Matches instructions with Opcode and three operands.
1429 template <typename T0, typename T1, unsigned Opcode> struct TwoOps_match {
1430  T0 Op1;
1432 
1433  TwoOps_match(const T0 &Op1, const T1 &Op2) : Op1(Op1), Op2(Op2) {}
1434 
1435  template <typename OpTy> bool match(OpTy *V) {
1436  if (V->getValueID() == Value::InstructionVal + Opcode) {
1437  auto *I = cast<Instruction>(V);
1438  return Op1.match(I->getOperand(0)) && Op2.match(I->getOperand(1));
1439  }
1440  return false;
1441  }
1442 };
1443 
1444 /// Matches instructions with Opcode and three operands.
1445 template <typename T0, typename T1, typename T2, unsigned Opcode>
1447  T0 Op1;
1449  T2 Op3;
1450 
1451  ThreeOps_match(const T0 &Op1, const T1 &Op2, const T2 &Op3)
1452  : Op1(Op1), Op2(Op2), Op3(Op3) {}
1453 
1454  template <typename OpTy> bool match(OpTy *V) {
1455  if (V->getValueID() == Value::InstructionVal + Opcode) {
1456  auto *I = cast<Instruction>(V);
1457  return Op1.match(I->getOperand(0)) && Op2.match(I->getOperand(1)) &&
1458  Op3.match(I->getOperand(2));
1459  }
1460  return false;
1461  }
1462 };
1463 
1464 /// Matches SelectInst.
1465 template <typename Cond, typename LHS, typename RHS>
1466 inline ThreeOps_match<Cond, LHS, RHS, Instruction::Select>
1467 m_Select(const Cond &C, const LHS &L, const RHS &R) {
1469 }
1470 
1471 /// This matches a select of two constants, e.g.:
1472 /// m_SelectCst<-1, 0>(m_Value(V))
1473 template <int64_t L, int64_t R, typename Cond>
1474 inline ThreeOps_match<Cond, constantint_match<L>, constantint_match<R>,
1476 m_SelectCst(const Cond &C) {
1477  return m_Select(C, m_ConstantInt<L>(), m_ConstantInt<R>());
1478 }
1479 
1480 /// Matches FreezeInst.
1481 template <typename OpTy>
1484 }
1485 
1486 /// Matches InsertElementInst.
1487 template <typename Val_t, typename Elt_t, typename Idx_t>
1488 inline ThreeOps_match<Val_t, Elt_t, Idx_t, Instruction::InsertElement>
1489 m_InsertElt(const Val_t &Val, const Elt_t &Elt, const Idx_t &Idx) {
1491  Val, Elt, Idx);
1492 }
1493 
1494 /// Matches ExtractElementInst.
1495 template <typename Val_t, typename Idx_t>
1496 inline TwoOps_match<Val_t, Idx_t, Instruction::ExtractElement>
1497 m_ExtractElt(const Val_t &Val, const Idx_t &Idx) {
1499 }
1500 
1501 /// Matches shuffle.
1502 template <typename T0, typename T1, typename T2> struct Shuffle_match {
1503  T0 Op1;
1505  T2 Mask;
1506 
1507  Shuffle_match(const T0 &Op1, const T1 &Op2, const T2 &Mask)
1508  : Op1(Op1), Op2(Op2), Mask(Mask) {}
1509 
1510  template <typename OpTy> bool match(OpTy *V) {
1511  if (auto *I = dyn_cast<ShuffleVectorInst>(V)) {
1512  return Op1.match(I->getOperand(0)) && Op2.match(I->getOperand(1)) &&
1513  Mask.match(I->getShuffleMask());
1514  }
1515  return false;
1516  }
1517 };
1518 
1519 struct m_Mask {
1523  MaskRef = Mask;
1524  return true;
1525  }
1526 };
1527 
1528 struct m_ZeroMask {
1530  return all_of(Mask, [](int Elem) { return Elem == 0 || Elem == -1; });
1531  }
1532 };
1533 
1537  bool match(ArrayRef<int> Mask) { return MaskRef == Mask; }
1538 };
1539 
1544  auto First = find_if(Mask, [](int Elem) { return Elem != -1; });
1545  if (First == Mask.end())
1546  return false;
1547  SplatIndex = *First;
1548  return all_of(Mask,
1549  [First](int Elem) { return Elem == *First || Elem == -1; });
1550  }
1551 };
1552 
1553 /// Matches ShuffleVectorInst independently of mask value.
1554 template <typename V1_t, typename V2_t>
1555 inline TwoOps_match<V1_t, V2_t, Instruction::ShuffleVector>
1556 m_Shuffle(const V1_t &v1, const V2_t &v2) {
1558 }
1559 
1560 template <typename V1_t, typename V2_t, typename Mask_t>
1561 inline Shuffle_match<V1_t, V2_t, Mask_t>
1562 m_Shuffle(const V1_t &v1, const V2_t &v2, const Mask_t &mask) {
1563  return Shuffle_match<V1_t, V2_t, Mask_t>(v1, v2, mask);
1564 }
1565 
1566 /// Matches LoadInst.
1567 template <typename OpTy>
1570 }
1571 
1572 /// Matches StoreInst.
1573 template <typename ValueOpTy, typename PointerOpTy>
1574 inline TwoOps_match<ValueOpTy, PointerOpTy, Instruction::Store>
1575 m_Store(const ValueOpTy &ValueOp, const PointerOpTy &PointerOp) {
1577  PointerOp);
1578 }
1579 
1580 //===----------------------------------------------------------------------===//
1581 // Matchers for CastInst classes
1582 //
1583 
1584 template <typename Op_t, unsigned Opcode> struct CastClass_match {
1585  Op_t Op;
1586 
1587  CastClass_match(const Op_t &OpMatch) : Op(OpMatch) {}
1588 
1589  template <typename OpTy> bool match(OpTy *V) {
1590  if (auto *O = dyn_cast<Operator>(V))
1591  return O->getOpcode() == Opcode && Op.match(O->getOperand(0));
1592  return false;
1593  }
1594 };
1595 
1596 /// Matches BitCast.
1597 template <typename OpTy>
1600 }
1601 
1602 /// Matches PtrToInt.
1603 template <typename OpTy>
1606 }
1607 
1608 /// Matches IntToPtr.
1609 template <typename OpTy>
1612 }
1613 
1614 /// Matches Trunc.
1615 template <typename OpTy>
1618 }
1619 
1620 template <typename OpTy>
1621 inline match_combine_or<CastClass_match<OpTy, Instruction::Trunc>, OpTy>
1622 m_TruncOrSelf(const OpTy &Op) {
1623  return m_CombineOr(m_Trunc(Op), Op);
1624 }
1625 
1626 /// Matches SExt.
1627 template <typename OpTy>
1630 }
1631 
1632 /// Matches ZExt.
1633 template <typename OpTy>
1636 }
1637 
1638 template <typename OpTy>
1639 inline match_combine_or<CastClass_match<OpTy, Instruction::ZExt>, OpTy>
1640 m_ZExtOrSelf(const OpTy &Op) {
1641  return m_CombineOr(m_ZExt(Op), Op);
1642 }
1643 
1644 template <typename OpTy>
1645 inline match_combine_or<CastClass_match<OpTy, Instruction::SExt>, OpTy>
1646 m_SExtOrSelf(const OpTy &Op) {
1647  return m_CombineOr(m_SExt(Op), Op);
1648 }
1649 
1650 template <typename OpTy>
1651 inline match_combine_or<CastClass_match<OpTy, Instruction::ZExt>,
1652  CastClass_match<OpTy, Instruction::SExt>>
1653 m_ZExtOrSExt(const OpTy &Op) {
1654  return m_CombineOr(m_ZExt(Op), m_SExt(Op));
1655 }
1656 
1657 template <typename OpTy>
1658 inline match_combine_or<
1659  match_combine_or<CastClass_match<OpTy, Instruction::ZExt>,
1660  CastClass_match<OpTy, Instruction::SExt>>,
1661  OpTy>
1662 m_ZExtOrSExtOrSelf(const OpTy &Op) {
1663  return m_CombineOr(m_ZExtOrSExt(Op), Op);
1664 }
1665 
1666 template <typename OpTy>
1669 }
1670 
1671 template <typename OpTy>
1674 }
1675 
1676 template <typename OpTy>
1679 }
1680 
1681 template <typename OpTy>
1684 }
1685 
1686 template <typename OpTy>
1689 }
1690 
1691 template <typename OpTy>
1694 }
1695 
1696 //===----------------------------------------------------------------------===//
1697 // Matchers for control flow.
1698 //
1699 
1700 struct br_match {
1702 
1704 
1705  template <typename OpTy> bool match(OpTy *V) {
1706  if (auto *BI = dyn_cast<BranchInst>(V))
1707  if (BI->isUnconditional()) {
1708  Succ = BI->getSuccessor(0);
1709  return true;
1710  }
1711  return false;
1712  }
1713 };
1714 
1715 inline br_match m_UnconditionalBr(BasicBlock *&Succ) { return br_match(Succ); }
1716 
1717 template <typename Cond_t, typename TrueBlock_t, typename FalseBlock_t>
1718 struct brc_match {
1719  Cond_t Cond;
1720  TrueBlock_t T;
1721  FalseBlock_t F;
1722 
1723  brc_match(const Cond_t &C, const TrueBlock_t &t, const FalseBlock_t &f)
1724  : Cond(C), T(t), F(f) {}
1725 
1726  template <typename OpTy> bool match(OpTy *V) {
1727  if (auto *BI = dyn_cast<BranchInst>(V))
1728  if (BI->isConditional() && Cond.match(BI->getCondition()))
1729  return T.match(BI->getSuccessor(0)) && F.match(BI->getSuccessor(1));
1730  return false;
1731  }
1732 };
1733 
1734 template <typename Cond_t>
1735 inline brc_match<Cond_t, bind_ty<BasicBlock>, bind_ty<BasicBlock>>
1736 m_Br(const Cond_t &C, BasicBlock *&T, BasicBlock *&F) {
1738  C, m_BasicBlock(T), m_BasicBlock(F));
1739 }
1740 
1741 template <typename Cond_t, typename TrueBlock_t, typename FalseBlock_t>
1742 inline brc_match<Cond_t, TrueBlock_t, FalseBlock_t>
1743 m_Br(const Cond_t &C, const TrueBlock_t &T, const FalseBlock_t &F) {
1745 }
1746 
1747 //===----------------------------------------------------------------------===//
1748 // Matchers for max/min idioms, eg: "select (sgt x, y), x, y" -> smax(x,y).
1749 //
1750 
1751 template <typename CmpInst_t, typename LHS_t, typename RHS_t, typename Pred_t,
1752  bool Commutable = false>
1754  using PredType = Pred_t;
1755  LHS_t L;
1756  RHS_t R;
1757 
1758  // The evaluation order is always stable, regardless of Commutability.
1759  // The LHS is always matched first.
1760  MaxMin_match(const LHS_t &LHS, const RHS_t &RHS) : L(LHS), R(RHS) {}
1761 
1762  template <typename OpTy> bool match(OpTy *V) {
1763  if (auto *II = dyn_cast<IntrinsicInst>(V)) {
1764  Intrinsic::ID IID = II->getIntrinsicID();
1769  Value *LHS = II->getOperand(0), *RHS = II->getOperand(1);
1770  return (L.match(LHS) && R.match(RHS)) ||
1771  (Commutable && L.match(RHS) && R.match(LHS));
1772  }
1773  }
1774  // Look for "(x pred y) ? x : y" or "(x pred y) ? y : x".
1775  auto *SI = dyn_cast<SelectInst>(V);
1776  if (!SI)
1777  return false;
1778  auto *Cmp = dyn_cast<CmpInst_t>(SI->getCondition());
1779  if (!Cmp)
1780  return false;
1781  // At this point we have a select conditioned on a comparison. Check that
1782  // it is the values returned by the select that are being compared.
1783  auto *TrueVal = SI->getTrueValue();
1784  auto *FalseVal = SI->getFalseValue();
1785  auto *LHS = Cmp->getOperand(0);
1786  auto *RHS = Cmp->getOperand(1);
1787  if ((TrueVal != LHS || FalseVal != RHS) &&
1788  (TrueVal != RHS || FalseVal != LHS))
1789  return false;
1790  typename CmpInst_t::Predicate Pred =
1791  LHS == TrueVal ? Cmp->getPredicate() : Cmp->getInversePredicate();
1792  // Does "(x pred y) ? x : y" represent the desired max/min operation?
1793  if (!Pred_t::match(Pred))
1794  return false;
1795  // It does! Bind the operands.
1796  return (L.match(LHS) && R.match(RHS)) ||
1797  (Commutable && L.match(RHS) && R.match(LHS));
1798  }
1799 };
1800 
1801 /// Helper class for identifying signed max predicates.
1803  static bool match(ICmpInst::Predicate Pred) {
1804  return Pred == CmpInst::ICMP_SGT || Pred == CmpInst::ICMP_SGE;
1805  }
1806 };
1807 
1808 /// Helper class for identifying signed min predicates.
1810  static bool match(ICmpInst::Predicate Pred) {
1811  return Pred == CmpInst::ICMP_SLT || Pred == CmpInst::ICMP_SLE;
1812  }
1813 };
1814 
1815 /// Helper class for identifying unsigned max predicates.
1817  static bool match(ICmpInst::Predicate Pred) {
1818  return Pred == CmpInst::ICMP_UGT || Pred == CmpInst::ICMP_UGE;
1819  }
1820 };
1821 
1822 /// Helper class for identifying unsigned min predicates.
1824  static bool match(ICmpInst::Predicate Pred) {
1825  return Pred == CmpInst::ICMP_ULT || Pred == CmpInst::ICMP_ULE;
1826  }
1827 };
1828 
1829 /// Helper class for identifying ordered max predicates.
1831  static bool match(FCmpInst::Predicate Pred) {
1832  return Pred == CmpInst::FCMP_OGT || Pred == CmpInst::FCMP_OGE;
1833  }
1834 };
1835 
1836 /// Helper class for identifying ordered min predicates.
1838  static bool match(FCmpInst::Predicate Pred) {
1839  return Pred == CmpInst::FCMP_OLT || Pred == CmpInst::FCMP_OLE;
1840  }
1841 };
1842 
1843 /// Helper class for identifying unordered max predicates.
1845  static bool match(FCmpInst::Predicate Pred) {
1846  return Pred == CmpInst::FCMP_UGT || Pred == CmpInst::FCMP_UGE;
1847  }
1848 };
1849 
1850 /// Helper class for identifying unordered min predicates.
1852  static bool match(FCmpInst::Predicate Pred) {
1853  return Pred == CmpInst::FCMP_ULT || Pred == CmpInst::FCMP_ULE;
1854  }
1855 };
1856 
1857 template <typename LHS, typename RHS>
1859  const RHS &R) {
1861 }
1862 
1863 template <typename LHS, typename RHS>
1865  const RHS &R) {
1867 }
1868 
1869 template <typename LHS, typename RHS>
1871  const RHS &R) {
1873 }
1874 
1875 template <typename LHS, typename RHS>
1877  const RHS &R) {
1879 }
1880 
1881 template <typename LHS, typename RHS>
1882 inline match_combine_or<
1883  match_combine_or<MaxMin_match<ICmpInst, LHS, RHS, smax_pred_ty>,
1884  MaxMin_match<ICmpInst, LHS, RHS, smin_pred_ty>>,
1885  match_combine_or<MaxMin_match<ICmpInst, LHS, RHS, umax_pred_ty>,
1886  MaxMin_match<ICmpInst, LHS, RHS, umin_pred_ty>>>
1887 m_MaxOrMin(const LHS &L, const RHS &R) {
1888  return m_CombineOr(m_CombineOr(m_SMax(L, R), m_SMin(L, R)),
1889  m_CombineOr(m_UMax(L, R), m_UMin(L, R)));
1890 }
1891 
1892 /// Match an 'ordered' floating point maximum function.
1893 /// Floating point has one special value 'NaN'. Therefore, there is no total
1894 /// order. However, if we can ignore the 'NaN' value (for example, because of a
1895 /// 'no-nans-float-math' flag) a combination of a fcmp and select has 'maximum'
1896 /// semantics. In the presence of 'NaN' we have to preserve the original
1897 /// select(fcmp(ogt/ge, L, R), L, R) semantics matched by this predicate.
1898 ///
1899 /// max(L, R) iff L and R are not NaN
1900 /// m_OrdFMax(L, R) = R iff L or R are NaN
1901 template <typename LHS, typename RHS>
1903  const RHS &R) {
1905 }
1906 
1907 /// Match an 'ordered' floating point minimum function.
1908 /// Floating point has one special value 'NaN'. Therefore, there is no total
1909 /// order. However, if we can ignore the 'NaN' value (for example, because of a
1910 /// 'no-nans-float-math' flag) a combination of a fcmp and select has 'minimum'
1911 /// semantics. In the presence of 'NaN' we have to preserve the original
1912 /// select(fcmp(olt/le, L, R), L, R) semantics matched by this predicate.
1913 ///
1914 /// min(L, R) iff L and R are not NaN
1915 /// m_OrdFMin(L, R) = R iff L or R are NaN
1916 template <typename LHS, typename RHS>
1918  const RHS &R) {
1920 }
1921 
1922 /// Match an 'unordered' floating point maximum function.
1923 /// Floating point has one special value 'NaN'. Therefore, there is no total
1924 /// order. However, if we can ignore the 'NaN' value (for example, because of a
1925 /// 'no-nans-float-math' flag) a combination of a fcmp and select has 'maximum'
1926 /// semantics. In the presence of 'NaN' we have to preserve the original
1927 /// select(fcmp(ugt/ge, L, R), L, R) semantics matched by this predicate.
1928 ///
1929 /// max(L, R) iff L and R are not NaN
1930 /// m_UnordFMax(L, R) = L iff L or R are NaN
1931 template <typename LHS, typename RHS>
1932 inline MaxMin_match<FCmpInst, LHS, RHS, ufmax_pred_ty>
1933 m_UnordFMax(const LHS &L, const RHS &R) {
1935 }
1936 
1937 /// Match an 'unordered' floating point minimum function.
1938 /// Floating point has one special value 'NaN'. Therefore, there is no total
1939 /// order. However, if we can ignore the 'NaN' value (for example, because of a
1940 /// 'no-nans-float-math' flag) a combination of a fcmp and select has 'minimum'
1941 /// semantics. In the presence of 'NaN' we have to preserve the original
1942 /// select(fcmp(ult/le, L, R), L, R) semantics matched by this predicate.
1943 ///
1944 /// min(L, R) iff L and R are not NaN
1945 /// m_UnordFMin(L, R) = L iff L or R are NaN
1946 template <typename LHS, typename RHS>
1947 inline MaxMin_match<FCmpInst, LHS, RHS, ufmin_pred_ty>
1948 m_UnordFMin(const LHS &L, const RHS &R) {
1950 }
1951 
1952 //===----------------------------------------------------------------------===//
1953 // Matchers for overflow check patterns: e.g. (a + b) u< a, (a ^ -1) <u b
1954 // Note that S might be matched to other instructions than AddInst.
1955 //
1956 
1957 template <typename LHS_t, typename RHS_t, typename Sum_t>
1959  LHS_t L;
1960  RHS_t R;
1961  Sum_t S;
1962 
1963  UAddWithOverflow_match(const LHS_t &L, const RHS_t &R, const Sum_t &S)
1964  : L(L), R(R), S(S) {}
1965 
1966  template <typename OpTy> bool match(OpTy *V) {
1967  Value *ICmpLHS, *ICmpRHS;
1968  ICmpInst::Predicate Pred;
1969  if (!m_ICmp(Pred, m_Value(ICmpLHS), m_Value(ICmpRHS)).match(V))
1970  return false;
1971 
1972  Value *AddLHS, *AddRHS;
1973  auto AddExpr = m_Add(m_Value(AddLHS), m_Value(AddRHS));
1974 
1975  // (a + b) u< a, (a + b) u< b
1976  if (Pred == ICmpInst::ICMP_ULT)
1977  if (AddExpr.match(ICmpLHS) && (ICmpRHS == AddLHS || ICmpRHS == AddRHS))
1978  return L.match(AddLHS) && R.match(AddRHS) && S.match(ICmpLHS);
1979 
1980  // a >u (a + b), b >u (a + b)
1981  if (Pred == ICmpInst::ICMP_UGT)
1982  if (AddExpr.match(ICmpRHS) && (ICmpLHS == AddLHS || ICmpLHS == AddRHS))
1983  return L.match(AddLHS) && R.match(AddRHS) && S.match(ICmpRHS);
1984 
1985  Value *Op1;
1986  auto XorExpr = m_OneUse(m_Xor(m_Value(Op1), m_AllOnes()));
1987  // (a ^ -1) <u b
1988  if (Pred == ICmpInst::ICMP_ULT) {
1989  if (XorExpr.match(ICmpLHS))
1990  return L.match(Op1) && R.match(ICmpRHS) && S.match(ICmpLHS);
1991  }
1992  // b > u (a ^ -1)
1993  if (Pred == ICmpInst::ICMP_UGT) {
1994  if (XorExpr.match(ICmpRHS))
1995  return L.match(Op1) && R.match(ICmpLHS) && S.match(ICmpRHS);
1996  }
1997 
1998  // Match special-case for increment-by-1.
1999  if (Pred == ICmpInst::ICMP_EQ) {
2000  // (a + 1) == 0
2001  // (1 + a) == 0
2002  if (AddExpr.match(ICmpLHS) && m_ZeroInt().match(ICmpRHS) &&
2003  (m_One().match(AddLHS) || m_One().match(AddRHS)))
2004  return L.match(AddLHS) && R.match(AddRHS) && S.match(ICmpLHS);
2005  // 0 == (a + 1)
2006  // 0 == (1 + a)
2007  if (m_ZeroInt().match(ICmpLHS) && AddExpr.match(ICmpRHS) &&
2008  (m_One().match(AddLHS) || m_One().match(AddRHS)))
2009  return L.match(AddLHS) && R.match(AddRHS) && S.match(ICmpRHS);
2010  }
2011 
2012  return false;
2013  }
2014 };
2015 
2016 /// Match an icmp instruction checking for unsigned overflow on addition.
2017 ///
2018 /// S is matched to the addition whose result is being checked for overflow, and
2019 /// L and R are matched to the LHS and RHS of S.
2020 template <typename LHS_t, typename RHS_t, typename Sum_t>
2021 UAddWithOverflow_match<LHS_t, RHS_t, Sum_t>
2022 m_UAddWithOverflow(const LHS_t &L, const RHS_t &R, const Sum_t &S) {
2024 }
2025 
2026 template <typename Opnd_t> struct Argument_match {
2027  unsigned OpI;
2028  Opnd_t Val;
2029 
2030  Argument_match(unsigned OpIdx, const Opnd_t &V) : OpI(OpIdx), Val(V) {}
2031 
2032  template <typename OpTy> bool match(OpTy *V) {
2033  // FIXME: Should likely be switched to use `CallBase`.
2034  if (const auto *CI = dyn_cast<CallInst>(V))
2035  return Val.match(CI->getArgOperand(OpI));
2036  return false;
2037  }
2038 };
2039 
2040 /// Match an argument.
2041 template <unsigned OpI, typename Opnd_t>
2042 inline Argument_match<Opnd_t> m_Argument(const Opnd_t &Op) {
2043  return Argument_match<Opnd_t>(OpI, Op);
2044 }
2045 
2046 /// Intrinsic matchers.
2048  unsigned ID;
2049 
2050  IntrinsicID_match(Intrinsic::ID IntrID) : ID(IntrID) {}
2051 
2052  template <typename OpTy> bool match(OpTy *V) {
2053  if (const auto *CI = dyn_cast<CallInst>(V))
2054  if (const auto *F = CI->getCalledFunction())
2055  return F->getIntrinsicID() == ID;
2056  return false;
2057  }
2058 };
2059 
2060 /// Intrinsic matches are combinations of ID matchers, and argument
2061 /// matchers. Higher arity matcher are defined recursively in terms of and-ing
2062 /// them with lower arity matchers. Here's some convenient typedefs for up to
2063 /// several arguments, and more can be added as needed
2064 template <typename T0 = void, typename T1 = void, typename T2 = void,
2065  typename T3 = void, typename T4 = void, typename T5 = void,
2066  typename T6 = void, typename T7 = void, typename T8 = void,
2067  typename T9 = void, typename T10 = void>
2069 template <typename T0> struct m_Intrinsic_Ty<T0> {
2071 };
2072 template <typename T0, typename T1> struct m_Intrinsic_Ty<T0, T1> {
2073  using Ty =
2075 };
2076 template <typename T0, typename T1, typename T2>
2077 struct m_Intrinsic_Ty<T0, T1, T2> {
2078  using Ty =
2081 };
2082 template <typename T0, typename T1, typename T2, typename T3>
2083 struct m_Intrinsic_Ty<T0, T1, T2, T3> {
2084  using Ty =
2087 };
2088 
2089 template <typename T0, typename T1, typename T2, typename T3, typename T4>
2090 struct m_Intrinsic_Ty<T0, T1, T2, T3, T4> {
2093 };
2094 
2095 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5>
2096 struct m_Intrinsic_Ty<T0, T1, T2, T3, T4, T5> {
2099 };
2100 
2101 /// Match intrinsic calls like this:
2102 /// m_Intrinsic<Intrinsic::fabs>(m_Value(X))
2103 template <Intrinsic::ID IntrID> inline IntrinsicID_match m_Intrinsic() {
2104  return IntrinsicID_match(IntrID);
2105 }
2106 
2107 template <Intrinsic::ID IntrID, typename T0>
2108 inline typename m_Intrinsic_Ty<T0>::Ty m_Intrinsic(const T0 &Op0) {
2109  return m_CombineAnd(m_Intrinsic<IntrID>(), m_Argument<0>(Op0));
2110 }
2111 
2112 template <Intrinsic::ID IntrID, typename T0, typename T1>
2113 inline typename m_Intrinsic_Ty<T0, T1>::Ty m_Intrinsic(const T0 &Op0,
2114  const T1 &Op1) {
2115  return m_CombineAnd(m_Intrinsic<IntrID>(Op0), m_Argument<1>(Op1));
2116 }
2117 
2118 template <Intrinsic::ID IntrID, typename T0, typename T1, typename T2>
2119 inline typename m_Intrinsic_Ty<T0, T1, T2>::Ty
2120 m_Intrinsic(const T0 &Op0, const T1 &Op1, const T2 &Op2) {
2121  return m_CombineAnd(m_Intrinsic<IntrID>(Op0, Op1), m_Argument<2>(Op2));
2122 }
2123 
2124 template <Intrinsic::ID IntrID, typename T0, typename T1, typename T2,
2125  typename T3>
2126 inline typename m_Intrinsic_Ty<T0, T1, T2, T3>::Ty
2127 m_Intrinsic(const T0 &Op0, const T1 &Op1, const T2 &Op2, const T3 &Op3) {
2128  return m_CombineAnd(m_Intrinsic<IntrID>(Op0, Op1, Op2), m_Argument<3>(Op3));
2129 }
2130 
2131 template <Intrinsic::ID IntrID, typename T0, typename T1, typename T2,
2132  typename T3, typename T4>
2134 m_Intrinsic(const T0 &Op0, const T1 &Op1, const T2 &Op2, const T3 &Op3,
2135  const T4 &Op4) {
2136  return m_CombineAnd(m_Intrinsic<IntrID>(Op0, Op1, Op2, Op3),
2137  m_Argument<4>(Op4));
2138 }
2139 
2140 template <Intrinsic::ID IntrID, typename T0, typename T1, typename T2,
2141  typename T3, typename T4, typename T5>
2143 m_Intrinsic(const T0 &Op0, const T1 &Op1, const T2 &Op2, const T3 &Op3,
2144  const T4 &Op4, const T5 &Op5) {
2145  return m_CombineAnd(m_Intrinsic<IntrID>(Op0, Op1, Op2, Op3, Op4),
2146  m_Argument<5>(Op5));
2147 }
2148 
2149 // Helper intrinsic matching specializations.
2150 template <typename Opnd0>
2151 inline typename m_Intrinsic_Ty<Opnd0>::Ty m_BitReverse(const Opnd0 &Op0) {
2152  return m_Intrinsic<Intrinsic::bitreverse>(Op0);
2153 }
2154 
2155 template <typename Opnd0>
2156 inline typename m_Intrinsic_Ty<Opnd0>::Ty m_BSwap(const Opnd0 &Op0) {
2157  return m_Intrinsic<Intrinsic::bswap>(Op0);
2158 }
2159 
2160 template <typename Opnd0>
2161 inline typename m_Intrinsic_Ty<Opnd0>::Ty m_FAbs(const Opnd0 &Op0) {
2162  return m_Intrinsic<Intrinsic::fabs>(Op0);
2163 }
2164 
2165 template <typename Opnd0>
2166 inline typename m_Intrinsic_Ty<Opnd0>::Ty m_FCanonicalize(const Opnd0 &Op0) {
2167  return m_Intrinsic<Intrinsic::canonicalize>(Op0);
2168 }
2169 
2170 template <typename Opnd0, typename Opnd1>
2171 inline typename m_Intrinsic_Ty<Opnd0, Opnd1>::Ty m_FMin(const Opnd0 &Op0,
2172  const Opnd1 &Op1) {
2173  return m_Intrinsic<Intrinsic::minnum>(Op0, Op1);
2174 }
2175 
2176 template <typename Opnd0, typename Opnd1>
2177 inline typename m_Intrinsic_Ty<Opnd0, Opnd1>::Ty m_FMax(const Opnd0 &Op0,
2178  const Opnd1 &Op1) {
2179  return m_Intrinsic<Intrinsic::maxnum>(Op0, Op1);
2180 }
2181 
2182 template <typename Opnd0, typename Opnd1, typename Opnd2>
2183 inline typename m_Intrinsic_Ty<Opnd0, Opnd1, Opnd2>::Ty
2184 m_FShl(const Opnd0 &Op0, const Opnd1 &Op1, const Opnd2 &Op2) {
2185  return m_Intrinsic<Intrinsic::fshl>(Op0, Op1, Op2);
2186 }
2187 
2188 template <typename Opnd0, typename Opnd1, typename Opnd2>
2189 inline typename m_Intrinsic_Ty<Opnd0, Opnd1, Opnd2>::Ty
2190 m_FShr(const Opnd0 &Op0, const Opnd1 &Op1, const Opnd2 &Op2) {
2191  return m_Intrinsic<Intrinsic::fshr>(Op0, Op1, Op2);
2192 }
2193 
2194 //===----------------------------------------------------------------------===//
2195 // Matchers for two-operands operators with the operators in either order
2196 //
2197 
2198 /// Matches a BinaryOperator with LHS and RHS in either order.
2199 template <typename LHS, typename RHS>
2200 inline AnyBinaryOp_match<LHS, RHS, true> m_c_BinOp(const LHS &L, const RHS &R) {
2201  return AnyBinaryOp_match<LHS, RHS, true>(L, R);
2202 }
2203 
2204 /// Matches an ICmp with a predicate over LHS and RHS in either order.
2205 /// Swaps the predicate if operands are commuted.
2206 template <typename LHS, typename RHS>
2207 inline CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate, true>
2208 m_c_ICmp(ICmpInst::Predicate &Pred, const LHS &L, const RHS &R) {
2210  R);
2211 }
2212 
2213 /// Matches a Add with LHS and RHS in either order.
2214 template <typename LHS, typename RHS>
2216  const RHS &R) {
2218 }
2219 
2220 /// Matches a Mul with LHS and RHS in either order.
2221 template <typename LHS, typename RHS>
2223  const RHS &R) {
2225 }
2226 
2227 /// Matches an And with LHS and RHS in either order.
2228 template <typename LHS, typename RHS>
2230  const RHS &R) {
2232 }
2233 
2234 /// Matches an Or with LHS and RHS in either order.
2235 template <typename LHS, typename RHS>
2237  const RHS &R) {
2239 }
2240 
2241 /// Matches an Xor with LHS and RHS in either order.
2242 template <typename LHS, typename RHS>
2244  const RHS &R) {
2246 }
2247 
2248 /// Matches a 'Neg' as 'sub 0, V'.
2249 template <typename ValTy>
2250 inline BinaryOp_match<cst_pred_ty<is_zero_int>, ValTy, Instruction::Sub>
2251 m_Neg(const ValTy &V) {
2252  return m_Sub(m_ZeroInt(), V);
2253 }
2254 
2255 /// Matches a 'Neg' as 'sub nsw 0, V'.
2256 template <typename ValTy>
2257 inline OverflowingBinaryOp_match<cst_pred_ty<is_zero_int>, ValTy,
2258  Instruction::Sub,
2260 m_NSWNeg(const ValTy &V) {
2261  return m_NSWSub(m_ZeroInt(), V);
2262 }
2263 
2264 /// Matches a 'Not' as 'xor V, -1' or 'xor -1, V'.
2265 template <typename ValTy>
2266 inline BinaryOp_match<ValTy, cst_pred_ty<is_all_ones>, Instruction::Xor, true>
2267 m_Not(const ValTy &V) {
2268  return m_c_Xor(V, m_AllOnes());
2269 }
2270 
2271 /// Matches an SMin with LHS and RHS in either order.
2272 template <typename LHS, typename RHS>
2273 inline MaxMin_match<ICmpInst, LHS, RHS, smin_pred_ty, true>
2274 m_c_SMin(const LHS &L, const RHS &R) {
2276 }
2277 /// Matches an SMax with LHS and RHS in either order.
2278 template <typename LHS, typename RHS>
2279 inline MaxMin_match<ICmpInst, LHS, RHS, smax_pred_ty, true>
2280 m_c_SMax(const LHS &L, const RHS &R) {
2282 }
2283 /// Matches a UMin with LHS and RHS in either order.
2284 template <typename LHS, typename RHS>
2285 inline MaxMin_match<ICmpInst, LHS, RHS, umin_pred_ty, true>
2286 m_c_UMin(const LHS &L, const RHS &R) {
2288 }
2289 /// Matches a UMax with LHS and RHS in either order.
2290 template <typename LHS, typename RHS>
2291 inline MaxMin_match<ICmpInst, LHS, RHS, umax_pred_ty, true>
2292 m_c_UMax(const LHS &L, const RHS &R) {
2294 }
2295 
2296 template <typename LHS, typename RHS>
2297 inline match_combine_or<
2298  match_combine_or<MaxMin_match<ICmpInst, LHS, RHS, smax_pred_ty, true>,
2299  MaxMin_match<ICmpInst, LHS, RHS, smin_pred_ty, true>>,
2300  match_combine_or<MaxMin_match<ICmpInst, LHS, RHS, umax_pred_ty, true>,
2301  MaxMin_match<ICmpInst, LHS, RHS, umin_pred_ty, true>>>
2302 m_c_MaxOrMin(const LHS &L, const RHS &R) {
2303  return m_CombineOr(m_CombineOr(m_c_SMax(L, R), m_c_SMin(L, R)),
2304  m_CombineOr(m_c_UMax(L, R), m_c_UMin(L, R)));
2305 }
2306 
2307 /// Matches FAdd with LHS and RHS in either order.
2308 template <typename LHS, typename RHS>
2309 inline BinaryOp_match<LHS, RHS, Instruction::FAdd, true>
2310 m_c_FAdd(const LHS &L, const RHS &R) {
2312 }
2313 
2314 /// Matches FMul with LHS and RHS in either order.
2315 template <typename LHS, typename RHS>
2316 inline BinaryOp_match<LHS, RHS, Instruction::FMul, true>
2317 m_c_FMul(const LHS &L, const RHS &R) {
2319 }
2320 
2321 template <typename Opnd_t> struct Signum_match {
2322  Opnd_t Val;
2323  Signum_match(const Opnd_t &V) : Val(V) {}
2324 
2325  template <typename OpTy> bool match(OpTy *V) {
2326  unsigned TypeSize = V->getType()->getScalarSizeInBits();
2327  if (TypeSize == 0)
2328  return false;
2329 
2330  unsigned ShiftWidth = TypeSize - 1;
2331  Value *OpL = nullptr, *OpR = nullptr;
2332 
2333  // This is the representation of signum we match:
2334  //
2335  // signum(x) == (x >> 63) | (-x >>u 63)
2336  //
2337  // An i1 value is its own signum, so it's correct to match
2338  //
2339  // signum(x) == (x >> 0) | (-x >>u 0)
2340  //
2341  // for i1 values.
2342 
2343  auto LHS = m_AShr(m_Value(OpL), m_SpecificInt(ShiftWidth));
2344  auto RHS = m_LShr(m_Neg(m_Value(OpR)), m_SpecificInt(ShiftWidth));
2345  auto Signum = m_Or(LHS, RHS);
2346 
2347  return Signum.match(V) && OpL == OpR && Val.match(OpL);
2348  }
2349 };
2350 
2351 /// Matches a signum pattern.
2352 ///
2353 /// signum(x) =
2354 /// x > 0 -> 1
2355 /// x == 0 -> 0
2356 /// x < 0 -> -1
2357 template <typename Val_t> inline Signum_match<Val_t> m_Signum(const Val_t &V) {
2358  return Signum_match<Val_t>(V);
2359 }
2360 
2361 template <int Ind, typename Opnd_t> struct ExtractValue_match {
2362  Opnd_t Val;
2363  ExtractValue_match(const Opnd_t &V) : Val(V) {}
2364 
2365  template <typename OpTy> bool match(OpTy *V) {
2366  if (auto *I = dyn_cast<ExtractValueInst>(V)) {
2367  // If Ind is -1, don't inspect indices
2368  if (Ind != -1 &&
2369  !(I->getNumIndices() == 1 && I->getIndices()[0] == (unsigned)Ind))
2370  return false;
2371  return Val.match(I->getAggregateOperand());
2372  }
2373  return false;
2374  }
2375 };
2376 
2377 /// Match a single index ExtractValue instruction.
2378 /// For example m_ExtractValue<1>(...)
2379 template <int Ind, typename Val_t>
2382 }
2383 
2384 /// Match an ExtractValue instruction with any index.
2385 /// For example m_ExtractValue(...)
2386 template <typename Val_t>
2387 inline ExtractValue_match<-1, Val_t> m_ExtractValue(const Val_t &V) {
2388  return ExtractValue_match<-1, Val_t>(V);
2389 }
2390 
2391 /// Matcher for a single index InsertValue instruction.
2392 template <int Ind, typename T0, typename T1> struct InsertValue_match {
2393  T0 Op0;
2395 
2396  InsertValue_match(const T0 &Op0, const T1 &Op1) : Op0(Op0), Op1(Op1) {}
2397 
2398  template <typename OpTy> bool match(OpTy *V) {
2399  if (auto *I = dyn_cast<InsertValueInst>(V)) {
2400  return Op0.match(I->getOperand(0)) && Op1.match(I->getOperand(1)) &&
2401  I->getNumIndices() == 1 && Ind == I->getIndices()[0];
2402  }
2403  return false;
2404  }
2405 };
2406 
2407 /// Matches a single index InsertValue instruction.
2408 template <int Ind, typename Val_t, typename Elt_t>
2410  const Elt_t &Elt) {
2411  return InsertValue_match<Ind, Val_t, Elt_t>(Val, Elt);
2412 }
2413 
2414 /// Matches patterns for `vscale`. This can either be a call to `llvm.vscale` or
2415 /// the constant expression
2416 /// `ptrtoint(gep <vscale x 1 x i8>, <vscale x 1 x i8>* null, i32 1>`
2417 /// under the right conditions determined by DataLayout.
2419 private:
2420  template <typename Base, typename Offset>
2422  m_OffsetGep(const Base &B, const Offset &O) {
2424  }
2425 
2426 public:
2427  const DataLayout &DL;
2429 
2430  template <typename ITy> bool match(ITy *V) {
2431  if (m_Intrinsic<Intrinsic::vscale>().match(V))
2432  return true;
2433 
2434  if (m_PtrToInt(m_OffsetGep(m_Zero(), m_SpecificInt(1))).match(V)) {
2435  Type *PtrTy = cast<Operator>(V)->getOperand(0)->getType();
2436  auto *DerefTy = PtrTy->getPointerElementType();
2437  if (isa<ScalableVectorType>(DerefTy) &&
2438  DL.getTypeAllocSizeInBits(DerefTy).getKnownMinSize() == 8)
2439  return true;
2440  }
2441 
2442  return false;
2443  }
2444 };
2445 
2447  return VScaleVal_match(DL);
2448 }
2449 
2450 template <typename LHS, typename RHS, unsigned Opcode>
2452  LHS L;
2453  RHS R;
2454 
2455  LogicalOp_match(const LHS &L, const RHS &R) : L(L), R(R) {}
2456 
2457  template <typename T> bool match(T *V) {
2458  if (auto *I = dyn_cast<Instruction>(V)) {
2459  if (!I->getType()->isIntOrIntVectorTy(1))
2460  return false;
2461 
2462  if (I->getOpcode() == Opcode && L.match(I->getOperand(0)) &&
2463  R.match(I->getOperand(1)))
2464  return true;
2465 
2466  if (auto *SI = dyn_cast<SelectInst>(I)) {
2467  if (Opcode == Instruction::And) {
2468  if (const auto *C = dyn_cast<Constant>(SI->getFalseValue()))
2469  if (C->isNullValue() && L.match(SI->getCondition()) &&
2470  R.match(SI->getTrueValue()))
2471  return true;
2472  } else {
2473  assert(Opcode == Instruction::Or);
2474  if (const auto *C = dyn_cast<Constant>(SI->getTrueValue()))
2475  if (C->isOneValue() && L.match(SI->getCondition()) &&
2476  R.match(SI->getFalseValue()))
2477  return true;
2478  }
2479  }
2480  }
2481 
2482  return false;
2483  }
2484 };
2485 
2486 /// Matches L && R either in the form of L & R or L ? R : false.
2487 /// Note that the latter form is poison-blocking.
2488 template <typename LHS, typename RHS>
2489 inline LogicalOp_match<LHS, RHS, Instruction::And>
2490 m_LogicalAnd(const LHS &L, const RHS &R) {
2492 }
2493 
2494 /// Matches L && R where L and R are arbitrary values.
2495 inline auto m_LogicalAnd() { return m_LogicalAnd(m_Value(), m_Value()); }
2496 
2497 /// Matches L || R either in the form of L | R or L ? true : R.
2498 /// Note that the latter form is poison-blocking.
2499 template <typename LHS, typename RHS>
2500 inline LogicalOp_match<LHS, RHS, Instruction::Or>
2501 m_LogicalOr(const LHS &L, const RHS &R) {
2503 }
2504 
2505 /// Matches L || R where L and R are arbitrary values.
2506 inline auto m_LogicalOr() {
2507  return m_LogicalOr(m_Value(), m_Value());
2508 }
2509 
2510 } // end namespace PatternMatch
2511 } // end namespace llvm
2512 
2513 #endif // LLVM_IR_PATTERNMATCH_H
llvm::PatternMatch::apint_match::AllowUndef
bool AllowUndef
Definition: PatternMatch.h:222
llvm::PatternMatch::api_pred_ty
This helper class is used to match scalar and vector constants that satisfy a specified predicate,...
Definition: PatternMatch.h:372
llvm::PatternMatch::specificval_ty::match
bool match(ITy *V)
Definition: PatternMatch.h:798
llvm::PatternMatch::LogicalOp_match::match
bool match(T *V)
Definition: PatternMatch.h:2457
llvm::PatternMatch::Signum_match
Definition: PatternMatch.h:2321
i
i
Definition: README.txt:29
llvm::PatternMatch::bind_const_intval_ty::bind_const_intval_ty
bind_const_intval_ty(uint64_t &V)
Definition: PatternMatch.h:848
llvm::PatternMatch::MaxMin_match
Definition: PatternMatch.h:1753
llvm::CmpInst::FCMP_ULE
@ FCMP_ULE
1 1 0 1 True if unordered, less than, or equal
Definition: InstrTypes.h:737
llvm::PatternMatch::specific_intval::Val
APInt Val
Definition: PatternMatch.h:864
llvm::PatternMatch::LogicalOp_match::L
LHS L
Definition: PatternMatch.h:2452
llvm::PatternMatch::m_APFloatForbidUndef
apfloat_match m_APFloatForbidUndef(const APFloat *&Res)
Match APFloat while forbidding undefs in splat vector constants.
Definition: PatternMatch.h:298
llvm::PatternMatch::m_Intrinsic
IntrinsicID_match m_Intrinsic()
Match intrinsic calls like this: m_Intrinsic<Intrinsic::fabs>(m_Value(X))
Definition: PatternMatch.h:2103
llvm::PatternMatch::m_Power2OrZero
cst_pred_ty< is_power2_or_zero > m_Power2OrZero()
Match an integer or vector of 0 or power-of-2 values.
Definition: PatternMatch.h:568
llvm::PatternMatch::is_pos_zero_fp
Definition: PatternMatch.h:700
llvm::PatternMatch::m_FShr
m_Intrinsic_Ty< Opnd0, Opnd1, Opnd2 >::Ty m_FShr(const Opnd0 &Op0, const Opnd1 &Op1, const Opnd2 &Op2)
Definition: PatternMatch.h:2190
llvm::PatternMatch::is_finitenonzero::isValue
bool isValue(const APFloat &C)
Definition: PatternMatch.h:680
llvm::PatternMatch::is_nan::isValue
bool isValue(const APFloat &C)
Definition: PatternMatch.h:634
llvm::PatternMatch::m_SIToFP
CastClass_match< OpTy, Instruction::SIToFP > m_SIToFP(const OpTy &Op)
Definition: PatternMatch.h:1672
llvm::PatternMatch::is_zero_int::isValue
bool isValue(const APInt &C)
Definition: PatternMatch.h:518
llvm::PatternMatch::m_NonNegative
cst_pred_ty< is_nonnegative > m_NonNegative()
Match an integer or vector of non-negative values.
Definition: PatternMatch.h:479
llvm::PatternMatch::is_power2_or_zero::isValue
bool isValue(const APInt &C)
Definition: PatternMatch.h:564
llvm
Definition: AllocatorList.h:23
llvm::PatternMatch::ofmax_pred_ty::match
static bool match(FCmpInst::Predicate Pred)
Definition: PatternMatch.h:1831
llvm::PatternMatch::bind_ty
Definition: PatternMatch.h:729
llvm::PatternMatch::BinaryOp_match
Definition: PatternMatch.h:978
llvm::PatternMatch::Signum_match::match
bool match(OpTy *V)
Definition: PatternMatch.h:2325
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::CmpInst::ICMP_EQ
@ ICMP_EQ
equal
Definition: InstrTypes.h:743
llvm::PatternMatch::is_neg_zero_fp
Definition: PatternMatch.h:709
llvm::PatternMatch::m_TruncOrSelf
match_combine_or< CastClass_match< OpTy, Instruction::Trunc >, OpTy > m_TruncOrSelf(const OpTy &Op)
Definition: PatternMatch.h:1622
llvm::PatternMatch::class_match::match
bool match(ITy *V)
Definition: PatternMatch.h:72
llvm::PatternMatch::m_Mask
Definition: PatternMatch.h:1519
llvm::PatternMatch::BinOpPred_match::L
LHS_t L
Definition: PatternMatch.h:1249
llvm::PatternMatch::cstval_pred_ty::match
bool match(ITy *V)
Definition: PatternMatch.h:327
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:112
llvm::PatternMatch::m_UAddWithOverflow
UAddWithOverflow_match< LHS_t, RHS_t, Sum_t > m_UAddWithOverflow(const LHS_t &L, const RHS_t &R, const Sum_t &S)
Match an icmp instruction checking for unsigned overflow on addition.
Definition: PatternMatch.h:2022
llvm::PatternMatch::m_SpecificFP
specific_fpval m_SpecificFP(double V)
Match a specific floating point value or vector with all elements equal to the value.
Definition: PatternMatch.h:840
llvm::PatternMatch::is_any_apint::isValue
bool isValue(const APInt &C)
Definition: PatternMatch.h:432
llvm::CmpInst::Predicate
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition: InstrTypes.h:722
llvm::PatternMatch::AnyUnaryOp_match::X
OP_t X
Definition: PatternMatch.h:957
llvm::PatternMatch::Exact_match::match
bool match(OpTy *V)
Definition: PatternMatch.h:1349
IntrinsicInst.h
llvm::PatternMatch::ThreeOps_match
Matches instructions with Opcode and three operands.
Definition: PatternMatch.h:1446
llvm::PatternMatch::TwoOps_match::Op2
T1 Op2
Definition: PatternMatch.h:1431
llvm::PatternMatch::m_NegatedPower2
cst_pred_ty< is_negated_power2 > m_NegatedPower2()
Match a integer or vector negated power-of-2.
Definition: PatternMatch.h:556
llvm::PatternMatch::CmpClass_match::CmpClass_match
CmpClass_match(PredicateTy &Pred, const LHS_t &LHS, const RHS_t &RHS)
Definition: PatternMatch.h:1373
llvm::PatternMatch::ExtractValue_match::Val
Opnd_t Val
Definition: PatternMatch.h:2362
llvm::PatternMatch::match_unless::M
Ty M
Definition: PatternMatch.h:166
llvm::PatternMatch::match_combine_and::match_combine_and
match_combine_and(const LTy &Left, const RTy &Right)
Definition: PatternMatch.h:198
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::PatternMatch::m_NaN
cstfp_pred_ty< is_nan > m_NaN()
Match an arbitrary NaN constant.
Definition: PatternMatch.h:638
llvm::PatternMatch::undef_match::match
bool match(ITy *V)
Definition: PatternMatch.h:130
llvm::PatternMatch::m_LShr
BinaryOp_match< LHS, RHS, Instruction::LShr > m_LShr(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1142
llvm::PatternMatch::is_one::isValue
bool isValue(const APInt &C)
Definition: PatternMatch.h:509
llvm::PatternMatch::Shuffle_match::Mask
T2 Mask
Definition: PatternMatch.h:1505
llvm::PatternMatch::m_Mask::m_Mask
m_Mask(ArrayRef< int > &MaskRef)
Definition: PatternMatch.h:1521
llvm::PatternMatch::specificval_ty::specificval_ty
specificval_ty(const Value *V)
Definition: PatternMatch.h:796
llvm::PatternMatch::m_SplatOrUndefMask
Definition: PatternMatch.h:1540
llvm::PatternMatch::deferredval_ty
Stores a reference to the Value *, not the Value * itself, thus can be used in commutative matchers.
Definition: PatternMatch.h:806
llvm::PatternMatch::m_FPOne
specific_fpval m_FPOne()
Match a float 1.0 or vector with all elements equal to 1.0.
Definition: PatternMatch.h:843
llvm::PatternMatch::AnyBinaryOp_match
Definition: PatternMatch.h:930
llvm::PatternMatch::Shuffle_match::match
bool match(OpTy *V)
Definition: PatternMatch.h:1510
llvm::PatternMatch::m_InsertElt
ThreeOps_match< Val_t, Elt_t, Idx_t, Instruction::InsertElement > m_InsertElt(const Val_t &Val, const Elt_t &Elt, const Idx_t &Idx)
Matches InsertElementInst.
Definition: PatternMatch.h:1489
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
llvm::PatternMatch::undef_match
Definition: PatternMatch.h:91
llvm::PatternMatch::m_SpecificMask
Definition: PatternMatch.h:1534
llvm::PatternMatch::m_Freeze
OneOps_match< OpTy, Instruction::Freeze > m_Freeze(const OpTy &Op)
Matches FreezeInst.
Definition: PatternMatch.h:1482
llvm::PatternMatch::m_FRem
BinaryOp_match< LHS, RHS, Instruction::FRem > m_FRem(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1112
llvm::PatternMatch::m_Add
BinaryOp_match< LHS, RHS, Instruction::Add > m_Add(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1003
llvm::PatternMatch::m_MaxSignedValue
cst_pred_ty< is_maxsignedvalue > m_MaxSignedValue()
Match an integer or vector with values having all bits except for the high bit set (0x7f....
Definition: PatternMatch.h:455
llvm::MCID::Commutable
@ Commutable
Definition: MCInstrDesc.h:172
llvm::PatternMatch::specific_fpval::Val
double Val
Definition: PatternMatch.h:823
llvm::PatternMatch::m_Load
OneOps_match< OpTy, Instruction::Load > m_Load(const OpTy &Op)
Matches LoadInst.
Definition: PatternMatch.h:1568
llvm::PatternMatch::match_combine_or::R
RTy R
Definition: PatternMatch.h:181
llvm::PatternMatch::m_CombineOr
match_combine_or< LTy, RTy > m_CombineOr(const LTy &L, const RTy &R)
Combine two pattern matchers matching L || R.
Definition: PatternMatch.h:210
llvm::PatternMatch::ThreeOps_match::ThreeOps_match
ThreeOps_match(const T0 &Op1, const T1 &Op2, const T2 &Op3)
Definition: PatternMatch.h:1451
llvm::PatternMatch::br_match::br_match
br_match(BasicBlock *&Succ)
Definition: PatternMatch.h:1703
llvm::PatternMatch::m_SplatOrUndefMask::m_SplatOrUndefMask
m_SplatOrUndefMask(int &SplatIndex)
Definition: PatternMatch.h:1542
llvm::ConstantAggregate
Base class for aggregate constants (with operands).
Definition: Constants.h:383
llvm::PatternMatch::BinaryOp_match::L
LHS_t L
Definition: PatternMatch.h:979
llvm::PatternMatch::m_APFloat
apfloat_match m_APFloat(const APFloat *&Res)
Match a ConstantFP or splatted ConstantVector, binding the specified pointer to the contained APFloat...
Definition: PatternMatch.h:287
Right
Vector Shift Left Right
Definition: README_P9.txt:118
llvm::PatternMatch::m_Br
brc_match< Cond_t, bind_ty< BasicBlock >, bind_ty< BasicBlock > > m_Br(const Cond_t &C, BasicBlock *&T, BasicBlock *&F)
Definition: PatternMatch.h:1736
llvm::PatternMatch::m_BitReverse
m_Intrinsic_Ty< Opnd0 >::Ty m_BitReverse(const Opnd0 &Op0)
Definition: PatternMatch.h:2151
llvm::PatternMatch::CastClass_match
Definition: PatternMatch.h:1584
llvm::PatternMatch::is_right_shift_op
Definition: PatternMatch.h:1269
llvm::PatternMatch::MaxMin_match::match
bool match(OpTy *V)
Definition: PatternMatch.h:1762
llvm::PatternMatch::apf_pred_ty::apf_pred_ty
apf_pred_ty(const APFloat *&R)
Definition: PatternMatch.h:401
APInt.h
llvm::PatternMatch::OneOps_match::Op1
T0 Op1
Definition: PatternMatch.h:1415
llvm::PatternMatch::m_FCanonicalize
m_Intrinsic_Ty< Opnd0 >::Ty m_FCanonicalize(const Opnd0 &Op0)
Definition: PatternMatch.h:2166
llvm::PatternMatch::m_NegZeroFP
cstfp_pred_ty< is_neg_zero_fp > m_NegZeroFP()
Match a floating-point negative zero.
Definition: PatternMatch.h:714
llvm::PatternMatch::m_NUWShl
OverflowingBinaryOp_match< LHS, RHS, Instruction::Shl, OverflowingBinaryOperator::NoUnsignedWrap > m_NUWShl(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1238
llvm::CmpInst::ICMP_SGT
@ ICMP_SGT
signed greater than
Definition: InstrTypes.h:749
llvm::PatternMatch::MaxMin_match::L
LHS_t L
Definition: PatternMatch.h:1755
llvm::PatternMatch::specific_intval
Match a specified integer value or vector of all elements of that value.
Definition: PatternMatch.h:863
llvm::PatternMatch::smin_pred_ty::match
static bool match(ICmpInst::Predicate Pred)
Definition: PatternMatch.h:1810
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:46
llvm::PatternMatch::icmp_pred_with_threshold::Thr
const APInt * Thr
Definition: PatternMatch.h:595
llvm::PatternMatch::m_FPToUI
CastClass_match< OpTy, Instruction::FPToUI > m_FPToUI(const OpTy &Op)
Definition: PatternMatch.h:1677
llvm::PatternMatch::constantint_match::match
bool match(ITy *V)
Definition: PatternMatch.h:303
llvm::PatternMatch::m_UnordFMin
MaxMin_match< FCmpInst, LHS, RHS, ufmin_pred_ty > m_UnordFMin(const LHS &L, const RHS &R)
Match an 'unordered' floating point minimum function.
Definition: PatternMatch.h:1948
llvm::Instruction::isShift
bool isShift() const
Definition: Instruction.h:167
llvm::PatternMatch::OneOps_match
Matches instructions with Opcode and three operands.
Definition: PatternMatch.h:1414
llvm::PatternMatch::is_maxsignedvalue
Definition: PatternMatch.h:449
llvm::PatternMatch::is_negative::isValue
bool isValue(const APInt &C)
Definition: PatternMatch.h:463
llvm::PatternMatch::BinOpPred_match::match
bool match(OpTy *V)
Definition: PatternMatch.h:1254
T1
#define T1
Definition: Mips16ISelLowering.cpp:340
llvm::PatternMatch::CastClass_match::CastClass_match
CastClass_match(const Op_t &OpMatch)
Definition: PatternMatch.h:1587
llvm::PatternMatch::m_ZExtOrSExtOrSelf
match_combine_or< match_combine_or< CastClass_match< OpTy, Instruction::ZExt >, CastClass_match< OpTy, Instruction::SExt > >, OpTy > m_ZExtOrSExtOrSelf(const OpTy &Op)
Definition: PatternMatch.h:1662
T
#define T
Definition: Mips16ISelLowering.cpp:341
llvm::PatternMatch::m_BinOp
class_match< BinaryOperator > m_BinOp()
Match an arbitrary binary operation and ignore it.
Definition: PatternMatch.h:84
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
llvm::SmallPtrSet
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:449
llvm::PatternMatch::TwoOps_match::match
bool match(OpTy *V)
Definition: PatternMatch.h:1435
llvm::PatternMatch::m_SplatOrUndefMask::match
bool match(ArrayRef< int > Mask)
Definition: PatternMatch.h:1543
llvm::PatternMatch::m_AShr
BinaryOp_match< LHS, RHS, Instruction::AShr > m_AShr(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1148
llvm::tgtok::FalseVal
@ FalseVal
Definition: TGLexer.h:61
llvm::PatternMatch::InsertValue_match
Matcher for a single index InsertValue instruction.
Definition: PatternMatch.h:2392
llvm::PatternMatch::m_SpecificBB
specific_bbval m_SpecificBB(BasicBlock *BB)
Match a specific basic block value.
Definition: PatternMatch.h:913
Operator.h
llvm::PatternMatch::m_Intrinsic_Ty< T0, T1, T2, T3 >::Ty
match_combine_and< typename m_Intrinsic_Ty< T0, T1, T2 >::Ty, Argument_match< T3 > > Ty
Definition: PatternMatch.h:2086
llvm::PatternMatch::is_negated_power2
Definition: PatternMatch.h:551
llvm::CmpInst::ICMP_SLE
@ ICMP_SLE
signed less or equal
Definition: InstrTypes.h:752
llvm::PatternMatch::IntrinsicID_match::IntrinsicID_match
IntrinsicID_match(Intrinsic::ID IntrID)
Definition: PatternMatch.h:2050
llvm::PatternMatch::OneOps_match::OneOps_match
OneOps_match(const T0 &Op1)
Definition: PatternMatch.h:1417
llvm::SmallVectorImpl::pop_back_val
LLVM_NODISCARD T pop_back_val()
Definition: SmallVector.h:635
llvm::PatternMatch::BinaryOp_match::BinaryOp_match
BinaryOp_match(const LHS_t &LHS, const RHS_t &RHS)
Definition: PatternMatch.h:984
llvm::PatternMatch::bind_const_intval_ty
Definition: PatternMatch.h:845
llvm::PatternMatch::m_c_And
BinaryOp_match< LHS, RHS, Instruction::And, true > m_c_And(const LHS &L, const RHS &R)
Matches an And with LHS and RHS in either order.
Definition: PatternMatch.h:2229
llvm::PatternMatch::m_Mask::match
bool match(ArrayRef< int > Mask)
Definition: PatternMatch.h:1522
llvm::UnaryOperator
Definition: InstrTypes.h:103
llvm::PatternMatch::m_Not
BinaryOp_match< ValTy, cst_pred_ty< is_all_ones >, Instruction::Xor, true > m_Not(const ValTy &V)
Matches a 'Not' as 'xor V, -1' or 'xor -1, V'.
Definition: PatternMatch.h:2267
llvm::PatternMatch::m_BitCast
CastClass_match< OpTy, Instruction::BitCast > m_BitCast(const OpTy &Op)
Matches BitCast.
Definition: PatternMatch.h:1598
llvm::PatternMatch::ThreeOps_match::Op1
T0 Op1
Definition: PatternMatch.h:1447
llvm::PatternMatch::VScaleVal_match::match
bool match(ITy *V)
Definition: PatternMatch.h:2430
llvm::PatternMatch::m_VScale
VScaleVal_match m_VScale(const DataLayout &DL)
Definition: PatternMatch.h:2446
llvm::CmpInst::FCMP_OGT
@ FCMP_OGT
0 0 1 0 True if ordered and greater than
Definition: InstrTypes.h:726
llvm::PatternMatch::bind_const_intval_ty::VR
uint64_t & VR
Definition: PatternMatch.h:846
llvm::BitmaskEnumDetail::Mask
std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
Definition: BitmaskEnum.h:80
llvm::PatternMatch::apfloat_match
Definition: PatternMatch.h:245
llvm::PatternMatch::m_Deferred
deferredval_ty< Value > m_Deferred(Value *const &V)
A commutative-friendly version of m_Specific().
Definition: PatternMatch.h:815
llvm::PatternMatch::m_ConstantFP
class_match< ConstantFP > m_ConstantFP()
Match an arbitrary ConstantFP and ignore it.
Definition: PatternMatch.h:150
llvm::APIntOps::umin
const APInt & umin(const APInt &A, const APInt &B)
Determine the smaller of two APInts considered to be signed.
Definition: APInt.h:2185
llvm::PatternMatch::m_FDiv
BinaryOp_match< LHS, RHS, Instruction::FDiv > m_FDiv(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1094
llvm::PatternMatch::ExtractValue_match::ExtractValue_match
ExtractValue_match(const Opnd_t &V)
Definition: PatternMatch.h:2363
llvm::PatternMatch::m_c_MaxOrMin
match_combine_or< match_combine_or< MaxMin_match< ICmpInst, LHS, RHS, smax_pred_ty, true >, MaxMin_match< ICmpInst, LHS, RHS, smin_pred_ty, true > >, match_combine_or< MaxMin_match< ICmpInst, LHS, RHS, umax_pred_ty, true >, MaxMin_match< ICmpInst, LHS, RHS, umin_pred_ty, true > > > m_c_MaxOrMin(const LHS &L, const RHS &R)
Definition: PatternMatch.h:2302
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::PatternMatch::m_FAdd
BinaryOp_match< LHS, RHS, Instruction::FAdd > m_FAdd(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1009
llvm::PatternMatch::umax_pred_ty::match
static bool match(ICmpInst::Predicate Pred)
Definition: PatternMatch.h:1817
llvm::PatternMatch::m_FSub
BinaryOp_match< LHS, RHS, Instruction::FSub > m_FSub(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1021
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:58
llvm::PatternMatch::m_Unless
match_unless< Ty > m_Unless(const Ty &M)
Match if the inner matcher does NOT match.
Definition: PatternMatch.h:174
llvm::PatternMatch::MaxMin_match::R
RHS_t R
Definition: PatternMatch.h:1756
llvm::PatternMatch::AnyUnaryOp_match
Definition: PatternMatch.h:956
llvm::PatternMatch::m_c_ICmp
CmpClass_match< LHS, RHS, ICmpInst, ICmpInst::Predicate, true > m_c_ICmp(ICmpInst::Predicate &Pred, const LHS &L, const RHS &R)
Matches an ICmp with a predicate over LHS and RHS in either order.
Definition: PatternMatch.h:2208
llvm::PatternMatch::is_power2_or_zero
Definition: PatternMatch.h:563
llvm::PatternMatch::m_OneUse
OneUse_match< T > m_OneUse(const T &SubPattern)
Definition: PatternMatch.h:67
llvm::DataLayout::getTypeAllocSizeInBits
TypeSize getTypeAllocSizeInBits(Type *Ty) const
Returns the offset in bits between successive objects of the specified type, including alignment padd...
Definition: DataLayout.h:511
llvm::CmpInst::FCMP_ULT
@ FCMP_ULT
1 1 0 0 True if unordered or less than
Definition: InstrTypes.h:736
llvm::PatternMatch::Signum_match::Val
Opnd_t Val
Definition: PatternMatch.h:2322
llvm::PatternMatch::cstval_pred_ty
This helper class is used to match constant scalars, vector splats, and fixed width vectors that sati...
Definition: PatternMatch.h:326
llvm::PatternMatch::match_combine_and
Definition: PatternMatch.h:194
llvm::AlignStyle::Left
@ Left
llvm::PatternMatch::is_strictlypositive
Definition: PatternMatch.h:486
Instruction.h
llvm::PatternMatch::m_APInt
apint_match m_APInt(const APInt *&Res)
Match a ConstantInt or splatted ConstantVector, binding the specified pointer to the contained APInt.
Definition: PatternMatch.h:270
llvm::PatternMatch::m_c_BinOp
AnyBinaryOp_match< LHS, RHS, true > m_c_BinOp(const LHS &L, const RHS &R)
Matches a BinaryOperator with LHS and RHS in either order.
Definition: PatternMatch.h:2200
llvm::PatternMatch::m_UMax
MaxMin_match< ICmpInst, LHS, RHS, umax_pred_ty > m_UMax(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1870
llvm::PatternMatch::m_OrdFMin
MaxMin_match< FCmpInst, LHS, RHS, ofmin_pred_ty > m_OrdFMin(const LHS &L, const RHS &R)
Match an 'ordered' floating point minimum function.
Definition: PatternMatch.h:1917
llvm::PatternMatch::is_maxsignedvalue::isValue
bool isValue(const APInt &C)
Definition: PatternMatch.h:450
llvm::PatternMatch::FNeg_match
Definition: PatternMatch.h:1026
llvm::ConstantInt
This is the shared class of boolean and integer constants.
Definition: Constants.h:77
llvm::all_of
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1505
llvm::PatternMatch::m_LowBitMask
cst_pred_ty< is_lowbit_mask > m_LowBitMask()
Match an integer or vector with only the low bit(s) set.
Definition: PatternMatch.h:589
llvm::PatternMatch::m_Intrinsic_Ty< T0, T1, T2 >::Ty
match_combine_and< typename m_Intrinsic_Ty< T0, T1 >::Ty, Argument_match< T2 > > Ty
Definition: PatternMatch.h:2080
llvm::PatternMatch::m_UIToFP
CastClass_match< OpTy, Instruction::UIToFP > m_UIToFP(const OpTy &Op)
Definition: PatternMatch.h:1667
llvm::PatternMatch::is_finite::isValue
bool isValue(const APFloat &C)
Definition: PatternMatch.h:670
llvm::PatternMatch::is_idiv_op::isOpType
bool isOpType(unsigned Opcode)
Definition: PatternMatch.h:1288
llvm::PatternMatch::m_Select
ThreeOps_match< Cond, LHS, RHS, Instruction::Select > m_Select(const Cond &C, const LHS &L, const RHS &R)
Matches SelectInst.
Definition: PatternMatch.h:1467
llvm::PatternMatch::AnyBinaryOp_match::AnyBinaryOp_match
AnyBinaryOp_match(const LHS_t &LHS, const RHS_t &RHS)
Definition: PatternMatch.h:936
llvm::PatternMatch::smax_pred_ty::match
static bool match(ICmpInst::Predicate Pred)
Definition: PatternMatch.h:1803
llvm::PatternMatch::smin_pred_ty
Helper class for identifying signed min predicates.
Definition: PatternMatch.h:1809
llvm::PatternMatch::m_ZExtOrSExt
match_combine_or< CastClass_match< OpTy, Instruction::ZExt >, CastClass_match< OpTy, Instruction::SExt > > m_ZExtOrSExt(const OpTy &Op)
Definition: PatternMatch.h:1653
Constants.h
llvm::PatternMatch::match
bool match(Val *V, const Pattern &P)
Definition: PatternMatch.h:49
llvm::PatternMatch::TwoOps_match
Matches instructions with Opcode and three operands.
Definition: PatternMatch.h:1429
llvm::PatternMatch::ufmax_pred_ty
Helper class for identifying unordered max predicates.
Definition: PatternMatch.h:1844
llvm::PatternMatch::is_lowbit_mask::isValue
bool isValue(const APInt &C)
Definition: PatternMatch.h:585
llvm::PatternMatch::Shuffle_match::Shuffle_match
Shuffle_match(const T0 &Op1, const T1 &Op2, const T2 &Mask)
Definition: PatternMatch.h:1507
llvm::PatternMatch::m_FShl
m_Intrinsic_Ty< Opnd0, Opnd1, Opnd2 >::Ty m_FShl(const Opnd0 &Op0, const Opnd1 &Op1, const Opnd2 &Op2)
Definition: PatternMatch.h:2184
llvm::PatternMatch::match_combine_and::R
RTy R
Definition: PatternMatch.h:196
f
Itanium Name Demangler i e convert the string _Z1fv into f()". You can also use the CRTP base ManglingParser to perform some simple analysis on the mangled name
llvm::PatternMatch::specific_bbval
Match a specified basic block value.
Definition: PatternMatch.h:901
llvm::PatternMatch::specific_bbval::match
bool match(ITy *V)
Definition: PatternMatch.h:906
llvm::PatternMatch::m_Exact
Exact_match< T > m_Exact(const T &SubPattern)
Definition: PatternMatch.h:1356
llvm::PatternMatch::AnyUnaryOp_match::AnyUnaryOp_match
AnyUnaryOp_match(const OP_t &X)
Definition: PatternMatch.h:959
llvm::PatternMatch::m_UnOp
class_match< UnaryOperator > m_UnOp()
Match an arbitrary unary operation and ignore it.
Definition: PatternMatch.h:79
llvm::PatternMatch::m_SpecificIntAllowUndef
specific_intval< true > m_SpecificIntAllowUndef(APInt V)
Definition: PatternMatch.h:888
Intrinsics.h
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::CmpInst::ICMP_ULE
@ ICMP_ULE
unsigned less or equal
Definition: InstrTypes.h:748
InstrTypes.h
llvm::PatternMatch::apfloat_match::apfloat_match
apfloat_match(const APFloat *&Res, bool AllowUndef)
Definition: PatternMatch.h:249
llvm::PatternMatch::Exact_match
Definition: PatternMatch.h:1344
llvm::PatternMatch::CastClass_match::match
bool match(OpTy *V)
Definition: PatternMatch.h:1589
llvm::PatternMatch::match_combine_or
Matching combinators.
Definition: PatternMatch.h:179
llvm::PatternMatch::BinaryOp_match::R
RHS_t R
Definition: PatternMatch.h:980
llvm::PatternMatch::m_PosZeroFP
cstfp_pred_ty< is_pos_zero_fp > m_PosZeroFP()
Match a floating-point positive zero.
Definition: PatternMatch.h:705
llvm::PatternMatch::m_NonNaN
cstfp_pred_ty< is_nonnan > m_NonNaN()
Match a non-NaN FP constant.
Definition: PatternMatch.h:647
SI
@ SI
Definition: SIInstrInfo.cpp:7344
llvm::PatternMatch::is_lowbit_mask
Definition: PatternMatch.h:584
llvm::CmpInst::FCMP_UGE
@ FCMP_UGE
1 0 1 1 True if unordered, greater than, or equal
Definition: InstrTypes.h:735
t
bitcast float %x to i32 %s=and i32 %t, 2147483647 %d=bitcast i32 %s to float ret float %d } declare float @fabsf(float %n) define float @bar(float %x) nounwind { %d=call float @fabsf(float %x) ret float %d } This IR(from PR6194):target datalayout="e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" target triple="x86_64-apple-darwin10.0.0" %0=type { double, double } %struct.float3=type { float, float, float } define void @test(%0, %struct.float3 *nocapture %res) nounwind noinline ssp { entry:%tmp18=extractvalue %0 %0, 0 t
Definition: README-SSE.txt:788
llvm::PatternMatch::deferredval_ty::Val
Class *const & Val
Definition: PatternMatch.h:807
llvm::PatternMatch::is_bitwiselogic_op
Definition: PatternMatch.h:1281
llvm::X86II::T8
@ T8
Definition: X86BaseInfo.h:803
UINT64_MAX
#define UINT64_MAX
Definition: DataTypes.h:77
llvm::PatternMatch::m_Instruction
bind_ty< Instruction > m_Instruction(Instruction *&I)
Match an instruction, capturing it if we match.
Definition: PatternMatch.h:748
llvm::PatternMatch::AnyBinaryOp_match::L
LHS_t L
Definition: PatternMatch.h:931
llvm::PatternMatch::class_match
Definition: PatternMatch.h:71
llvm::PatternMatch::bind_ty::bind_ty
bind_ty(Class *&V)
Definition: PatternMatch.h:732
llvm::PatternMatch::m_ZExt
CastClass_match< OpTy, Instruction::ZExt > m_ZExt(const OpTy &Op)
Matches ZExt.
Definition: PatternMatch.h:1634
llvm::PatternMatch::m_c_Add
BinaryOp_match< LHS, RHS, Instruction::Add, true > m_c_Add(const LHS &L, const RHS &R)
Matches a Add with LHS and RHS in either order.
Definition: PatternMatch.h:2215
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
First
into llvm powi allowing the code generator to produce balanced multiplication trees First
Definition: README.txt:54
llvm::PatternMatch::is_negated_power2::isValue
bool isValue(const APInt &C)
Definition: PatternMatch.h:552
llvm::PatternMatch::CmpClass_match::Predicate
PredicateTy & Predicate
Definition: PatternMatch.h:1367
llvm::PatternMatch::m_MaxOrMin
match_combine_or< match_combine_or< MaxMin_match< ICmpInst, LHS, RHS, smax_pred_ty >, MaxMin_match< ICmpInst, LHS, RHS, smin_pred_ty > >, match_combine_or< MaxMin_match< ICmpInst, LHS, RHS, umax_pred_ty >, MaxMin_match< ICmpInst, LHS, RHS, umin_pred_ty > > > m_MaxOrMin(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1887
llvm::PatternMatch::m_FNeg
FNeg_match< OpTy > m_FNeg(const OpTy &X)
Match 'fneg X' as 'fsub -0.0, X'.
Definition: PatternMatch.h:1058
llvm::PatternMatch::ufmin_pred_ty
Helper class for identifying unordered min predicates.
Definition: PatternMatch.h:1851
llvm::PatternMatch::deferredval_ty::deferredval_ty
deferredval_ty(Class *const &V)
Definition: PatternMatch.h:809
llvm::PatternMatch::m_SDiv
BinaryOp_match< LHS, RHS, Instruction::SDiv > m_SDiv(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1088
llvm::PatternMatch::m_ConstantInt
class_match< ConstantInt > m_ConstantInt()
Match an arbitrary ConstantInt and ignore it.
Definition: PatternMatch.h:145
llvm::PatternMatch::is_idiv_op
Definition: PatternMatch.h:1287
llvm::Instruction
Definition: Instruction.h:45
llvm::PatternMatch::m_IDiv
BinOpPred_match< LHS, RHS, is_idiv_op > m_IDiv(const LHS &L, const RHS &R)
Matches integer division operations.
Definition: PatternMatch.h:1329
llvm::PatternMatch::m_NSWMul
OverflowingBinaryOp_match< LHS, RHS, Instruction::Mul, OverflowingBinaryOperator::NoSignedWrap > m_NSWMul(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1197
llvm::PatternMatch::icmp_pred_with_threshold::Pred
ICmpInst::Predicate Pred
Definition: PatternMatch.h:594
llvm::PatternMatch::m_UMin
MaxMin_match< ICmpInst, LHS, RHS, umin_pred_ty > m_UMin(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1876
llvm::PatternMatch::m_c_Or
BinaryOp_match< LHS, RHS, Instruction::Or, true > m_c_Or(const LHS &L, const RHS &R)
Matches an Or with LHS and RHS in either order.
Definition: PatternMatch.h:2236
llvm::PatternMatch::UAddWithOverflow_match::R
RHS_t R
Definition: PatternMatch.h:1960
llvm::PatternMatch::br_match::match
bool match(OpTy *V)
Definition: PatternMatch.h:1705
llvm::ConstantFP
ConstantFP - Floating Point Values [float, double].
Definition: Constants.h:255
APFloat.h
This file declares a class to represent arbitrary precision floating point values and provide a varie...
llvm::PatternMatch::brc_match::Cond
Cond_t Cond
Definition: PatternMatch.h:1719
llvm::PatternMatch::m_NSWSub
OverflowingBinaryOp_match< LHS, RHS, Instruction::Sub, OverflowingBinaryOperator::NoSignedWrap > m_NSWSub(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1189
llvm::PatternMatch::apint_match
Definition: PatternMatch.h:220
llvm::PatternMatch::CmpClass_match::R
RHS_t R
Definition: PatternMatch.h:1369
llvm::PatternMatch::apint_match::match
bool match(ITy *V)
Definition: PatternMatch.h:227
llvm::PatternMatch::BinOpPred_match::R
RHS_t R
Definition: PatternMatch.h:1250
llvm::PatternMatch::m_UnordFMax
MaxMin_match< FCmpInst, LHS, RHS, ufmax_pred_ty > m_UnordFMax(const LHS &L, const RHS &R)
Match an 'unordered' floating point maximum function.
Definition: PatternMatch.h:1933
llvm::PatternMatch::is_pos_zero_fp::isValue
bool isValue(const APFloat &C)
Definition: PatternMatch.h:701
llvm::CmpInst::FCMP_OLT
@ FCMP_OLT
0 1 0 0 True if ordered and less than
Definition: InstrTypes.h:728
llvm::PatternMatch::m_NonPositive
cst_pred_ty< is_nonpositive > m_NonPositive()
Match an integer or vector of non-positive values.
Definition: PatternMatch.h:503
llvm::PatternMatch::m_URem
BinaryOp_match< LHS, RHS, Instruction::URem > m_URem(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1100
llvm::PatternMatch::OneUse_match::match
bool match(OpTy *V)
Definition: PatternMatch.h:62
llvm::PatternMatch::is_right_shift_op::isOpType
bool isOpType(unsigned Opcode)
Definition: PatternMatch.h:1270
llvm::PatternMatch::apfloat_match::AllowUndef
bool AllowUndef
Definition: PatternMatch.h:247
llvm::PatternMatch::m_APIntAllowUndef
apint_match m_APIntAllowUndef(const APInt *&Res)
Match APInt while allowing undefs in splat vector constants.
Definition: PatternMatch.h:276
llvm::PatternMatch::VScaleVal_match
Matches patterns for vscale.
Definition: PatternMatch.h:2418
llvm::PatternMatch::specificval_ty
Match a specified Value*.
Definition: PatternMatch.h:793
llvm::PatternMatch::is_inf
Definition: PatternMatch.h:651
llvm::PatternMatch::m_Shift
BinOpPred_match< LHS, RHS, is_shift_op > m_Shift(const LHS &L, const RHS &R)
Matches shift operations.
Definition: PatternMatch.h:1301
llvm::PatternMatch::is_sign_mask::isValue
bool isValue(const APInt &C)
Definition: PatternMatch.h:576
llvm::PatternMatch::Argument_match::Val
Opnd_t Val
Definition: PatternMatch.h:2028
llvm::PatternMatch::is_zero
Definition: PatternMatch.h:526
llvm::PatternMatch::m_c_UMax
MaxMin_match< ICmpInst, LHS, RHS, umax_pred_ty, true > m_c_UMax(const LHS &L, const RHS &R)
Matches a UMax with LHS and RHS in either order.
Definition: PatternMatch.h:2292
X
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
llvm::PatternMatch::m_One
cst_pred_ty< is_one > m_One()
Match an integer 1 or a vector with all elements equal to 1.
Definition: PatternMatch.h:513
llvm::PatternMatch::is_logical_shift_op
Definition: PatternMatch.h:1275
llvm::PatternMatch::Shuffle_match::Op1
T0 Op1
Definition: PatternMatch.h:1503
llvm::PatternMatch::bind_ty::match
bool match(ITy *V)
Definition: PatternMatch.h:734
llvm::PatternMatch::FNeg_match::FNeg_match
FNeg_match(const Op_t &Op)
Definition: PatternMatch.h:1029
llvm::PatternMatch::m_ExtractElt
TwoOps_match< Val_t, Idx_t, Instruction::ExtractElement > m_ExtractElt(const Val_t &Val, const Idx_t &Idx)
Matches ExtractElementInst.
Definition: PatternMatch.h:1497
llvm::PatternMatch::m_NSWAdd
OverflowingBinaryOp_match< LHS, RHS, Instruction::Add, OverflowingBinaryOperator::NoSignedWrap > m_NSWAdd(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1181
llvm::PatternMatch::ufmin_pred_ty::match
static bool match(FCmpInst::Predicate Pred)
Definition: PatternMatch.h:1852
llvm::PatternMatch::m_Power2
cst_pred_ty< is_power2 > m_Power2()
Match an integer or vector power-of-2.
Definition: PatternMatch.h:544
llvm::PatternMatch::m_Xor
BinaryOp_match< LHS, RHS, Instruction::Xor > m_Xor(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1130
llvm::PatternMatch::m_Shr
BinOpPred_match< LHS, RHS, is_right_shift_op > m_Shr(const LHS &L, const RHS &R)
Matches logical shift operations.
Definition: PatternMatch.h:1308
llvm::PatternMatch::api_pred_ty::api_pred_ty
api_pred_ty(const APInt *&R)
Definition: PatternMatch.h:375
llvm::PatternMatch::m_FMax
m_Intrinsic_Ty< Opnd0, Opnd1 >::Ty m_FMax(const Opnd0 &Op0, const Opnd1 &Op1)
Definition: PatternMatch.h:2177
llvm::PatternMatch::OverflowingBinaryOp_match::R
RHS_t R
Definition: PatternMatch.h:1157
llvm::PatternMatch::m_FPTrunc
CastClass_match< OpTy, Instruction::FPTrunc > m_FPTrunc(const OpTy &Op)
Definition: PatternMatch.h:1687
llvm::PatternMatch::m_ZExtOrSelf
match_combine_or< CastClass_match< OpTy, Instruction::ZExt >, OpTy > m_ZExtOrSelf(const OpTy &Op)
Definition: PatternMatch.h:1640
llvm::PatternMatch::ExtractValue_match
Definition: PatternMatch.h:2361
llvm::PatternMatch::m_Intrinsic_Ty< T0, T1, T2, T3, T4 >::Ty
match_combine_and< typename m_Intrinsic_Ty< T0, T1, T2, T3 >::Ty, Argument_match< T4 > > Ty
Definition: PatternMatch.h:2092
llvm::PatternMatch::is_nonpositive
Definition: PatternMatch.h:498
llvm::APFloat
Definition: APFloat.h:701
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:128
llvm::PPC::Predicate
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
Definition: PPCPredicates.h:26
llvm::PatternMatch::TwoOps_match::TwoOps_match
TwoOps_match(const T0 &Op1, const T1 &Op2)
Definition: PatternMatch.h:1433
llvm::PatternMatch::m_Zero
is_zero m_Zero()
Match any null constant or a vector with all elements equal to 0.
Definition: PatternMatch.h:535
llvm::PatternMatch::m_NUWAdd
OverflowingBinaryOp_match< LHS, RHS, Instruction::Add, OverflowingBinaryOperator::NoUnsignedWrap > m_NUWAdd(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1214
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::PatternMatch::is_power2
Definition: PatternMatch.h:539
llvm::PatternMatch::match_combine_or::L
LTy L
Definition: PatternMatch.h:180
llvm::PatternMatch::m_UnconditionalBr
br_match m_UnconditionalBr(BasicBlock *&Succ)
Definition: PatternMatch.h:1715
llvm::PatternMatch::m_ImmConstant
match_combine_and< class_match< Constant >, match_unless< class_match< ConstantExpr > > > m_ImmConstant()
Match an arbitrary immediate Constant and ignore it.
Definition: PatternMatch.h:781
llvm::PatternMatch::apf_pred_ty
This helper class is used to match scalar and vector constants that satisfy a specified predicate,...
Definition: PatternMatch.h:398
llvm::PatternMatch::smax_pred_ty
Helper class for identifying signed max predicates.
Definition: PatternMatch.h:1802
llvm::PatternMatch::m_LogicalOr
LogicalOp_match< LHS, RHS, Instruction::Or > m_LogicalOr(const LHS &L, const RHS &R)
Matches L || R either in the form of L | R or L ? true : R.
Definition: PatternMatch.h:2501
llvm::PatternMatch::m_Inf
cstfp_pred_ty< is_inf > m_Inf()
Match a positive or negative infinity FP constant.
Definition: PatternMatch.h:656
llvm::PatternMatch::is_finitenonzero
Definition: PatternMatch.h:679
llvm::PatternMatch::is_non_zero_fp
Definition: PatternMatch.h:718
llvm::PatternMatch::m_SpecificMask::match
bool match(ArrayRef< int > Mask)
Definition: PatternMatch.h:1537
llvm::PatternMatch::bind_const_intval_ty::match
bool match(ITy *V)
Definition: PatternMatch.h:850
llvm::PatternMatch::specific_intval::specific_intval
specific_intval(APInt V)
Definition: PatternMatch.h:866
llvm::PatternMatch::match_combine_and::L
LTy L
Definition: PatternMatch.h:195
llvm::PatternMatch::IntrinsicID_match::ID
unsigned ID
Definition: PatternMatch.h:2048
llvm::PatternMatch::Argument_match::Argument_match
Argument_match(unsigned OpIdx, const Opnd_t &V)
Definition: PatternMatch.h:2030
llvm::PatternMatch::m_Or
BinaryOp_match< LHS, RHS, Instruction::Or > m_Or(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1124
llvm::PatternMatch::m_AllOnes
cst_pred_ty< is_all_ones > m_AllOnes()
Match an integer or vector with all bits set.
Definition: PatternMatch.h:445
llvm::PatternMatch::m_NonInf
cstfp_pred_ty< is_noninf > m_NonInf()
Match a non-infinity FP constant, i.e.
Definition: PatternMatch.h:665
llvm::PatternMatch::UAddWithOverflow_match::S
Sum_t S
Definition: PatternMatch.h:1961
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::PatternMatch::icmp_pred_with_threshold
Definition: PatternMatch.h:593
llvm::PatternMatch::InsertValue_match::Op0
T0 Op0
Definition: PatternMatch.h:2393
llvm::PatternMatch::m_Store
TwoOps_match< ValueOpTy, PointerOpTy, Instruction::Store > m_Store(const ValueOpTy &ValueOp, const PointerOpTy &PointerOp)
Matches StoreInst.
Definition: PatternMatch.h:1575
llvm::PatternMatch::UAddWithOverflow_match
Definition: PatternMatch.h:1958
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::PatternMatch::is_all_ones
Definition: PatternMatch.h:440
llvm::PatternMatch::LogicalOp_match::LogicalOp_match
LogicalOp_match(const LHS &L, const RHS &R)
Definition: PatternMatch.h:2455
llvm::PatternMatch::m_FAbs
m_Intrinsic_Ty< Opnd0 >::Ty m_FAbs(const Opnd0 &Op0)
Definition: PatternMatch.h:2161
llvm::PatternMatch::m_And
BinaryOp_match< LHS, RHS, Instruction::And > m_And(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1118
llvm::PatternMatch::specific_bbval::Val
BasicBlock * Val
Definition: PatternMatch.h:902
llvm::PatternMatch::MaxMin_match::PredType
Pred_t PredType
Definition: PatternMatch.h:1754
llvm::PatternMatch::m_SRem
BinaryOp_match< LHS, RHS, Instruction::SRem > m_SRem(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1106
llvm::PatternMatch::AnyBinaryOp_match::R
RHS_t R
Definition: PatternMatch.h:932
llvm::PatternMatch::is_one
Definition: PatternMatch.h:508
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::PatternMatch::OverflowingBinaryOp_match::match
bool match(OpTy *V)
Definition: PatternMatch.h:1162
llvm::move
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:1563
llvm::PatternMatch::OneUse_match::OneUse_match
OneUse_match(const SubPattern_t &SP)
Definition: PatternMatch.h:60
llvm::PatternMatch::m_Sub
BinaryOp_match< LHS, RHS, Instruction::Sub > m_Sub(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1015
llvm::PatternMatch::MaxMin_match::MaxMin_match
MaxMin_match(const LHS_t &LHS, const RHS_t &RHS)
Definition: PatternMatch.h:1760
llvm::PatternMatch::OneOps_match::match
bool match(OpTy *V)
Definition: PatternMatch.h:1419
llvm::CmpInst::FCMP_OGE
@ FCMP_OGE
0 0 1 1 True if ordered and greater than or equal
Definition: InstrTypes.h:727
llvm::PatternMatch::is_inf::isValue
bool isValue(const APFloat &C)
Definition: PatternMatch.h:652
llvm::PatternMatch::BinaryOp_match::match
bool match(OpTy *V)
Definition: PatternMatch.h:986
llvm::PatternMatch::UAddWithOverflow_match::L
LHS_t L
Definition: PatternMatch.h:1959
llvm::PatternMatch::Shuffle_match::Op2
T1 Op2
Definition: PatternMatch.h:1504
llvm::PatternMatch::umin_pred_ty
Helper class for identifying unsigned min predicates.
Definition: PatternMatch.h:1823
llvm::PatternMatch::Shuffle_match
Matches shuffle.
Definition: PatternMatch.h:1502
llvm::CmpInst::ICMP_UGE
@ ICMP_UGE
unsigned greater or equal
Definition: InstrTypes.h:746
llvm::PatternMatch::brc_match
Definition: PatternMatch.h:1718
llvm::PatternMatch::m_ZeroMask
Definition: PatternMatch.h:1528
llvm::PatternMatch::specificval_ty::Val
const Value * Val
Definition: PatternMatch.h:794
llvm::PatternMatch::m_WithOverflowInst
bind_ty< WithOverflowInst > m_WithOverflowInst(WithOverflowInst *&I)
Match a with overflow intrinsic, capturing it if we match.
Definition: PatternMatch.h:754
llvm::PatternMatch::m_SMin
MaxMin_match< ICmpInst, LHS, RHS, smin_pred_ty > m_SMin(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1864
llvm::PatternMatch::bind_ty::VR
Class *& VR
Definition: PatternMatch.h:730
llvm::PatternMatch::m_Negative
cst_pred_ty< is_negative > m_Negative()
Match an integer or vector of negative values.
Definition: PatternMatch.h:467
llvm::PatternMatch::specific_fpval::match
bool match(ITy *V)
Definition: PatternMatch.h:827
llvm::PatternMatch::is_finite
Definition: PatternMatch.h:669
llvm::PatternMatch::m_Constant
class_match< Constant > m_Constant()
Match an arbitrary Constant and ignore it.
Definition: PatternMatch.h:142
llvm::PatternMatch::is_nonnegative::isValue
bool isValue(const APInt &C)
Definition: PatternMatch.h:475
llvm::PatternMatch::apf_pred_ty::Res
const APFloat *& Res
Definition: PatternMatch.h:399
llvm::PatternMatch::LogicalOp_match::R
RHS R
Definition: PatternMatch.h:2453
llvm::PatternMatch::AnyUnaryOp_match::match
bool match(OpTy *V)
Definition: PatternMatch.h:961
llvm::PatternMatch::m_Value
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
Definition: PatternMatch.h:76
llvm::APInt
Class for arbitrary precision integers.
Definition: APInt.h:70
llvm::CmpInst::ICMP_SLT
@ ICMP_SLT
signed less than
Definition: InstrTypes.h:751
llvm::APIntOps::smin
const APInt & smin(const APInt &A, const APInt &B)
Determine the smaller of two APInts considered to be signed.
Definition: APInt.h:2175
llvm::PatternMatch::m_SExt
CastClass_match< OpTy, Instruction::SExt > m_SExt(const OpTy &Op)
Matches SExt.
Definition: PatternMatch.h:1628
llvm::PatternMatch::is_nan
Definition: PatternMatch.h:633
llvm::PatternMatch::specific_fpval
Match a specified floating point value or vector of all elements of that value.
Definition: PatternMatch.h:822
llvm::PatternMatch::LogicalOp_match
Definition: PatternMatch.h:2451
llvm::PatternMatch::m_SpecificMask::m_SpecificMask
m_SpecificMask(ArrayRef< int > &MaskRef)
Definition: PatternMatch.h:1536
llvm::PatternMatch::FNeg_match::match
bool match(OpTy *V)
Definition: PatternMatch.h:1030
llvm::PatternMatch::m_SpecificInt
specific_intval< false > m_SpecificInt(APInt V)
Match a specific integer value or vector with all elements equal to the value.
Definition: PatternMatch.h:880
llvm::PatternMatch::m_CombineAnd
match_combine_and< LTy, RTy > m_CombineAnd(const LTy &L, const RTy &R)
Combine two pattern matchers matching L && R.
Definition: PatternMatch.h:216
llvm::PatternMatch::m_NUWMul
OverflowingBinaryOp_match< LHS, RHS, Instruction::Mul, OverflowingBinaryOperator::NoUnsignedWrap > m_NUWMul(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1230
llvm::ArrayRef< int >
llvm::PatternMatch::FNeg_match::X
Op_t X
Definition: PatternMatch.h:1027
llvm::BinaryOperator
Definition: InstrTypes.h:190
llvm::PatternMatch::is_nonnan::isValue
bool isValue(const APFloat &C)
Definition: PatternMatch.h:643
llvm::PatternMatch::VScaleVal_match::DL
const DataLayout & DL
Definition: PatternMatch.h:2427
llvm::PatternMatch::is_noninf
Definition: PatternMatch.h:660
DataLayout.h
llvm::PatternMatch::m_SpecificInt_ICMP
cst_pred_ty< icmp_pred_with_threshold > m_SpecificInt_ICMP(ICmpInst::Predicate Predicate, const APInt &Threshold)
Match an integer or vector with every element comparing 'pred' (eg/ne/...) to Threshold.
Definition: PatternMatch.h:626
llvm::PatternMatch::match
bool match(ArrayRef< int > Mask, const Pattern &P)
Definition: PatternMatch.h:53
Cond
SmallVector< MachineOperand, 4 > Cond
Definition: BasicBlockSections.cpp:167
llvm::PatternMatch::ThreeOps_match::match
bool match(OpTy *V)
Definition: PatternMatch.h:1454
llvm::PatternMatch::m_Undef
auto m_Undef()
Match an arbitrary undef constant.
Definition: PatternMatch.h:136
llvm::CmpInst::ICMP_ULT
@ ICMP_ULT
unsigned less than
Definition: InstrTypes.h:747
llvm::PatternMatch::brc_match::T
TrueBlock_t T
Definition: PatternMatch.h:1720
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
llvm::Constant::getAggregateElement
Constant * getAggregateElement(unsigned Elt) const
For aggregates (struct/array/vector) return the constant that corresponds to the specified element if...
Definition: Constants.cpp:421
llvm::PatternMatch::ThreeOps_match::Op2
T1 Op2
Definition: PatternMatch.h:1448
llvm::PatternMatch::is_sign_mask
Definition: PatternMatch.h:575
llvm::PatternMatch::m_Shuffle
TwoOps_match< V1_t, V2_t, Instruction::ShuffleVector > m_Shuffle(const V1_t &v1, const V2_t &v2)
Matches ShuffleVectorInst independently of mask value.
Definition: PatternMatch.h:1556
llvm::PatternMatch::Exact_match::SubPattern
SubPattern_t SubPattern
Definition: PatternMatch.h:1345
llvm::PatternMatch::m_FiniteNonZero
cstfp_pred_ty< is_finitenonzero > m_FiniteNonZero()
Match a finite non-zero FP constant.
Definition: PatternMatch.h:684
llvm::PatternMatch::m_NonZeroFP
cstfp_pred_ty< is_non_zero_fp > m_NonZeroFP()
Match a floating-point non-zero.
Definition: PatternMatch.h:723
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::PatternMatch::is_irem_op
Definition: PatternMatch.h:1293
llvm::PatternMatch::icmp_pred_with_threshold::isValue
bool isValue(const APInt &C)
Definition: PatternMatch.h:596
llvm::OverflowingBinaryOperator::NoUnsignedWrap
@ NoUnsignedWrap
Definition: Operator.h:70
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::PatternMatch::m_Argument
Argument_match< Opnd_t > m_Argument(const Opnd_t &Op)
Match an argument.
Definition: PatternMatch.h:2042
v2
llvm lib Support Unix the directory structure underneath this directory could look like only those directories actually needing to be created should be created further subdirectories could be created to reflect versions of the various standards For under SUS there could be v2
Definition: README.txt:15
llvm::PatternMatch::apint_match::Res
const APInt *& Res
Definition: PatternMatch.h:221
llvm::WithOverflowInst
Represents an op.with.overflow intrinsic.
Definition: IntrinsicInst.h:541
llvm::PatternMatch::Argument_match::match
bool match(OpTy *V)
Definition: PatternMatch.h:2032
llvm::PatternMatch::is_irem_op::isOpType
bool isOpType(unsigned Opcode)
Definition: PatternMatch.h:1294
llvm::PatternMatch::match_combine_or::match
bool match(ITy *V)
Definition: PatternMatch.h:185
llvm::PatternMatch::m_IRem
BinOpPred_match< LHS, RHS, is_irem_op > m_IRem(const LHS &L, const RHS &R)
Matches integer remainder operations.
Definition: PatternMatch.h:1336
llvm::PatternMatch::m_SMax
MaxMin_match< ICmpInst, LHS, RHS, smax_pred_ty > m_SMax(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1858
llvm::PatternMatch::UAddWithOverflow_match::UAddWithOverflow_match
UAddWithOverflow_match(const LHS_t &L, const RHS_t &R, const Sum_t &S)
Definition: PatternMatch.h:1963
llvm::PatternMatch::VScaleVal_match::VScaleVal_match
VScaleVal_match(const DataLayout &DL)
Definition: PatternMatch.h:2428
llvm::PatternMatch::m_Poison
class_match< PoisonValue > m_Poison()
Match an arbitrary poison constant.
Definition: PatternMatch.h:139
llvm::PatternMatch::is_power2::isValue
bool isValue(const APInt &C)
Definition: PatternMatch.h:540
llvm::PatternMatch::m_SpecificMask::MaskRef
ArrayRef< int > & MaskRef
Definition: PatternMatch.h:1535
llvm::PatternMatch::m_OrdFMax
MaxMin_match< FCmpInst, LHS, RHS, ofmax_pred_ty > m_OrdFMax(const LHS &L, const RHS &R)
Match an 'ordered' floating point maximum function.
Definition: PatternMatch.h:1902
llvm::PatternMatch::constantint_match
Definition: PatternMatch.h:302
llvm::PatternMatch::deferredval_ty::match
bool match(ITy *const V)
Definition: PatternMatch.h:811
llvm::find_if
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:1532
llvm::PatternMatch::m_c_SMax
MaxMin_match< ICmpInst, LHS, RHS, smax_pred_ty, true > m_c_SMax(const LHS &L, const RHS &R)
Matches an SMax with LHS and RHS in either order.
Definition: PatternMatch.h:2280
llvm::PatternMatch::is_negative
Definition: PatternMatch.h:462
llvm::PatternMatch::m_StrictlyPositive
cst_pred_ty< is_strictlypositive > m_StrictlyPositive()
Match an integer or vector of strictly positive values.
Definition: PatternMatch.h:491
llvm::PatternMatch::m_FMin
m_Intrinsic_Ty< Opnd0, Opnd1 >::Ty m_FMin(const Opnd0 &Op0, const Opnd1 &Op1)
Definition: PatternMatch.h:2171
llvm::MCID::Select
@ Select
Definition: MCInstrDesc.h:163
llvm::PatternMatch::InsertValue_match::Op1
T1 Op1
Definition: PatternMatch.h:2394
llvm::PatternMatch::m_BitwiseLogic
BinOpPred_match< LHS, RHS, is_bitwiselogic_op > m_BitwiseLogic(const LHS &L, const RHS &R)
Matches bitwise logic operations.
Definition: PatternMatch.h:1323
llvm::PatternMatch::m_FPExt
CastClass_match< OpTy, Instruction::FPExt > m_FPExt(const OpTy &Op)
Definition: PatternMatch.h:1692
llvm::APIntOps::umax
const APInt & umax(const APInt &A, const APInt &B)
Determine the larger of two APInts considered to be unsigned.
Definition: APInt.h:2190
llvm::CmpInst::FCMP_UGT
@ FCMP_UGT
1 0 1 0 True if unordered or greater than
Definition: InstrTypes.h:734
llvm::PatternMatch::IntrinsicID_match::match
bool match(OpTy *V)
Definition: PatternMatch.h:2052
Constant.h
llvm::PatternMatch::m_SExtOrSelf
match_combine_or< CastClass_match< OpTy, Instruction::SExt >, OpTy > m_SExtOrSelf(const OpTy &Op)
Definition: PatternMatch.h:1646
llvm::PatternMatch::InsertValue_match::InsertValue_match
InsertValue_match(const T0 &Op0, const T1 &Op1)
Definition: PatternMatch.h:2396
llvm::ConstantExpr
A constant value that is initialized with an expression using other constant values.
Definition: Constants.h:931
llvm::PatternMatch::is_bitwiselogic_op::isOpType
bool isOpType(unsigned Opcode)
Definition: PatternMatch.h:1282
llvm::PatternMatch::is_noninf::isValue
bool isValue(const APFloat &C)
Definition: PatternMatch.h:661
std
Definition: BitVector.h:838
llvm::PatternMatch::m_UDiv
BinaryOp_match< LHS, RHS, Instruction::UDiv > m_UDiv(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1082
llvm::PatternMatch::is_all_ones::isValue
bool isValue(const APInt &C)
Definition: PatternMatch.h:441
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:314
v1
llvm lib Support Unix the directory structure underneath this directory could look like only those directories actually needing to be created should be created further subdirectories could be created to reflect versions of the various standards For under SUS there could be v1
Definition: README.txt:15
llvm::PatternMatch::BinOpPred_match
Definition: PatternMatch.h:1248
llvm::PatternMatch::m_FPToSI
CastClass_match< OpTy, Instruction::FPToSI > m_FPToSI(const OpTy &Op)
Definition: PatternMatch.h:1682
llvm::PatternMatch::m_c_SMin
MaxMin_match< ICmpInst, LHS, RHS, smin_pred_ty, true > m_c_SMin(const LHS &L, const RHS &R)
Matches an SMin with LHS and RHS in either order.
Definition: PatternMatch.h:2274
llvm::PatternMatch::m_ZeroMask::match
bool match(ArrayRef< int > Mask)
Definition: PatternMatch.h:1529
llvm::TypeSize
Definition: TypeSize.h:417
llvm::PatternMatch::undef_match::check
static bool check(const Value *V)
Definition: PatternMatch.h:92
llvm::PatternMatch::specific_fpval::specific_fpval
specific_fpval(double V)
Definition: PatternMatch.h:825
Casting.h
llvm::PatternMatch::m_SignMask
cst_pred_ty< is_sign_mask > m_SignMask()
Match an integer or vector with only the sign bit(s) set.
Definition: PatternMatch.h:580
llvm::APInt::isSameValue
static bool isSameValue(const APInt &I1, const APInt &I2)
Determine if two APInts have the same value, after zero-extending one of them (if needed!...
Definition: APInt.h:678
llvm::PatternMatch::CmpClass_match::match
bool match(OpTy *V)
Definition: PatternMatch.h:1376
llvm::PatternMatch::m_NSWShl
OverflowingBinaryOp_match< LHS, RHS, Instruction::Shl, OverflowingBinaryOperator::NoSignedWrap > m_NSWShl(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1205
llvm::PatternMatch::m_BSwap
m_Intrinsic_Ty< Opnd0 >::Ty m_BSwap(const Opnd0 &Op0)
Definition: PatternMatch.h:2156
llvm::PatternMatch::ExtractValue_match::match
bool match(OpTy *V)
Definition: PatternMatch.h:2365
llvm::PatternMatch::umax_pred_ty
Helper class for identifying unsigned max predicates.
Definition: PatternMatch.h:1816
llvm::PatternMatch::m_ExtractValue
ExtractValue_match< Ind, Val_t > m_ExtractValue(const Val_t &V)
Match a single index ExtractValue instruction.
Definition: PatternMatch.h:2380
llvm::PatternMatch::m_c_Mul
BinaryOp_match< LHS, RHS, Instruction::Mul, true > m_c_Mul(const LHS &L, const RHS &R)
Matches a Mul with LHS and RHS in either order.
Definition: PatternMatch.h:2222
llvm::PatternMatch::BinOpPred_match::BinOpPred_match
BinOpPred_match(const LHS_t &LHS, const RHS_t &RHS)
Definition: PatternMatch.h:1252
llvm::PatternMatch::m_ZeroInt
cst_pred_ty< is_zero_int > m_ZeroInt()
Match an integer 0 or a vector with all elements equal to 0.
Definition: PatternMatch.h:522
llvm::PatternMatch::is_any_apint
Definition: PatternMatch.h:431
llvm::PatternMatch::m_PtrToInt
CastClass_match< OpTy, Instruction::PtrToInt > m_PtrToInt(const OpTy &Op)
Matches PtrToInt.
Definition: PatternMatch.h:1604
llvm::CmpInst::ICMP_SGE
@ ICMP_SGE
signed greater or equal
Definition: InstrTypes.h:750
llvm::MCID::Add
@ Add
Definition: MCInstrDesc.h:184
llvm::PatternMatch::m_Signum
Signum_match< Val_t > m_Signum(const Val_t &V)
Matches a signum pattern.
Definition: PatternMatch.h:2357
llvm::Instruction::isBitwiseLogicOp
bool isBitwiseLogicOp() const
Return true if this is and/or/xor.
Definition: Instruction.h:215
llvm::PatternMatch::is_non_zero_fp::isValue
bool isValue(const APFloat &C)
Definition: PatternMatch.h:719
llvm::PatternMatch::m_APFloatAllowUndef
apfloat_match m_APFloatAllowUndef(const APFloat *&Res)
Match APFloat while allowing undefs in splat vector constants.
Definition: PatternMatch.h:293
llvm::PatternMatch::InsertValue_match::match
bool match(OpTy *V)
Definition: PatternMatch.h:2398
llvm::PatternMatch::m_c_Xor
BinaryOp_match< LHS, RHS, Instruction::Xor, true > m_c_Xor(const LHS &L, const RHS &R)
Matches an Xor with LHS and RHS in either order.
Definition: PatternMatch.h:2243
llvm::PatternMatch::brc_match::brc_match
brc_match(const Cond_t &C, const TrueBlock_t &t, const FalseBlock_t &f)
Definition: PatternMatch.h:1723
llvm::PatternMatch::m_Mask::MaskRef
ArrayRef< int > & MaskRef
Definition: PatternMatch.h:1520
llvm::PatternMatch::m_LogicalShift
BinOpPred_match< LHS, RHS, is_logical_shift_op > m_LogicalShift(const LHS &L, const RHS &R)
Matches logical shift operations.
Definition: PatternMatch.h:1316
llvm::PatternMatch::api_pred_ty::match
bool match(ITy *V)
Definition: PatternMatch.h:377
llvm::PatternMatch::ThreeOps_match::Op3
T2 Op3
Definition: PatternMatch.h:1449
llvm::PatternMatch::m_AnyZeroFP
cstfp_pred_ty< is_any_zero_fp > m_AnyZeroFP()
Match a floating-point negative zero or positive zero.
Definition: PatternMatch.h:696
llvm::PatternMatch::m_NUWSub
OverflowingBinaryOp_match< LHS, RHS, Instruction::Sub, OverflowingBinaryOperator::NoUnsignedWrap > m_NUWSub(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1222
llvm::PatternMatch::Argument_match
Definition: PatternMatch.h:2026
llvm::PatternMatch::br_match::Succ
BasicBlock *& Succ
Definition: PatternMatch.h:1701
Predicate
llvm::PatternMatch::ofmax_pred_ty
Helper class for identifying ordered max predicates.
Definition: PatternMatch.h:1830
llvm::PatternMatch::OverflowingBinaryOp_match::OverflowingBinaryOp_match
OverflowingBinaryOp_match(const LHS_t &LHS, const RHS_t &RHS)
Definition: PatternMatch.h:1159
llvm::PatternMatch::m_ConstantExpr
class_match< ConstantExpr > m_ConstantExpr()
Match an arbitrary ConstantExpr and ignore it.
Definition: PatternMatch.h:155
llvm::PatternMatch::is_shift_op
Definition: PatternMatch.h:1265
llvm::PatternMatch::m_Intrinsic_Ty
Intrinsic matches are combinations of ID matchers, and argument matchers.
Definition: PatternMatch.h:2068
llvm::PatternMatch::m_c_FMul
BinaryOp_match< LHS, RHS, Instruction::FMul, true > m_c_FMul(const LHS &L, const RHS &R)
Matches FMul with LHS and RHS in either order.
Definition: PatternMatch.h:2317
Instructions.h
llvm::Pattern
Definition: FileCheckImpl.h:614
llvm::PatternMatch::m_c_FAdd
BinaryOp_match< LHS, RHS, Instruction::FAdd, true > m_c_FAdd(const LHS &L, const RHS &R)
Matches FAdd with LHS and RHS in either order.
Definition: PatternMatch.h:2310
llvm::PatternMatch::m_AnyIntegralConstant
cst_pred_ty< is_any_apint > m_AnyIntegralConstant()
Match an integer or vector with any integral constant.
Definition: PatternMatch.h:436
llvm::PatternMatch::apint_match::apint_match
apint_match(const APInt *&Res, bool AllowUndef)
Definition: PatternMatch.h:224
llvm::PatternMatch::m_Specific
specificval_ty m_Specific(const Value *V)
Match if we have a specific specified value.
Definition: PatternMatch.h:802
llvm::OverflowingBinaryOperator::NoSignedWrap
@ NoSignedWrap
Definition: Operator.h:71
llvm::PatternMatch::m_ICmp
CmpClass_match< LHS, RHS, ICmpInst, ICmpInst::Predicate > m_ICmp(ICmpInst::Predicate &Pred, const LHS &L, const RHS &R)
Definition: PatternMatch.h:1399
llvm::CmpInst::ICMP_UGT
@ ICMP_UGT
unsigned greater than
Definition: InstrTypes.h:745
llvm::PatternMatch::OverflowingBinaryOp_match::L
LHS_t L
Definition: PatternMatch.h:1156
llvm::Type::getPointerElementType
Type * getPointerElementType() const
Definition: Type.h:378
llvm::PatternMatch::m_Intrinsic_Ty< T0, T1, T2, T3, T4, T5 >::Ty
match_combine_and< typename m_Intrinsic_Ty< T0, T1, T2, T3, T4 >::Ty, Argument_match< T5 > > Ty
Definition: PatternMatch.h:2098
llvm::PatternMatch::brc_match::match
bool match(OpTy *V)
Definition: PatternMatch.h:1726
llvm::PatternMatch::m_SplatOrUndefMask::SplatIndex
int & SplatIndex
Definition: PatternMatch.h:1541
llvm::PatternMatch::TwoOps_match::Op1
T0 Op1
Definition: PatternMatch.h:1430
llvm::PatternMatch::Signum_match::Signum_match
Signum_match(const Opnd_t &V)
Definition: PatternMatch.h:2323
llvm::PatternMatch::is_shift_op::isOpType
bool isOpType(unsigned Opcode)
Definition: PatternMatch.h:1266
llvm::PatternMatch::CmpClass_match::L
LHS_t L
Definition: PatternMatch.h:1368
llvm::PatternMatch::specific_intval::match
bool match(ITy *V)
Definition: PatternMatch.h:868
llvm::PatternMatch::is_nonpositive::isValue
bool isValue(const APInt &C)
Definition: PatternMatch.h:499
llvm::PatternMatch::m_NSWNeg
OverflowingBinaryOp_match< cst_pred_ty< is_zero_int >, ValTy, Instruction::Sub, OverflowingBinaryOperator::NoSignedWrap > m_NSWNeg(const ValTy &V)
Matches a 'Neg' as 'sub nsw 0, V'.
Definition: PatternMatch.h:2260
Threshold
static cl::opt< unsigned > Threshold("loop-unswitch-threshold", cl::desc("Max loop size to unswitch"), cl::init(100), cl::Hidden)
llvm::PatternMatch::UAddWithOverflow_match::match
bool match(OpTy *V)
Definition: PatternMatch.h:1966
llvm::TypeSize::getKnownMinSize
ScalarTy getKnownMinSize() const
Definition: TypeSize.h:427
llvm::PatternMatch::match_unless::match
bool match(ITy *V)
Definition: PatternMatch.h:170
llvm::PatternMatch::api_pred_ty::Res
const APInt *& Res
Definition: PatternMatch.h:373
llvm::CmpInst::FCMP_OLE
@ FCMP_OLE
0 1 0 1 True if ordered and less than or equal
Definition: InstrTypes.h:729
llvm::PatternMatch::m_FCmp
CmpClass_match< LHS, RHS, FCmpInst, FCmpInst::Predicate > m_FCmp(FCmpInst::Predicate &Pred, const LHS &L, const RHS &R)
Definition: PatternMatch.h:1405
llvm::PatternMatch::ofmin_pred_ty
Helper class for identifying ordered min predicates.
Definition: PatternMatch.h:1837
llvm::PatternMatch::m_IntToPtr
CastClass_match< OpTy, Instruction::IntToPtr > m_IntToPtr(const OpTy &Op)
Matches IntToPtr.
Definition: PatternMatch.h:1610
llvm::PatternMatch::m_Neg
BinaryOp_match< cst_pred_ty< is_zero_int >, ValTy, Instruction::Sub > m_Neg(const ValTy &V)
Matches a 'Neg' as 'sub 0, V'.
Definition: PatternMatch.h:2251
llvm::PatternMatch::m_InsertValue
InsertValue_match< Ind, Val_t, Elt_t > m_InsertValue(const Val_t &Val, const Elt_t &Elt)
Matches a single index InsertValue instruction.
Definition: PatternMatch.h:2409
llvm::PatternMatch::is_neg_zero_fp::isValue
bool isValue(const APFloat &C)
Definition: PatternMatch.h:710
llvm::PatternMatch::specific_bbval::specific_bbval
specific_bbval(BasicBlock *Val)
Definition: PatternMatch.h:904
llvm::PatternMatch::is_any_zero_fp
Definition: PatternMatch.h:691
BB
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
Definition: README.txt:39
llvm::PatternMatch::match_unless
Inverting matcher.
Definition: PatternMatch.h:165
llvm::PatternMatch::is_strictlypositive::isValue
bool isValue(const APInt &C)
Definition: PatternMatch.h:487
llvm::PatternMatch::match_combine_or::match_combine_or
match_combine_or(const LTy &Left, const RTy &Right)
Definition: PatternMatch.h:183
llvm::PatternMatch::is_nonnegative
Definition: PatternMatch.h:474
llvm::PatternMatch::CmpClass_match
Definition: PatternMatch.h:1366
llvm::PatternMatch::Argument_match::OpI
unsigned OpI
Definition: PatternMatch.h:2027
llvm::PatternMatch::m_APIntForbidUndef
apint_match m_APIntForbidUndef(const APInt *&Res)
Match APInt while forbidding undefs in splat vector constants.
Definition: PatternMatch.h:281
llvm::PatternMatch::m_BasicBlock
class_match< BasicBlock > m_BasicBlock()
Match an arbitrary basic block value and ignore it.
Definition: PatternMatch.h:160
llvm::PatternMatch::umin_pred_ty::match
static bool match(ICmpInst::Predicate Pred)
Definition: PatternMatch.h:1824
llvm::PatternMatch::m_Finite
cstfp_pred_ty< is_finite > m_Finite()
Match a finite FP constant, i.e.
Definition: PatternMatch.h:674
llvm::PatternMatch::is_zero_int
Definition: PatternMatch.h:517
llvm::PatternMatch::apfloat_match::Res
const APFloat *& Res
Definition: PatternMatch.h:246
llvm::PatternMatch::match_unless::match_unless
match_unless(const Ty &Matcher)
Definition: PatternMatch.h:168
llvm::PatternMatch::m_Trunc
CastClass_match< OpTy, Instruction::Trunc > m_Trunc(const OpTy &Op)
Matches Trunc.
Definition: PatternMatch.h:1616
llvm::PatternMatch::match_combine_and::match
bool match(ITy *V)
Definition: PatternMatch.h:200
llvm::PatternMatch::is_nonnan
Definition: PatternMatch.h:642
llvm::PatternMatch::apfloat_match::match
bool match(ITy *V)
Definition: PatternMatch.h:252
llvm::PatternMatch::CastClass_match::Op
Op_t Op
Definition: PatternMatch.h:1585
llvm::PatternMatch::ofmin_pred_ty::match
static bool match(FCmpInst::Predicate Pred)
Definition: PatternMatch.h:1838
llvm::PatternMatch::m_SelectCst
ThreeOps_match< Cond, constantint_match< L >, constantint_match< R >, Instruction::Select > m_SelectCst(const Cond &C)
This matches a select of two constants, e.g.
Definition: PatternMatch.h:1476
llvm::PatternMatch::m_FMul
BinaryOp_match< LHS, RHS, Instruction::FMul > m_FMul(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1076
llvm::tgtok::TrueVal
@ TrueVal
Definition: TGLexer.h:61
llvm::PatternMatch::is_any_zero_fp::isValue
bool isValue(const APFloat &C)
Definition: PatternMatch.h:692
Value.h
llvm::PatternMatch::m_Cmp
class_match< CmpInst > m_Cmp()
Matches any compare instruction and ignore it.
Definition: PatternMatch.h:89
llvm::PatternMatch::is_logical_shift_op::isOpType
bool isOpType(unsigned Opcode)
Definition: PatternMatch.h:1276
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
llvm::PatternMatch::m_Shl
BinaryOp_match< LHS, RHS, Instruction::Shl > m_Shl(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1136
llvm::PatternMatch::m_FNegNSZ
BinaryOp_match< cstfp_pred_ty< is_any_zero_fp >, RHS, Instruction::FSub > m_FNegNSZ(const RHS &X)
Match 'fneg X' as 'fsub +-0.0, X'.
Definition: PatternMatch.h:1065
llvm::PatternMatch::OneUse_match
Definition: PatternMatch.h:57
llvm::APIntOps::smax
const APInt & smax(const APInt &A, const APInt &B)
Determine the larger of two APInts considered to be signed.
Definition: APInt.h:2180
llvm::PatternMatch::m_LogicalAnd
LogicalOp_match< LHS, RHS, Instruction::And > m_LogicalAnd(const LHS &L, const RHS &R)
Matches L && R either in the form of L & R or L ? R : false.
Definition: PatternMatch.h:2490
llvm::PatternMatch::Exact_match::Exact_match
Exact_match(const SubPattern_t &SP)
Definition: PatternMatch.h:1347
llvm::PatternMatch::apf_pred_ty::match
bool match(ITy *V)
Definition: PatternMatch.h:403
llvm::PatternMatch::OneUse_match::SubPattern
SubPattern_t SubPattern
Definition: PatternMatch.h:58
llvm::PatternMatch::AnyBinaryOp_match::match
bool match(OpTy *V)
Definition: PatternMatch.h:938
llvm::PatternMatch::m_c_UMin
MaxMin_match< ICmpInst, LHS, RHS, umin_pred_ty, true > m_c_UMin(const LHS &L, const RHS &R)
Matches a UMin with LHS and RHS in either order.
Definition: PatternMatch.h:2286
llvm::PatternMatch::m_Mul
BinaryOp_match< LHS, RHS, Instruction::Mul > m_Mul(const LHS &L, const RHS &R)
Definition: PatternMatch.h:1070
llvm::PatternMatch::ufmax_pred_ty::match
static bool match(FCmpInst::Predicate Pred)
Definition: PatternMatch.h:1845
llvm::PatternMatch::is_zero::match
bool match(ITy *V)
Definition: PatternMatch.h:527
llvm::SmallVectorImpl::emplace_back
reference emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:908
llvm::PatternMatch::OverflowingBinaryOp_match
Definition: PatternMatch.h:1155
llvm::PatternMatch::IntrinsicID_match
Intrinsic matchers.
Definition: PatternMatch.h:2047
llvm::SmallPtrSetImpl::insert
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Definition: SmallPtrSet.h:364
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:38
llvm::PatternMatch::br_match
Definition: PatternMatch.h:1700
llvm::PatternMatch::brc_match::F
FalseBlock_t F
Definition: PatternMatch.h:1721