LLVM: include/llvm/IR/PatternMatch.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28#ifndef LLVM_IR_PATTERNMATCH_H
29#define LLVM_IR_PATTERNMATCH_H
30
44#include
45
46namespace llvm {
47namespace PatternMatch {
48
49template <typename Val, typename Pattern> bool match(Val *V, const Pattern &P) {
51}
52
55}
56
59
61
62 template bool match(OpTy *V) {
63 return V->hasOneUse() && SubPattern.match(V);
64 }
65};
66
68 return SubPattern;
69}
70
73
75
76 template bool match(OpTy *V) {
77 auto *I = dyn_cast(V);
78 return I && I->hasAllowReassoc() && SubPattern.match(I);
79 }
80};
81
82template
84 return SubPattern;
85}
86
88 template bool match(ITy *V) { return isa(V); }
89};
90
91
93
94
97}
98
99
102}
103
104
106
109 if (isa(V))
110 return true;
111
112 const auto *CA = dyn_cast(V);
113 if (!CA)
114 return false;
115
118
119
120
121
123 for (const Value *Op : CA->operand_values()) {
124 if (isa(Op))
125 continue;
126
127 const auto *CA = dyn_cast(Op);
128 if (!CA)
129 return false;
130 if (Seen.insert(CA).second)
132 }
133
134 return true;
135 };
136
137 if (!CheckValue(CA))
138 return false;
139
140 while (!Worklist.empty()) {
142 return false;
143 }
144 return true;
145 }
146 template bool match(ITy *V) { return check(V); }
147};
148
149
150
151
153
154
157}
158
159
162}
163
164
166
167
170}
171
172
175}
176
178 template bool match(ITy *V) {
179 auto *C = dyn_cast(V);
180 return C && (isa(C) || C->containsConstantExpression());
181 }
182};
183
184
185
187
188
191}
192
193
196
198
199 template bool match(ITy *V) { return .match(V); }
200};
201
202
205}
206
207
211
213
214 template bool match(ITy *V) {
215 if (L.match(V))
216 return true;
217 if (R.match(V))
218 return true;
219 return false;
220 }
221};
222
226
228
229 template bool match(ITy *V) {
230 if (L.match(V))
231 if (R.match(V))
232 return true;
233 return false;
234 }
235};
236
237
238template <typename LTy, typename RTy>
241}
242
243
244template <typename LTy, typename RTy>
247}
248
252
255
256 template bool match(ITy *V) {
257 if (auto *CI = dyn_cast(V)) {
258 Res = &CI->getValue();
259 return true;
260 }
261 if (V->getType()->isVectorTy())
262 if (const auto *C = dyn_cast(V))
263 if (auto *CI =
264 dyn_cast_or_null(C->getSplatValue(AllowPoison))) {
265 Res = &CI->getValue();
266 return true;
267 }
268 return false;
269 }
270};
271
272
273
277
280
281 template bool match(ITy *V) {
282 if (auto *CI = dyn_cast(V)) {
283 Res = &CI->getValueAPF();
284 return true;
285 }
286 if (V->getType()->isVectorTy())
287 if (const auto *C = dyn_cast(V))
288 if (auto *CI =
289 dyn_cast_or_null(C->getSplatValue(AllowPoison))) {
290 Res = &CI->getValueAPF();
291 return true;
292 }
293 return false;
294 }
295};
296
297
298
300
301 return apint_match(Res, false);
302}
303
304
306 return apint_match(Res, true);
307}
308
309
311 return apint_match(Res, false);
312}
313
314
315
317
318 return apfloat_match(Res, false);
319}
320
321
323 return apfloat_match(Res, true);
324}
325
326
328 return apfloat_match(Res, false);
329}
330
332 template bool match(ITy *V) {
333 if (const auto *CI = dyn_cast(V)) {
334 const APInt &CIV = CI->getValue();
335 if (Val >= 0)
336 return CIV == static_cast<uint64_t>(Val);
337
338
339
340 return -CIV == -Val;
341 }
342 return false;
343 }
344};
345
346
349}
350
351
352
353
354
355template <typename Predicate, typename ConstantVal, bool AllowPoison>
358 template bool match_impl(ITy *V) {
359 if (const auto *CV = dyn_cast(V))
360 return this->isValue(CV->getValue());
361 if (const auto *VTy = dyn_cast(V->getType())) {
362 if (const auto *C = dyn_cast(V)) {
363 if (const auto *CV = dyn_cast_or_null(C->getSplatValue()))
364 return this->isValue(CV->getValue());
365
366
367 auto *FVTy = dyn_cast(VTy);
368 if (!FVTy)
369 return false;
370
371
372 unsigned NumElts = FVTy->getNumElements();
373 assert(NumElts != 0 && "Constant vector with no elements?");
374 bool HasNonPoisonElements = false;
375 for (unsigned i = 0; i != NumElts; ++i) {
376 Constant *Elt = C->getAggregateElement(i);
377 if (!Elt)
378 return false;
379 if (AllowPoison && isa(Elt))
380 continue;
381 auto *CV = dyn_cast(Elt);
382 if (!CV || !this->isValue(CV->getValue()))
383 return false;
384 HasNonPoisonElements = true;
385 }
386 return HasNonPoisonElements;
387 }
388 }
389 return false;
390 }
391
392 template bool match(ITy *V) {
395 *Res = cast(V);
396 return true;
397 }
398 return false;
399 }
400};
401
402
403template <typename Predicate, bool AllowPoison = true>
405
406
407template
409 true>;
410
411
412
413template struct api_pred_ty : public Predicate {
415
417
418 template bool match(ITy *V) {
419 if (const auto *CI = dyn_cast(V))
420 if (this->isValue(CI->getValue())) {
421 Res = &CI->getValue();
422 return true;
423 }
424 if (V->getType()->isVectorTy())
425 if (const auto *C = dyn_cast(V))
426 if (auto *CI = dyn_cast_or_null(
427 C->getSplatValue(true)))
428 if (this->isValue(CI->getValue())) {
429 Res = &CI->getValue();
430 return true;
431 }
432
433 return false;
434 }
435};
436
437
438
439
440template struct apf_pred_ty : public Predicate {
442
444
445 template bool match(ITy *V) {
446 if (const auto *CI = dyn_cast(V))
447 if (this->isValue(CI->getValue())) {
448 Res = &CI->getValue();
449 return true;
450 }
451 if (V->getType()->isVectorTy())
452 if (const auto *C = dyn_cast(V))
453 if (auto *CI = dyn_cast_or_null(
454 C->getSplatValue( true)))
455 if (this->isValue(CI->getValue())) {
456 Res = &CI->getValue();
457 return true;
458 }
459
460 return false;
461 }
462};
463
464
465
466
467
468
469
470
471
472
476};
477
478
479
483}
484
488}
489
490
491
495}
496
500}
501
504};
505
506
509}
510
513};
514
517}
518
521};
522
523
526}
527
530}
531
534};
535
536
537
540}
542 return V;
543}
544
547};
548
549
552}
554
557};
558
559
562}
564
567};
568
569
572}
574 return V;
575}
576
579};
580
581
584}
586
589};
590
591
593
596};
597
598
601}
602
604 template bool match(ITy *V) {
605 auto *C = dyn_cast(V);
606
608 }
609};
610
611
613
616};
617
618
621
624};
625
626
629}
631 return V;
632}
633
636};
637
638
641}
644 return V;
645}
646
649};
650
651
654}
656 return V;
657}
658
661};
662
663
666}
667
670};
671
672
675}
677
680};
681
682
685}
687 return V;
688}
689
694};
695
696
700 P.Pred = Predicate;
701 P.Thr = &Threshold;
702 return P;
703}
704
707};
708
709
711
714};
715
716
719}
720
723};
724
725
727
730};
731
732
735}
736
739};
740
741
744}
746
749};
750
751
754}
756 return V;
757}
758
761};
762
763
766}
767
770};
771
772
775}
776
779};
780
781
784}
785
788};
789
790
793}
794
797};
798
799
800
803}
804
805
806
809
811
812 template bool match(ITy *V) {
813 if (auto *CV = dyn_cast(V)) {
814 VR = CV;
815 return true;
816 }
817 return false;
818 }
819};
820
821
824
825
827
829
831
833 return I;
834}
837 return I;
838}
839
840
842
843
845
846
848
849
851
852
854
855
858 return V;
859}
860
861
866}
867
868
873}
874
875
878
880
881 template bool match(ITy *V) { return V == Val; }
882};
883
884
886
887
888
891
893
894 template bool match(ITy *const V) { return V == Val; }
895};
896
897
898
899
900
901
902
905 return V;
906}
907
908
909
912
914
915 template bool match(ITy *V) {
916 if (const auto *CFP = dyn_cast(V))
917 return CFP->isExactlyValue(Val);
918 if (V->getType()->isVectorTy())
919 if (const auto *C = dyn_cast(V))
920 if (auto *CFP = dyn_cast_or_null(C->getSplatValue()))
921 return CFP->isExactlyValue(Val);
922 return false;
923 }
924};
925
926
927
929
930
932
935
937
938 template bool match(ITy *V) {
939 if (const auto *CV = dyn_cast(V))
940 if (CV->getValue().ule(UINT64_MAX)) {
941 VR = CV->getZExtValue();
942 return true;
943 }
944 return false;
945 }
946};
947
948
949
952
954
955 template bool match(ITy *V) {
956 const auto *CI = dyn_cast(V);
957 if (!CI && V->getType()->isVectorTy())
958 if (const auto *C = dyn_cast(V))
959 CI = dyn_cast_or_null(C->getSplatValue(AllowPoison));
960
962 }
963};
964
967
969
970 template bool match(ITy *V) {
971 const auto *CI = dyn_cast(V);
972 if (!CI && V->getType()->isVectorTy())
973 if (const auto *C = dyn_cast(V))
974 CI = dyn_cast_or_null(C->getSplatValue(AllowPoison));
975
976 return CI && CI->getValue() == Val;
977 }
978};
979
980
981
984}
985
988}
989
992}
993
996}
997
998
999
1001
1002
1005
1007
1008 template bool match(ITy *V) {
1009 const auto *BB = dyn_cast(V);
1010 return BB && BB == Val;
1011 }
1012};
1013
1014
1017}
1018
1019
1021 return BB;
1022}
1025 return BB;
1026}
1027
1028
1029
1030
1031template <typename LHS_t, typename RHS_t, bool Commutable = false>
1035
1036
1037
1039
1040 template bool match(OpTy *V) {
1041 if (auto *I = dyn_cast(V))
1042 return (L.match(I->getOperand(0)) && R.match(I->getOperand(1))) ||
1043 (Commutable && L.match(I->getOperand(1)) &&
1044 R.match(I->getOperand(0)));
1045 return false;
1046 }
1047};
1048
1049template <typename LHS, typename RHS>
1052}
1053
1054
1055
1056
1057
1060
1062
1063 template bool match(OpTy *V) {
1064 if (auto *I = dyn_cast(V))
1065 return X.match(I->getOperand(0));
1066 return false;
1067 }
1068};
1069
1072}
1073
1074
1075
1076
1077
1078template <typename LHS_t, typename RHS_t, unsigned Opcode,
1079 bool Commutable = false>
1083
1084
1085
1087
1088 template inline bool match(unsigned Opc, OpTy *V) {
1089 if (V->getValueID() == Value::InstructionVal + Opc) {
1090 auto *I = cast(V);
1091 return (L.match(I->getOperand(0)) && R.match(I->getOperand(1))) ||
1092 (Commutable && L.match(I->getOperand(1)) &&
1093 R.match(I->getOperand(0)));
1094 }
1095 return false;
1096 }
1097
1098 template bool match(OpTy *V) { return match(Opcode, V); }
1099};
1100
1101template <typename LHS, typename RHS>
1103 const RHS &R) {
1105}
1106
1107template <typename LHS, typename RHS>
1109 const RHS &R) {
1111}
1112
1113template <typename LHS, typename RHS>
1115 const RHS &R) {
1117}
1118
1119template <typename LHS, typename RHS>
1121 const RHS &R) {
1123}
1124
1127
1129 template bool match(OpTy *V) {
1130 auto *FPMO = dyn_cast(V);
1131 if (!FPMO)
1132 return false;
1133
1134 if (FPMO->getOpcode() == Instruction::FNeg)
1135 return X.match(FPMO->getOperand(0));
1136
1137 if (FPMO->getOpcode() == Instruction::FSub) {
1138 if (FPMO->hasNoSignedZeros()) {
1139
1141 return false;
1142 } else {
1143
1145 return false;
1146 }
1147
1148 return X.match(FPMO->getOperand(1));
1149 }
1150
1151 return false;
1152 }
1153};
1154
1155
1158}
1159
1160
1161template
1165}
1166
1167template <typename LHS, typename RHS>
1169 const RHS &R) {
1171}
1172
1173template <typename LHS, typename RHS>
1175 const RHS &R) {
1177}
1178
1179template <typename LHS, typename RHS>
1181 const RHS &R) {
1183}
1184
1185template <typename LHS, typename RHS>
1187 const RHS &R) {
1189}
1190
1191template <typename LHS, typename RHS>
1193 const RHS &R) {
1195}
1196
1197template <typename LHS, typename RHS>
1199 const RHS &R) {
1201}
1202
1203template <typename LHS, typename RHS>
1205 const RHS &R) {
1207}
1208
1209template <typename LHS, typename RHS>
1211 const RHS &R) {
1213}
1214
1215template <typename LHS, typename RHS>
1217 const RHS &R) {
1219}
1220
1221template <typename LHS, typename RHS>
1223 const RHS &R) {
1225}
1226
1227template <typename LHS, typename RHS>
1229 const RHS &R) {
1231}
1232
1233template <typename LHS, typename RHS>
1235 const RHS &R) {
1237}
1238
1239template <typename LHS, typename RHS>
1241 const RHS &R) {
1243}
1244
1245template <typename LHS, typename RHS>
1247 const RHS &R) {
1249}
1250
1251template <typename LHS_t, typename RHS_t, unsigned Opcode,
1252 unsigned WrapFlags = 0, bool Commutable = false>
1256
1259
1260 template bool match(OpTy *V) {
1261 if (auto *Op = dyn_cast(V)) {
1262 if (Op->getOpcode() != Opcode)
1263 return false;
1265 ->hasNoUnsignedWrap())
1266 return false;
1268 ->hasNoSignedWrap())
1269 return false;
1270 return (L.match(Op->getOperand(0)) && R.match(Op->getOperand(1))) ||
1271 (Commutable && L.match(Op->getOperand(1)) &&
1272 R.match(Op->getOperand(0)));
1273 }
1274 return false;
1275 }
1276};
1277
1278template <typename LHS, typename RHS>
1284 R);
1285}
1286template <typename LHS, typename RHS>
1292 R);
1293}
1294template <typename LHS, typename RHS>
1300 R);
1301}
1302template <typename LHS, typename RHS>
1308 R);
1309}
1310
1311template <typename LHS, typename RHS>
1317 L, R);
1318}
1319
1320template <typename LHS, typename RHS>
1326 true>(L, R);
1327}
1328
1329template <typename LHS, typename RHS>
1335 L, R);
1336}
1337template <typename LHS, typename RHS>
1343 L, R);
1344}
1345template <typename LHS, typename RHS>
1351 L, R);
1352}
1353
1354template <typename LHS_t, typename RHS_t, bool Commutable = false>
1356 : public BinaryOp_match<LHS_t, RHS_t, 0, Commutable> {
1358
1361
1362 template bool match(OpTy *V) {
1364 }
1365};
1366
1367
1368template <typename LHS, typename RHS>
1370 const RHS &R) {
1372}
1373
1374template <typename LHS, typename RHS, bool Commutable = false>
1378
1380
1381 template bool match(OpTy *V) {
1382 if (auto *PDI = dyn_cast(V)) {
1383 assert(PDI->getOpcode() == Instruction::Or && "Only or can be disjoint");
1384 if (!PDI->isDisjoint())
1385 return false;
1386 return (L.match(PDI->getOperand(0)) && R.match(PDI->getOperand(1))) ||
1387 (Commutable && L.match(PDI->getOperand(1)) &&
1388 R.match(PDI->getOperand(0)));
1389 }
1390 return false;
1391 }
1392};
1393
1394template <typename LHS, typename RHS>
1397}
1398
1399template <typename LHS, typename RHS>
1401 const RHS &R) {
1403}
1404
1405
1406template <typename LHS, typename RHS>
1411}
1412
1413
1414template <typename LHS, typename RHS>
1421}
1422
1423
1424template <typename LHS, typename RHS>
1431}
1432
1433template <typename LHS, typename RHS>
1437
1439
1440 template bool match(OpTy *V) {
1441 if (auto *Op = dyn_cast(V)) {
1442 if (Op->getOpcode() == Instruction::Sub && Op->hasNoUnsignedWrap() &&
1444 ;
1445 else if (Op->getOpcode() != Instruction::Xor)
1446 return false;
1447 return (L.match(Op->getOperand(0)) && R.match(Op->getOperand(1))) ||
1448 (L.match(Op->getOperand(1)) && R.match(Op->getOperand(0)));
1449 }
1450 return false;
1451 }
1452};
1453
1454
1455
1456template <typename LHS, typename RHS>
1459}
1460
1461
1462
1463
1464template <typename LHS_t, typename RHS_t, typename Predicate,
1465 bool Commutable = false>
1469
1471
1472 template bool match(OpTy *V) {
1473 if (auto *I = dyn_cast(V))
1474 return this->isOpType(I->getOpcode()) &&
1475 ((L.match(I->getOperand(0)) && R.match(I->getOperand(1))) ||
1476 (Commutable && L.match(I->getOperand(1)) &&
1477 R.match(I->getOperand(0))));
1478 return false;
1479 }
1480};
1481
1484};
1485
1488 return Opcode == Instruction::LShr || Opcode == Instruction::AShr;
1489 }
1490};
1491
1494 return Opcode == Instruction::LShr || Opcode == Instruction::Shl;
1495 }
1496};
1497
1501 }
1502};
1503
1506 return Opcode == Instruction::SDiv || Opcode == Instruction::UDiv;
1507 }
1508};
1509
1512 return Opcode == Instruction::SRem || Opcode == Instruction::URem;
1513 }
1514};
1515
1516
1517template <typename LHS, typename RHS>
1519 const RHS &R) {
1521}
1522
1523
1524template <typename LHS, typename RHS>
1526 const RHS &R) {
1528}
1529
1530
1531template <typename LHS, typename RHS>
1535}
1536
1537
1538template <typename LHS, typename RHS>
1542}
1543
1544
1545template <typename LHS, typename RHS>
1549}
1550
1551
1552template <typename LHS, typename RHS>
1554 const RHS &R) {
1556}
1557
1558
1559template <typename LHS, typename RHS>
1561 const RHS &R) {
1563}
1564
1565
1566
1567
1570
1572
1573 template bool match(OpTy *V) {
1574 if (auto *PEO = dyn_cast(V))
1575 return PEO->isExact() && SubPattern.match(V);
1576 return false;
1577 }
1578};
1579
1581 return SubPattern;
1582}
1583
1584
1585
1586
1587
1588template <typename LHS_t, typename RHS_t, typename Class,
1589 bool Commutable = false>
1594
1595
1596
1601
1602 template bool match(OpTy *V) {
1603 if (auto *I = dyn_cast(V)) {
1604 if (L.match(I->getOperand(0)) && R.match(I->getOperand(1))) {
1607 return true;
1608 }
1609 if (Commutable && L.match(I->getOperand(1)) &&
1610 R.match(I->getOperand(0))) {
1613 return true;
1614 }
1615 }
1616 return false;
1617 }
1618};
1619
1620template <typename LHS, typename RHS>
1622 const RHS &R) {
1624}
1625
1626template <typename LHS, typename RHS>
1628 const LHS &L, const RHS &R) {
1630}
1631
1632template <typename LHS, typename RHS>
1634 const LHS &L, const RHS &R) {
1636}
1637
1638template <typename LHS, typename RHS>
1641}
1642
1643template <typename LHS, typename RHS>
1646}
1647
1648template <typename LHS, typename RHS>
1651}
1652
1653
1654
1655template <typename LHS_t, typename RHS_t, typename Class,
1656 bool Commutable = false>
1661
1664
1665 template bool match(OpTy *V) {
1666 if (auto *I = dyn_cast(V)) {
1668 L.match(I->getOperand(0)) && R.match(I->getOperand(1)))
1669 return true;
1670 if constexpr (Commutable) {
1673 L.match(I->getOperand(1)) && R.match(I->getOperand(0)))
1674 return true;
1675 }
1676 }
1677
1678 return false;
1679 }
1680};
1681
1682template <typename LHS, typename RHS>
1686}
1687
1688template <typename LHS, typename RHS>
1692}
1693
1694template <typename LHS, typename RHS>
1698}
1699
1700template <typename LHS, typename RHS>
1704}
1705
1706
1707
1708
1709
1710
1711template <typename T0, unsigned Opcode> struct OneOps_match {
1713
1715
1716 template bool match(OpTy *V) {
1717 if (V->getValueID() == Value::InstructionVal + Opcode) {
1718 auto *I = cast(V);
1719 return Op1.match(I->getOperand(0));
1720 }
1721 return false;
1722 }
1723};
1724
1725
1726template <typename T0, typename T1, unsigned Opcode> struct TwoOps_match {
1729
1731
1732 template bool match(OpTy *V) {
1733 if (V->getValueID() == Value::InstructionVal + Opcode) {
1734 auto *I = cast(V);
1735 return Op1.match(I->getOperand(0)) && Op2.match(I->getOperand(1));
1736 }
1737 return false;
1738 }
1739};
1740
1741
1742template <typename T0, typename T1, typename T2, unsigned Opcode,
1743 bool CommutableOp2Op3 = false>
1748
1751
1752 template bool match(OpTy *V) {
1753 if (V->getValueID() == Value::InstructionVal + Opcode) {
1754 auto *I = cast(V);
1755 if (.match(I->getOperand(0)))
1756 return false;
1757 if (Op2.match(I->getOperand(1)) && Op3.match(I->getOperand(2)))
1758 return true;
1759 return CommutableOp2Op3 && Op2.match(I->getOperand(2)) &&
1760 Op3.match(I->getOperand(1));
1761 }
1762 return false;
1763 }
1764};
1765
1766
1767template <unsigned Opcode, typename... OperandTypes> struct AnyOps_match {
1769
1771
1772
1773
1774
1775
1776 template <int Idx, int Last>
1778 return match_operands<Idx, Idx>(I) && match_operands<Idx + 1, Last>(I);
1779 }
1780
1781 template <int Idx, int Last>
1783 return std::get(Operands).match(I->getOperand(Idx));
1784 }
1785
1786 template bool match(OpTy *V) {
1787 if (V->getValueID() == Value::InstructionVal + Opcode) {
1788 auto *I = cast(V);
1789 return I->getNumOperands() == sizeof...(OperandTypes) &&
1791 }
1792 return false;
1793 }
1794};
1795
1796
1797template <typename Cond, typename LHS, typename RHS>
1801}
1802
1803
1804
1805template <int64_t L, int64_t R, typename Cond>
1807 Instruction::Select>
1809 return m_Select(C, m_ConstantInt(), m_ConstantInt());
1810}
1811
1812
1813template <typename LHS, typename RHS>
1818}
1819
1820
1821template
1824}
1825
1826
1827template <typename Val_t, typename Elt_t, typename Idx_t>
1831 Val, Elt, Idx);
1832}
1833
1834
1835template <typename Val_t, typename Idx_t>
1839}
1840
1841
1842template <typename T0, typename T1, typename T2> struct Shuffle_match {
1846
1849
1850 template bool match(OpTy *V) {
1851 if (auto *I = dyn_cast(V)) {
1852 return Op1.match(I->getOperand(0)) && Op2.match(I->getOperand(1)) &&
1853 Mask.match(I->getShuffleMask());
1854 }
1855 return false;
1856 }
1857};
1858
1864 return true;
1865 }
1866};
1867
1870 return all_of(Mask, [](int Elem) { return Elem == 0 || Elem == -1; });
1871 }
1872};
1873
1878};
1879
1884 const auto *First = find_if(Mask, [](int Elem) { return Elem != -1; });
1885 if (First == Mask.end())
1886 return false;
1889 [First](int Elem) { return Elem == *First || Elem == -1; });
1890 }
1891};
1892
1893template <typename PointerOpTy, typename OffsetOpTy> struct PtrAdd_match {
1896
1899
1900 template bool match(OpTy *V) {
1901 auto *GEP = dyn_cast(V);
1902 return GEP && GEP->getSourceElementType()->isIntegerTy(8) &&
1903 PointerOp.match(GEP->getPointerOperand()) &&
1904 OffsetOp.match(GEP->idx_begin()->get());
1905 }
1906};
1907
1908
1909template <typename V1_t, typename V2_t>
1913}
1914
1915template <typename V1_t, typename V2_t, typename Mask_t>
1917m_Shuffle(const V1_t &v1, const V2_t &v2, const Mask_t &mask) {
1919}
1920
1921
1922template
1925}
1926
1927
1928template <typename ValueOpTy, typename PointerOpTy>
1930m_Store(const ValueOpTy &ValueOp, const PointerOpTy &PointerOp) {
1932 PointerOp);
1933}
1934
1935
1936template <typename... OperandTypes>
1937inline auto m_GEP(const OperandTypes &...Ops) {
1938 return AnyOps_match<Instruction::GetElementPtr, OperandTypes...>(Ops...);
1939}
1940
1941
1942template <typename PointerOpTy, typename OffsetOpTy>
1944m_PtrAdd(const PointerOpTy &PointerOp, const OffsetOpTy &OffsetOp) {
1946}
1947
1948
1949
1950
1951
1954
1956
1957 template bool match(OpTy *V) {
1958 if (auto *O = dyn_cast(V))
1959 return O->getOpcode() == Opcode && Op.match(O->getOperand(0));
1960 return false;
1961 }
1962};
1963
1966
1968
1969 template bool match(OpTy *V) {
1970 if (auto *I = dyn_cast(V))
1971 return Op.match(I->getOperand(0));
1972 return false;
1973 }
1974};
1975
1979
1982
1983 template bool match(OpTy *V) {
1984 if (auto *O = dyn_cast(V))
1985 return O->getOpcode() == Instruction::PtrToInt &&
1988 Op.match(O->getOperand(0));
1989 return false;
1990 }
1991};
1992
1995
1997
1998 template bool match(OpTy *V) {
1999 if (auto *I = dyn_cast(V))
2000 return I->hasNonNeg() && Op.match(I->getOperand(0));
2001 return false;
2002 }
2003};
2004
2007
2009
2010 template bool match(OpTy *V) {
2011 if (auto *I = dyn_cast(V))
2012 return (I->getNoWrapKind() & WrapFlags) == WrapFlags &&
2013 Op.match(I->getOperand(0));
2014 return false;
2015 }
2016};
2017
2018
2019template
2023}
2024
2027
2029
2030 template bool match(OpTy *V) {
2031 auto *I = dyn_cast(V);
2032 if ()
2033 return false;
2034 Type *SrcType = I->getSrcTy();
2035 Type *DstType = I->getType();
2036
2037
2039 return false;
2040 if (VectorType *SrcVecTy = dyn_cast(SrcType);
2042 cast(DstType)->getElementCount())
2043 return false;
2044 return Op.match(I->getOperand(0));
2045 }
2046};
2047
2048template
2051}
2052
2053
2054template
2058}
2059
2060template
2062 const OpTy &Op) {
2064}
2065
2066
2067template
2071}
2072
2073
2074template
2077}
2078
2079
2080template
2084}
2085
2086
2087template
2091}
2092
2093template
2097}
2098
2099
2100template
2103}
2104
2105
2106template
2109}
2110
2111template
2114}
2115
2116template
2120}
2121
2122template
2126}
2127
2128
2129template
2133}
2134
2135template
2140}
2141
2142template
2145 OpTy>
2148}
2149
2150template
2153}
2154
2155template
2158}
2159
2160template
2163}
2164
2165template
2168}
2169
2170template
2173}
2174
2175template
2178}
2179
2180
2181
2182
2183
2186
2188
2189 template bool match(OpTy *V) {
2190 if (auto *BI = dyn_cast(V))
2191 if (BI->isUnconditional()) {
2192 Succ = BI->getSuccessor(0);
2193 return true;
2194 }
2195 return false;
2196 }
2197};
2198
2200
2201template <typename Cond_t, typename TrueBlock_t, typename FalseBlock_t>
2206
2207 brc_match(const Cond_t &C, const TrueBlock_t &t, const FalseBlock_t &f)
2209
2210 template bool match(OpTy *V) {
2211 if (auto *BI = dyn_cast(V))
2212 if (BI->isConditional() && Cond.match(BI->getCondition()))
2213 return T.match(BI->getSuccessor(0)) && F.match(BI->getSuccessor(1));
2214 return false;
2215 }
2216};
2217
2218template <typename Cond_t>
2223}
2224
2225template <typename Cond_t, typename TrueBlock_t, typename FalseBlock_t>
2227m_Br(const Cond_t &C, const TrueBlock_t &T, const FalseBlock_t &F) {
2229}
2230
2231
2232
2233
2234
2235template <typename CmpInst_t, typename LHS_t, typename RHS_t, typename Pred_t,
2236 bool Commutable = false>
2241
2242
2243
2245
2246 template bool match(OpTy *V) {
2247 if (auto *II = dyn_cast(V)) {
2249 if ((IID == Intrinsic::smax && Pred_t::match(ICmpInst::ICMP_SGT)) ||
2253 Value *LHS = II->getOperand(0), *RHS = II->getOperand(1);
2254 return (L.match(LHS) && R.match(RHS)) ||
2255 (Commutable && L.match(RHS) && R.match(LHS));
2256 }
2257 }
2258
2259 auto *SI = dyn_cast(V);
2260 if (!SI)
2261 return false;
2262 auto *Cmp = dyn_cast<CmpInst_t>(SI->getCondition());
2263 if (!Cmp)
2264 return false;
2265
2266
2267 auto *TrueVal = SI->getTrueValue();
2268 auto *FalseVal = SI->getFalseValue();
2269 auto *LHS = Cmp->getOperand(0);
2270 auto *RHS = Cmp->getOperand(1);
2271 if ((TrueVal != LHS || FalseVal != RHS) &&
2272 (TrueVal != RHS || FalseVal != LHS))
2273 return false;
2274 typename CmpInst_t::Predicate Pred =
2275 LHS == TrueVal ? Cmp->getPredicate() : Cmp->getInversePredicate();
2276
2277 if (!Pred_t::match(Pred))
2278 return false;
2279
2280 return (L.match(LHS) && R.match(RHS)) ||
2281 (Commutable && L.match(RHS) && R.match(LHS));
2282 }
2283};
2284
2285
2289 }
2290};
2291
2292
2296 }
2297};
2298
2299
2303 }
2304};
2305
2306
2310 }
2311};
2312
2313
2317 }
2318};
2319
2320
2324 }
2325};
2326
2327
2331 }
2332};
2333
2334
2338 }
2339};
2340
2341template <typename LHS, typename RHS>
2343 const RHS &R) {
2345}
2346
2347template <typename LHS, typename RHS>
2349 const RHS &R) {
2351}
2352
2353template <typename LHS, typename RHS>
2355 const RHS &R) {
2357}
2358
2359template <typename LHS, typename RHS>
2361 const RHS &R) {
2363}
2364
2365template <typename LHS, typename RHS>
2374}
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385template <typename LHS, typename RHS>
2387 const RHS &R) {
2389}
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400template <typename LHS, typename RHS>
2402 const RHS &R) {
2404}
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415template <typename LHS, typename RHS>
2419}
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430template <typename LHS, typename RHS>
2434}
2435
2436
2437
2438
2439
2440
2441template <typename LHS, typename RHS>
2447}
2448
2449
2450
2451
2452
2453
2454template <typename LHS, typename RHS>
2460}
2461
2462
2463
2464
2465template
2469}
2470
2471template
2473 true>
2476}
2477
2478
2479
2480
2481
2482
2483template <typename LHS_t, typename RHS_t, typename Sum_t>
2488
2491
2492 template bool match(OpTy *V) {
2493 Value *ICmpLHS, *ICmpRHS;
2496 return false;
2497
2498 Value *AddLHS, *AddRHS;
2500
2501
2503 if (AddExpr.match(ICmpLHS) && (ICmpRHS == AddLHS || ICmpRHS == AddRHS))
2504 return L.match(AddLHS) && R.match(AddRHS) && S.match(ICmpLHS);
2505
2506
2508 if (AddExpr.match(ICmpRHS) && (ICmpLHS == AddLHS || ICmpLHS == AddRHS))
2509 return L.match(AddLHS) && R.match(AddRHS) && S.match(ICmpRHS);
2510
2513
2515 if (XorExpr.match(ICmpLHS))
2516 return L.match(Op1) && R.match(ICmpRHS) && S.match(ICmpLHS);
2517 }
2518
2520 if (XorExpr.match(ICmpRHS))
2521 return L.match(Op1) && R.match(ICmpLHS) && S.match(ICmpRHS);
2522 }
2523
2524
2526
2527
2528 if (AddExpr.match(ICmpLHS) && m_ZeroInt().match(ICmpRHS) &&
2530 return L.match(AddLHS) && R.match(AddRHS) && S.match(ICmpLHS);
2531
2532
2533 if (m_ZeroInt().match(ICmpLHS) && AddExpr.match(ICmpRHS) &&
2535 return L.match(AddLHS) && R.match(AddRHS) && S.match(ICmpRHS);
2536 }
2537
2538 return false;
2539 }
2540};
2541
2542
2543
2544
2545
2546template <typename LHS_t, typename RHS_t, typename Sum_t>
2550}
2551
2555
2557
2558 template bool match(OpTy *V) {
2559
2560 if (const auto *CI = dyn_cast(V))
2561 return Val.match(CI->getArgOperand(OpI));
2562 return false;
2563 }
2564};
2565
2566
2567template <unsigned OpI, typename Opnd_t>
2570}
2571
2572
2575
2577
2578 template bool match(OpTy *V) {
2579 if (const auto *CI = dyn_cast(V))
2580 if (const auto *F = CI->getCalledFunction())
2581 return F->getIntrinsicID() == ID;
2582 return false;
2583 }
2584};
2585
2586
2587
2588
2589
2590template <typename T0 = void, typename T1 = void, typename T2 = void,
2591 typename T3 = void, typename T4 = void, typename T5 = void,
2592 typename T6 = void, typename T7 = void, typename T8 = void,
2593 typename T9 = void, typename T10 = void>
2597};
2601};
2602template <typename T0, typename T1, typename T2>
2606};
2607template <typename T0, typename T1, typename T2, typename T3>
2611};
2612
2613template <typename T0, typename T1, typename T2, typename T3, typename T4>
2617};
2618
2619template <typename T0, typename T1, typename T2, typename T3, typename T4,
2620 typename T5>
2624};
2625
2626
2627
2630}
2631
2632
2633template <typename Opnd0, typename Opnd1, typename Opnd2, typename Opnd3>
2635m_MaskedLoad(const Opnd0 &Op0, const Opnd1 &Op1, const Opnd2 &Op2,
2636 const Opnd3 &Op3) {
2637 return m_IntrinsicIntrinsic::masked\_load(Op0, Op1, Op2, Op3);
2638}
2639
2640
2641template <typename Opnd0, typename Opnd1, typename Opnd2, typename Opnd3>
2644 const Opnd3 &Op3) {
2645 return m_IntrinsicIntrinsic::masked\_gather(Op0, Op1, Op2, Op3);
2646}
2647
2648template <Intrinsic::ID IntrID, typename T0>
2650 return m_CombineAnd(m_Intrinsic(), m_Argument<0>(Op0));
2651}
2652
2653template <Intrinsic::ID IntrID, typename T0, typename T1>
2655 const T1 &Op1) {
2656 return m_CombineAnd(m_Intrinsic(Op0), m_Argument<1>(Op1));
2657}
2658
2659template <Intrinsic::ID IntrID, typename T0, typename T1, typename T2>
2662 return m_CombineAnd(m_Intrinsic(Op0, Op1), m_Argument<2>(Op2));
2663}
2664
2665template <Intrinsic::ID IntrID, typename T0, typename T1, typename T2,
2666 typename T3>
2668m_Intrinsic(const T0 &Op0, const T1 &Op1, const T2 &Op2, const T3 &Op3) {
2669 return m_CombineAnd(m_Intrinsic(Op0, Op1, Op2), m_Argument<3>(Op3));
2670}
2671
2672template <Intrinsic::ID IntrID, typename T0, typename T1, typename T2,
2673 typename T3, typename T4>
2675m_Intrinsic(const T0 &Op0, const T1 &Op1, const T2 &Op2, const T3 &Op3,
2676 const T4 &Op4) {
2677 return m_CombineAnd(m_Intrinsic(Op0, Op1, Op2, Op3),
2678 m_Argument<4>(Op4));
2679}
2680
2681template <Intrinsic::ID IntrID, typename T0, typename T1, typename T2,
2682 typename T3, typename T4, typename T5>
2684m_Intrinsic(const T0 &Op0, const T1 &Op1, const T2 &Op2, const T3 &Op3,
2685 const T4 &Op4, const T5 &Op5) {
2686 return m_CombineAnd(m_Intrinsic(Op0, Op1, Op2, Op3, Op4),
2687 m_Argument<5>(Op5));
2688}
2689
2690
2691template
2693 return m_IntrinsicIntrinsic::bitreverse(Op0);
2694}
2695
2696template
2698 return m_IntrinsicIntrinsic::bswap(Op0);
2699}
2700
2701template
2703 return m_IntrinsicIntrinsic::fabs(Op0);
2704}
2705
2706template
2708 return m_IntrinsicIntrinsic::canonicalize(Op0);
2709}
2710
2711template <typename Opnd0, typename Opnd1>
2713 const Opnd1 &Op1) {
2714 return m_IntrinsicIntrinsic::minnum(Op0, Op1);
2715}
2716
2717template <typename Opnd0, typename Opnd1>
2719 const Opnd1 &Op1) {
2720 return m_IntrinsicIntrinsic::maxnum(Op0, Op1);
2721}
2722
2723template <typename Opnd0, typename Opnd1, typename Opnd2>
2725m_FShl(const Opnd0 &Op0, const Opnd1 &Op1, const Opnd2 &Op2) {
2726 return m_IntrinsicIntrinsic::fshl(Op0, Op1, Op2);
2727}
2728
2729template <typename Opnd0, typename Opnd1, typename Opnd2>
2731m_FShr(const Opnd0 &Op0, const Opnd1 &Op1, const Opnd2 &Op2) {
2732 return m_IntrinsicIntrinsic::fshr(Op0, Op1, Op2);
2733}
2734
2735template
2737 return m_IntrinsicIntrinsic::sqrt(Op0);
2738}
2739
2740template <typename Opnd0, typename Opnd1>
2742 const Opnd1 &Op1) {
2743 return m_IntrinsicIntrinsic::copysign(Op0, Op1);
2744}
2745
2746template
2748 return m_IntrinsicIntrinsic::vector\_reverse(Op0);
2749}
2750
2751
2752
2753
2754
2755
2756template <typename LHS, typename RHS>
2759}
2760
2761
2762
2763template <typename LHS, typename RHS>
2767}
2768
2769template <typename LHS, typename RHS>
2771 const RHS &R) {
2773}
2774
2775
2776template <typename LHS, typename RHS>
2780}
2781
2782
2783template <typename LHS, typename RHS>
2785 const RHS &R) {
2787}
2788
2789
2790template <typename LHS, typename RHS>
2792 const RHS &R) {
2794}
2795
2796
2797template <typename LHS, typename RHS>
2799 const RHS &R) {
2801}
2802
2803
2804template <typename LHS, typename RHS>
2806 const RHS &R) {
2808}
2809
2810
2811template <typename LHS, typename RHS>
2813 const RHS &R) {
2815}
2816
2817
2818template
2822}
2823
2824
2825template
2827 Instruction::Sub,
2831}
2832
2833
2834template <typename LHS, typename RHS>
2838}
2839
2840template <typename LHS, typename RHS>
2844}
2845
2846template <typename LHS, typename RHS>
2850}
2851
2852template <typename LHS, typename RHS>
2856}
2857
2858template <typename LHS, typename RHS>
2867}
2868
2869template <Intrinsic::ID IntrID, typename T0, typename T1>
2873 return m_CombineOr(m_Intrinsic(Op0, Op1),
2874 m_Intrinsic(Op1, Op0));
2875}
2876
2877
2878template <typename LHS, typename RHS>
2882}
2883
2884
2885template <typename LHS, typename RHS>
2889}
2890
2894
2895 template bool match(OpTy *V) {
2896 unsigned TypeSize = V->getType()->getScalarSizeInBits();
2898 return false;
2899
2900 unsigned ShiftWidth = TypeSize - 1;
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2916
2917 return Signum.match(V) && Val.match(Op);
2918 }
2919};
2920
2921
2922
2923
2924
2925
2926
2929}
2930
2934
2935 template bool match(OpTy *V) {
2936 if (auto *I = dyn_cast(V)) {
2937
2938 if (Ind != -1 &&
2939 !(I->getNumIndices() == 1 && I->getIndices()[0] == (unsigned)Ind))
2940 return false;
2941 return Val.match(I->getAggregateOperand());
2942 }
2943 return false;
2944 }
2945};
2946
2947
2948
2949template <int Ind, typename Val_t>
2952}
2953
2954
2955
2956template <typename Val_t>
2959}
2960
2961
2965
2967
2968 template bool match(OpTy *V) {
2969 if (auto *I = dyn_cast(V)) {
2970 return Op0.match(I->getOperand(0)) && Op1.match(I->getOperand(1)) &&
2971 I->getNumIndices() == 1 && Ind == I->getIndices()[0];
2972 }
2973 return false;
2974 }
2975};
2976
2977
2978template <int Ind, typename Val_t, typename Elt_t>
2980 const Elt_t &Elt) {
2982}
2983
2984
2985
2986
2987
2989 template bool match(ITy *V) {
2990 if (m_IntrinsicIntrinsic::vscale().match(V))
2991 return true;
2992
2995 if (auto *GEP = dyn_cast(Ptr)) {
2996 auto *DerefTy =
2997 dyn_cast(GEP->getSourceElementType());
2998 if (GEP->getNumIndices() == 1 && DerefTy &&
2999 DerefTy->getElementType()->isIntegerTy(8) &&
3002 return true;
3003 }
3004 }
3005
3006 return false;
3007 }
3008};
3009
3012}
3013
3014template <typename Opnd0, typename Opnd1>
3017 return m_IntrinsicIntrinsic::vector\_interleave2(Op0, Op1);
3018}
3019
3020template
3022 return m_IntrinsicIntrinsic::vector\_deinterleave2(Op);
3023}
3024
3025template <typename LHS, typename RHS, unsigned Opcode, bool Commutable = false>
3029
3031
3032 template bool match(T *V) {
3033 auto *I = dyn_cast(V);
3034 if ( ||
->getType()->isIntOrIntVectorTy(1))
3035 return false;
3036
3037 if (I->getOpcode() == Opcode) {
3038 auto *Op0 = I->getOperand(0);
3039 auto *Op1 = I->getOperand(1);
3040 return (L.match(Op0) && R.match(Op1)) ||
3041 (Commutable && L.match(Op1) && R.match(Op0));
3042 }
3043
3044 if (auto *Select = dyn_cast(I)) {
3045 auto *Cond = Select->getCondition();
3046 auto *TVal = Select->getTrueValue();
3047 auto *FVal = Select->getFalseValue();
3048
3049
3050
3051 if (Cond->getType() != Select->getType())
3052 return false;
3053
3054 if (Opcode == Instruction::And) {
3055 auto *C = dyn_cast(FVal);
3056 if (C && C->isNullValue())
3057 return (L.match(Cond) && R.match(TVal)) ||
3058 (Commutable && L.match(TVal) && R.match(Cond));
3059 } else {
3060 assert(Opcode == Instruction::Or);
3061 auto *C = dyn_cast(TVal);
3062 if (C && C->isOneValue())
3063 return (L.match(Cond) && R.match(FVal)) ||
3064 (Commutable && L.match(FVal) && R.match(Cond));
3065 }
3066 }
3067
3068 return false;
3069 }
3070};
3071
3072
3073
3074template <typename LHS, typename RHS>
3076 const RHS &R) {
3078}
3079
3080
3082
3083
3084template <typename LHS, typename RHS>
3088}
3089
3090
3091
3092template <typename LHS, typename RHS>
3094 const RHS &R) {
3096}
3097
3098
3100
3101
3102template <typename LHS, typename RHS>
3106}
3107
3108
3109
3110
3111template <typename LHS, typename RHS, bool Commutable = false>
3116}
3117
3118
3120
3121
3122template <typename LHS, typename RHS>
3125}
3126
3127}
3128}
3129
3130#endif
AMDGPU Register Bank Select
This file declares a class to represent arbitrary precision floating point values and provide a varie...
This file implements a class to represent arbitrary precision integral constant values and operations...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
uint64_t IntrinsicInst * II
const SmallVectorImpl< MachineOperand > & Cond
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Class for arbitrary precision integers.
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!...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
@ ICMP_SLT
signed less than
@ ICMP_SLE
signed less or equal
@ FCMP_OLT
0 1 0 0 True if ordered and less than
@ FCMP_ULE
1 1 0 1 True if unordered, less than, or equal
@ FCMP_OGT
0 0 1 0 True if ordered and greater than
@ FCMP_OGE
0 0 1 1 True if ordered and greater than or equal
@ ICMP_UGE
unsigned greater or equal
@ ICMP_UGT
unsigned greater than
@ ICMP_SGT
signed greater than
@ FCMP_ULT
1 1 0 0 True if unordered or less than
@ ICMP_ULT
unsigned less than
@ FCMP_UGT
1 0 1 0 True if unordered or greater than
@ FCMP_OLE
0 1 0 1 True if ordered and less than or equal
@ ICMP_SGE
signed greater or equal
@ ICMP_ULE
unsigned less or equal
@ FCMP_UGE
1 0 1 1 True if unordered, greater than, or equal
An abstraction over a floating-point predicate, and a pack of an integer predicate with samesign info...
static std::optional< CmpPredicate > getMatching(CmpPredicate A, CmpPredicate B)
Compares two CmpPredicates taking samesign into account and returns the canonicalized CmpPredicate if...
static CmpPredicate get(const CmpInst *Cmp)
Do a ICmpInst::getCmpPredicate() or CmpInst::getPredicate(), as appropriate.
static CmpPredicate getSwapped(CmpPredicate P)
Get the swapped predicate of a CmpPredicate.
Base class for aggregate constants (with operands).
A constant value that is initialized with an expression using other constant values.
ConstantFP - Floating Point Values [float, double].
This is the shared class of boolean and integer constants.
This is an important base class in LLVM.
This class represents an Operation in the Expression.
A parsed version of the target data layout string in and methods for querying it.
TypeSize getTypeSizeInBits(Type *Ty) const
Size examples:
static bool compare(const APInt &LHS, const APInt &RHS, ICmpInst::Predicate Pred)
Return result of LHS Pred RHS comparison.
bool isBitwiseLogicOp() const
Return true if this is and/or/xor.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
reference emplace_back(ArgTypes &&... Args)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
The instances of the Type class are immutable: once they are created, they are never changed.
bool isVectorTy() const
True if this is an instance of VectorType.
'undef' values are things that do not have specified contents.
LLVM Value Representation.
Base class of all SIMD vector types.
ElementCount getElementCount() const
Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...
Represents an op.with.overflow intrinsic.
An efficient, type-erasing, non-owning reference to a callable.
@ C
The default llvm calling convention, compatible with C.
TwoOps_match< ValueOpTy, PointerOpTy, Instruction::Store > m_Store(const ValueOpTy &ValueOp, const PointerOpTy &PointerOp)
Matches StoreInst.
cst_pred_ty< is_all_ones > m_AllOnes()
Match an integer or vector with all bits set.
class_match< PoisonValue > m_Poison()
Match an arbitrary poison constant.
cst_pred_ty< is_lowbit_mask > m_LowBitMask()
Match an integer or vector with only the low bit(s) set.
BinaryOp_match< LHS, RHS, Instruction::And > m_And(const LHS &L, const RHS &R)
PtrAdd_match< PointerOpTy, OffsetOpTy > m_PtrAdd(const PointerOpTy &PointerOp, const OffsetOpTy &OffsetOp)
Matches GEP with i8 source element type.
apfloat_match m_APFloatForbidPoison(const APFloat *&Res)
Match APFloat while forbidding poison in splat vector constants.
cst_pred_ty< is_negative > m_Negative()
Match an integer or vector of negative values.
BinaryOp_match< cst_pred_ty< is_all_ones, false >, ValTy, Instruction::Xor, true > m_NotForbidPoison(const ValTy &V)
MaxMin_match< FCmpInst, LHS, RHS, ufmin_pred_ty > m_UnordFMin(const LHS &L, const RHS &R)
Match an 'unordered' floating point minimum function.
PtrToIntSameSize_match< OpTy > m_PtrToIntSameSize(const DataLayout &DL, const OpTy &Op)
BinaryOp_match< LHS, RHS, Instruction::Add > m_Add(const LHS &L, const RHS &R)
class_match< BinaryOperator > m_BinOp()
Match an arbitrary binary operation and ignore it.
m_Intrinsic_Ty< Opnd0 >::Ty m_FCanonicalize(const Opnd0 &Op0)
CmpClass_match< LHS, RHS, FCmpInst > m_FCmp(CmpPredicate &Pred, const LHS &L, const RHS &R)
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.
cst_pred_ty< is_sign_mask > m_SignMask()
Match an integer or vector with only the sign bit(s) set.
OverflowingBinaryOp_match< LHS, RHS, Instruction::Add, OverflowingBinaryOperator::NoUnsignedWrap > m_NUWAdd(const LHS &L, const RHS &R)
BinaryOp_match< LHS, RHS, Instruction::AShr > m_AShr(const LHS &L, const RHS &R)
cstfp_pred_ty< is_inf > m_Inf()
Match a positive or negative infinity FP constant.
m_Intrinsic_Ty< Opnd0 >::Ty m_BitReverse(const Opnd0 &Op0)
BinaryOp_match< LHS, RHS, Instruction::FSub > m_FSub(const LHS &L, const RHS &R)
cst_pred_ty< is_power2 > m_Power2()
Match an integer or vector power-of-2.
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'.
BinaryOp_match< LHS, RHS, Instruction::URem > m_URem(const LHS &L, const RHS &R)
match_combine_or< CastInst_match< OpTy, TruncInst >, OpTy > m_TruncOrSelf(const OpTy &Op)
auto m_LogicalOp()
Matches either L && R or L || R where L and R are arbitrary values.
class_match< Constant > m_Constant()
Match an arbitrary Constant and ignore it.
AllowReassoc_match< T > m_AllowReassoc(const T &SubPattern)
OneOps_match< OpTy, Instruction::Freeze > m_Freeze(const OpTy &Op)
Matches FreezeInst.
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.
cst_pred_ty< is_power2_or_zero > m_Power2OrZero()
Match an integer or vector of 0 or power-of-2 values.
CastInst_match< OpTy, TruncInst > m_Trunc(const OpTy &Op)
Matches Trunc.
BinaryOp_match< LHS, RHS, Instruction::Xor > m_Xor(const LHS &L, const RHS &R)
br_match m_UnconditionalBr(BasicBlock *&Succ)
OverflowingBinaryOp_match< LHS, RHS, Instruction::Sub, OverflowingBinaryOperator::NoSignedWrap > m_NSWSub(const LHS &L, const RHS &R)
specific_intval< false > m_SpecificInt(const APInt &V)
Match a specific integer value or vector with all elements equal to the value.
BinaryOp_match< LHS, RHS, Instruction::FMul > m_FMul(const LHS &L, const RHS &R)
match_combine_or< CastInst_match< OpTy, ZExtInst >, OpTy > m_ZExtOrSelf(const OpTy &Op)
bool match(Val *V, const Pattern &P)
BinOpPred_match< LHS, RHS, is_idiv_op > m_IDiv(const LHS &L, const RHS &R)
Matches integer division operations.
m_Intrinsic_Ty< Opnd0, Opnd1 >::Ty m_FMax(const Opnd0 &Op0, const Opnd1 &Op1)
cst_pred_ty< is_shifted_mask > m_ShiftedMask()
bind_ty< Instruction > m_Instruction(Instruction *&I)
Match an instruction, capturing it if we match.
cstfp_pred_ty< is_any_zero_fp > m_AnyZeroFP()
Match a floating-point negative zero or positive zero.
specificval_ty m_Specific(const Value *V)
Match if we have a specific specified value.
DisjointOr_match< LHS, RHS > m_DisjointOr(const LHS &L, const RHS &R)
constantexpr_match m_ConstantExpr()
Match a constant expression or a constant that contains a constant expression.
BinOpPred_match< LHS, RHS, is_right_shift_op > m_Shr(const LHS &L, const RHS &R)
Matches logical shift operations.
auto m_c_XorLike(const LHS &L, const RHS &R)
Match either (xor L, R), (xor R, L) or (sub nuw R, L) iff R.isMask() Only commutative matcher as the ...
specific_intval< true > m_SpecificIntAllowPoison(const APInt &V)
CmpClass_match< LHS, RHS, ICmpInst, true > m_c_ICmp(CmpPredicate &Pred, const LHS &L, const RHS &R)
Matches an ICmp with a predicate over LHS and RHS in either order.
OverflowingBinaryOp_match< LHS, RHS, Instruction::Add, OverflowingBinaryOperator::NoUnsignedWrap, true > m_c_NUWAdd(const LHS &L, const RHS &R)
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'.
TwoOps_match< Val_t, Idx_t, Instruction::ExtractElement > m_ExtractElt(const Val_t &Val, const Idx_t &Idx)
Matches ExtractElementInst.
cstfp_pred_ty< is_finite > m_Finite()
Match a finite FP constant, i.e.
cst_pred_ty< is_nonnegative > m_NonNegative()
Match an integer or vector of non-negative values.
class_match< ConstantInt > m_ConstantInt()
Match an arbitrary ConstantInt and ignore it.
cst_pred_ty< is_one > m_One()
Match an integer 1 or a vector with all elements equal to 1.
IntrinsicID_match m_Intrinsic()
Match intrinsic calls like this: m_IntrinsicIntrinsic::fabs(m_Value(X))
ThreeOps_match< Cond, LHS, RHS, Instruction::Select > m_Select(const Cond &C, const LHS &L, const RHS &R)
Matches SelectInst.
cstfp_pred_ty< is_neg_zero_fp > m_NegZeroFP()
Match a floating-point negative zero.
match_combine_or< CastInst_match< OpTy, SExtInst >, OpTy > m_SExtOrSelf(const OpTy &Op)
InsertValue_match< Ind, Val_t, Elt_t > m_InsertValue(const Val_t &Val, const Elt_t &Elt)
Matches a single index InsertValue instruction.
match_combine_or< MaxMin_match< FCmpInst, LHS, RHS, ofmin_pred_ty >, MaxMin_match< FCmpInst, LHS, RHS, ufmin_pred_ty > > m_OrdOrUnordFMin(const LHS &L, const RHS &R)
Match an 'ordered' or 'unordered' floating point minimum function.
specific_fpval m_SpecificFP(double V)
Match a specific floating point value or vector with all elements equal to the value.
m_Intrinsic_Ty< Opnd0, Opnd1 >::Ty m_Interleave2(const Opnd0 &Op0, const Opnd1 &Op1)
ExtractValue_match< Ind, Val_t > m_ExtractValue(const Val_t &V)
Match a single index ExtractValue instruction.
BinOpPred_match< LHS, RHS, is_logical_shift_op > m_LogicalShift(const LHS &L, const RHS &R)
Matches logical shift operations.
match_combine_and< LTy, RTy > m_CombineAnd(const LTy &L, const RTy &R)
Combine two pattern matchers matching L && R.
MaxMin_match< ICmpInst, LHS, RHS, smin_pred_ty > m_SMin(const LHS &L, const RHS &R)
cst_pred_ty< is_any_apint > m_AnyIntegralConstant()
Match an integer or vector with any integral constant.
CastInst_match< OpTy, FPToUIInst > m_FPToUI(const OpTy &Op)
m_Intrinsic_Ty< Opnd0 >::Ty m_Sqrt(const Opnd0 &Op0)
bind_ty< WithOverflowInst > m_WithOverflowInst(WithOverflowInst *&I)
Match a with overflow intrinsic, capturing it if we match.
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.
BinaryOp_match< LHS, RHS, Instruction::FAdd > m_FAdd(const LHS &L, const RHS &R)
SpecificCmpClass_match< LHS, RHS, CmpInst > m_SpecificCmp(CmpPredicate MatchPred, const LHS &L, const RHS &R)
match_combine_or< typename m_Intrinsic_Ty< T0, T1 >::Ty, typename m_Intrinsic_Ty< T1, T0 >::Ty > m_c_Intrinsic(const T0 &Op0, const T1 &Op1)
BinaryOp_match< LHS, RHS, Instruction::Mul > m_Mul(const LHS &L, const RHS &R)
deferredval_ty< Value > m_Deferred(Value *const &V)
Like m_Specific(), but works if the specific value to match is determined as part of the same match()...
cst_pred_ty< is_zero_int > m_ZeroInt()
Match an integer 0 or a vector with all elements equal to 0.
apint_match m_APIntAllowPoison(const APInt *&Res)
Match APInt while allowing poison in splat vector constants.
NoWrapTrunc_match< OpTy, TruncInst::NoSignedWrap > m_NSWTrunc(const OpTy &Op)
Matches trunc nsw.
match_combine_or< match_combine_or< CastInst_match< OpTy, ZExtInst >, CastInst_match< OpTy, SExtInst > >, OpTy > m_ZExtOrSExtOrSelf(const OpTy &Op)
OneUse_match< T > m_OneUse(const T &SubPattern)
NNegZExt_match< OpTy > m_NNegZExt(const OpTy &Op)
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.
auto m_LogicalOr()
Matches L || R where L and R are arbitrary values.
BinaryOp_match< cst_pred_ty< is_zero_int >, ValTy, Instruction::Sub > m_Neg(const ValTy &V)
Matches a 'Neg' as 'sub 0, V'.
TwoOps_match< V1_t, V2_t, Instruction::ShuffleVector > m_Shuffle(const V1_t &v1, const V2_t &v2)
Matches ShuffleVectorInst independently of mask value.
match_combine_and< class_match< Constant >, match_unless< constantexpr_match > > m_ImmConstant()
Match an arbitrary immediate Constant and ignore it.
specific_bbval m_SpecificBB(BasicBlock *BB)
Match a specific basic block value.
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.
auto m_GEP(const OperandTypes &...Ops)
Matches GetElementPtrInst.
cst_pred_ty< is_strictlypositive > m_StrictlyPositive()
Match an integer or vector of strictly positive values.
ThreeOps_match< decltype(m_Value()), LHS, RHS, Instruction::Select, true > m_c_Select(const LHS &L, const RHS &R)
Match Select(C, LHS, RHS) or Select(C, RHS, LHS)
CastInst_match< OpTy, FPExtInst > m_FPExt(const OpTy &Op)
OverflowingBinaryOp_match< LHS, RHS, Instruction::Shl, OverflowingBinaryOperator::NoSignedWrap > m_NSWShl(const LHS &L, const RHS &R)
class_match< ConstantFP > m_ConstantFP()
Match an arbitrary ConstantFP and ignore it.
cstfp_pred_ty< is_nonnan > m_NonNaN()
Match a non-NaN FP constant.
m_Intrinsic_Ty< Opnd0, Opnd1, Opnd2, Opnd3 >::Ty m_MaskedLoad(const Opnd0 &Op0, const Opnd1 &Op1, const Opnd2 &Op2, const Opnd3 &Op3)
Matches MaskedLoad Intrinsic.
SpecificCmpClass_match< LHS, RHS, ICmpInst > m_SpecificICmp(CmpPredicate MatchPred, const LHS &L, const RHS &R)
OneOps_match< OpTy, Instruction::Load > m_Load(const OpTy &Op)
Matches LoadInst.
apint_match m_APIntForbidPoison(const APInt *&Res)
Match APInt while forbidding poison in splat vector constants.
CastInst_match< OpTy, ZExtInst > m_ZExt(const OpTy &Op)
Matches ZExt.
OverflowingBinaryOp_match< LHS, RHS, Instruction::Shl, OverflowingBinaryOperator::NoUnsignedWrap > m_NUWShl(const LHS &L, const RHS &R)
cstfp_pred_ty< is_non_zero_not_denormal_fp > m_NonZeroNotDenormalFP()
Match a floating-point non-zero that is not a denormal.
cst_pred_ty< is_all_ones, false > m_AllOnesForbidPoison()
OverflowingBinaryOp_match< LHS, RHS, Instruction::Mul, OverflowingBinaryOperator::NoUnsignedWrap > m_NUWMul(const LHS &L, const RHS &R)
BinaryOp_match< LHS, RHS, Instruction::UDiv > m_UDiv(const LHS &L, const RHS &R)
BinOpPred_match< LHS, RHS, is_bitwiselogic_op, true > m_c_BitwiseLogic(const LHS &L, const RHS &R)
Matches bitwise logic operations in either order.
class_match< UndefValue > m_UndefValue()
Match an arbitrary UndefValue constant.
MaxMin_match< ICmpInst, LHS, RHS, umax_pred_ty > m_UMax(const LHS &L, const RHS &R)
class_match< CmpInst > m_Cmp()
Matches any compare instruction and ignore it.
brc_match< Cond_t, bind_ty< BasicBlock >, bind_ty< BasicBlock > > m_Br(const Cond_t &C, BasicBlock *&T, BasicBlock *&F)
cst_pred_ty< is_negated_power2 > m_NegatedPower2()
Match a integer or vector negated power-of-2.
cst_pred_ty< is_negated_power2_or_zero > m_NegatedPower2OrZero()
Match a integer or vector negated power-of-2.
auto m_c_LogicalOp(const LHS &L, const RHS &R)
Matches either L && R or L || R with LHS and RHS in either order.
NoWrapTrunc_match< OpTy, TruncInst::NoUnsignedWrap > m_NUWTrunc(const OpTy &Op)
Matches trunc nuw.
cst_pred_ty< custom_checkfn< APInt > > m_CheckedInt(function_ref< bool(const APInt &)> CheckFn)
Match an integer or vector where CheckFn(ele) for each element is true.
cst_pred_ty< is_lowbit_mask_or_zero > m_LowBitMaskOrZero()
Match an integer or vector with only the low bit(s) set.
specific_fpval m_FPOne()
Match a float 1.0 or vector with all elements equal to 1.0.
DisjointOr_match< LHS, RHS, true > m_c_DisjointOr(const LHS &L, const RHS &R)
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.
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.
SpecificCmpClass_match< LHS, RHS, FCmpInst > m_SpecificFCmp(CmpPredicate MatchPred, const LHS &L, const RHS &R)
apfloat_match m_APFloatAllowPoison(const APFloat *&Res)
Match APFloat while allowing poison in splat vector constants.
match_combine_or< BinaryOp_match< LHS, RHS, Instruction::Add >, DisjointOr_match< LHS, RHS > > m_AddLike(const LHS &L, const RHS &R)
Match either "add" or "or disjoint".
CastInst_match< OpTy, UIToFPInst > m_UIToFP(const OpTy &Op)
match_combine_or< MaxMin_match< FCmpInst, LHS, RHS, ofmax_pred_ty >, MaxMin_match< FCmpInst, LHS, RHS, ufmax_pred_ty > > m_OrdOrUnordFMax(const LHS &L, const RHS &R)
Match an 'ordered' or 'unordered' floating point maximum function.
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.
CastOperator_match< OpTy, Instruction::BitCast > m_BitCast(const OpTy &Op)
Matches BitCast.
m_Intrinsic_Ty< Opnd0, Opnd1, Opnd2 >::Ty m_FShl(const Opnd0 &Op0, const Opnd1 &Op1, const Opnd2 &Op2)
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)
MaxMin_match< FCmpInst, LHS, RHS, ufmax_pred_ty > m_UnordFMax(const LHS &L, const RHS &R)
Match an 'unordered' floating point maximum function.
match_combine_or< CastInst_match< OpTy, SExtInst >, NNegZExt_match< OpTy > > m_SExtLike(const OpTy &Op)
Match either "sext" or "zext nneg".
cstfp_pred_ty< is_finitenonzero > m_FiniteNonZero()
Match a finite non-zero FP constant.
class_match< UnaryOperator > m_UnOp()
Match an arbitrary unary operation and ignore it.
VScaleVal_match m_VScale()
CastInst_match< OpTy, FPToSIInst > m_FPToSI(const OpTy &Op)
BinaryOp_match< LHS, RHS, Instruction::SDiv > m_SDiv(const LHS &L, const RHS &R)
cstfp_pred_ty< custom_checkfn< APFloat > > m_CheckedFp(function_ref< bool(const APFloat &)> CheckFn)
Match a float or vector where CheckFn(ele) for each element is true.
OverflowingBinaryOp_match< LHS, RHS, Instruction::Sub, OverflowingBinaryOperator::NoUnsignedWrap > m_NUWSub(const LHS &L, const RHS &R)
MaxMin_match< ICmpInst, LHS, RHS, smax_pred_ty > m_SMax(const LHS &L, const RHS &R)
apint_match m_APInt(const APInt *&Res)
Match a ConstantInt or splatted ConstantVector, binding the specified pointer to the contained APInt.
cst_pred_ty< is_maxsignedvalue > m_MaxSignedValue()
Match an integer or vector with values having all bits except for the high bit set (0x7f....
MaxMin_match< FCmpInst, LHS, RHS, ofmax_pred_ty > m_OrdFMax(const LHS &L, const RHS &R)
Match an 'ordered' floating point maximum function.
match_combine_or< OverflowingBinaryOp_match< LHS, RHS, Instruction::Add, OverflowingBinaryOperator::NoSignedWrap >, DisjointOr_match< LHS, RHS > > m_NSWAddLike(const LHS &L, const RHS &R)
Match either "add nsw" or "or disjoint".
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
AnyBinaryOp_match< LHS, RHS, true > m_c_BinOp(const LHS &L, const RHS &R)
Matches a BinaryOperator with LHS and RHS in either order.
Signum_match< Val_t > m_Signum(const Val_t &V)
Matches a signum pattern.
OverflowingBinaryOp_match< LHS, RHS, Instruction::Add, OverflowingBinaryOperator::NoSignedWrap > m_NSWAdd(const LHS &L, const RHS &R)
CastInst_match< OpTy, SIToFPInst > m_SIToFP(const OpTy &Op)
BinaryOp_match< LHS, RHS, Instruction::LShr > m_LShr(const LHS &L, const RHS &R)
CmpClass_match< LHS, RHS, ICmpInst > m_ICmp(CmpPredicate &Pred, const LHS &L, const RHS &R)
Argument_match< Opnd_t > m_Argument(const Opnd_t &Op)
Match an argument.
match_combine_or< CastInst_match< OpTy, ZExtInst >, CastInst_match< OpTy, SExtInst > > m_ZExtOrSExt(const OpTy &Op)
Exact_match< T > m_Exact(const T &SubPattern)
FNeg_match< OpTy > m_FNeg(const OpTy &X)
Match 'fneg X' as 'fsub -0.0, X'.
BinOpPred_match< LHS, RHS, is_shift_op > m_Shift(const LHS &L, const RHS &R)
Matches shift operations.
cstfp_pred_ty< is_pos_zero_fp > m_PosZeroFP()
Match a floating-point positive zero.
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.
LogicalOp_match< LHS, RHS, Instruction::And, true > m_c_LogicalAnd(const LHS &L, const RHS &R)
Matches L && R with LHS and RHS in either order.
BinaryOp_match< LHS, RHS, Instruction::Shl > m_Shl(const LHS &L, const RHS &R)
cstfp_pred_ty< is_non_zero_fp > m_NonZeroFP()
Match a floating-point non-zero.
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.
BinaryOp_match< LHS, RHS, Instruction::FDiv > m_FDiv(const LHS &L, const RHS &R)
m_Intrinsic_Ty< Opnd0 >::Ty m_VecReverse(const Opnd0 &Op0)
BinOpPred_match< LHS, RHS, is_irem_op > m_IRem(const LHS &L, const RHS &R)
Matches integer remainder operations.
apfloat_match m_APFloat(const APFloat *&Res)
Match a ConstantFP or splatted ConstantVector, binding the specified pointer to the contained APFloat...
auto m_LogicalAnd()
Matches L && R where L and R are arbitrary values.
MaxMin_match< FCmpInst, LHS, RHS, ofmin_pred_ty > m_OrdFMin(const LHS &L, const RHS &R)
Match an 'ordered' floating point minimum function.
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)
m_Intrinsic_Ty< Opnd0, Opnd1, Opnd2 >::Ty m_FShr(const Opnd0 &Op0, const Opnd1 &Op1, const Opnd2 &Op2)
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.: m_SelectCst<-1, 0>(m_Value(V))
BinaryOp_match< LHS, RHS, Instruction::FRem > m_FRem(const LHS &L, const RHS &R)
CastInst_match< OpTy, FPTruncInst > m_FPTrunc(const OpTy &Op)
class_match< BasicBlock > m_BasicBlock()
Match an arbitrary basic block value and ignore it.
BinaryOp_match< LHS, RHS, Instruction::SRem > m_SRem(const LHS &L, const RHS &R)
auto m_Undef()
Match an arbitrary undef constant.
cst_pred_ty< is_nonpositive > m_NonPositive()
Match an integer or vector of non-positive values.
cstfp_pred_ty< is_nan > m_NaN()
Match an arbitrary NaN constant.
BinaryOp_match< cst_pred_ty< is_all_ones >, ValTy, Instruction::Xor, true > m_Not(const ValTy &V)
Matches a 'Not' as 'xor V, -1' or 'xor -1, V'.
m_Intrinsic_Ty< Opnd0, Opnd1 >::Ty m_FMin(const Opnd0 &Op0, const Opnd1 &Op1)
BinaryOp_match< LHS, RHS, Instruction::Or > m_Or(const LHS &L, const RHS &R)
m_Intrinsic_Ty< Opnd0 >::Ty m_BSwap(const Opnd0 &Op0)
CastInst_match< OpTy, SExtInst > m_SExt(const OpTy &Op)
Matches SExt.
is_zero m_Zero()
Match any null constant or a vector with all elements equal to 0.
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.
match_combine_or< OverflowingBinaryOp_match< LHS, RHS, Instruction::Add, OverflowingBinaryOperator::NoUnsignedWrap >, DisjointOr_match< LHS, RHS > > m_NUWAddLike(const LHS &L, const RHS &R)
Match either "add nuw" or "or disjoint".
CastOperator_match< OpTy, Instruction::IntToPtr > m_IntToPtr(const OpTy &Op)
Matches IntToPtr.
BinOpPred_match< LHS, RHS, is_bitwiselogic_op > m_BitwiseLogic(const LHS &L, const RHS &R)
Matches bitwise logic operations.
LogicalOp_match< LHS, RHS, Instruction::Or, true > m_c_LogicalOr(const LHS &L, const RHS &R)
Matches L || R with LHS and RHS in either order.
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.
SpecificCmpClass_match< LHS, RHS, ICmpInst, true > m_c_SpecificICmp(CmpPredicate MatchPred, const LHS &L, const RHS &R)
ElementWiseBitCast_match< OpTy > m_ElementWiseBitCast(const OpTy &Op)
m_Intrinsic_Ty< Opnd0 >::Ty m_FAbs(const Opnd0 &Op0)
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.
m_Intrinsic_Ty< Opnd0, Opnd1 >::Ty m_CopySign(const Opnd0 &Op0, const Opnd1 &Op1)
CastOperator_match< OpTy, Instruction::PtrToInt > m_PtrToInt(const OpTy &Op)
Matches PtrToInt.
OverflowingBinaryOp_match< LHS, RHS, Instruction::Mul, OverflowingBinaryOperator::NoSignedWrap > m_NSWMul(const LHS &L, const RHS &R)
BinaryOp_match< LHS, RHS, Instruction::Sub > m_Sub(const LHS &L, const RHS &R)
MaxMin_match< ICmpInst, LHS, RHS, umin_pred_ty > m_UMin(const LHS &L, const RHS &R)
cstfp_pred_ty< is_noninf > m_NonInf()
Match a non-infinity FP constant, i.e.
m_Intrinsic_Ty< Opnd >::Ty m_Deinterleave2(const Opnd &Op)
m_Intrinsic_Ty< Opnd0, Opnd1, Opnd2, Opnd3 >::Ty m_MaskedGather(const Opnd0 &Op0, const Opnd1 &Op1, const Opnd2 &Op2, const Opnd3 &Op3)
Matches MaskedGather Intrinsic.
match_unless< Ty > m_Unless(const Ty &M)
Match if the inner matcher does NOT match.
match_combine_or< LTy, RTy > m_CombineOr(const LTy &L, const RTy &R)
Combine two pattern matchers matching L || R.
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.
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
DWARFExpression::Operation Op
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
AllowReassoc_match(const SubPattern_t &SP)
AnyBinaryOp_match(const LHS_t &LHS, const RHS_t &RHS)
Matches instructions with Opcode and any number of operands.
std::enable_if_t< Idx==Last, bool > match_operands(const Instruction *I)
std::enable_if_t< Idx !=Last, bool > match_operands(const Instruction *I)
std::tuple< OperandTypes... > Operands
AnyOps_match(const OperandTypes &...Ops)
AnyUnaryOp_match(const OP_t &X)
Argument_match(unsigned OpIdx, const Opnd_t &V)
BinOpPred_match(const LHS_t &LHS, const RHS_t &RHS)
BinaryOp_match(const LHS_t &LHS, const RHS_t &RHS)
bool match(unsigned Opc, OpTy *V)
CastInst_match(const Op_t &OpMatch)
CastOperator_match(const Op_t &OpMatch)
CmpClass_match(CmpPredicate &Pred, const LHS_t &LHS, const RHS_t &RHS)
CmpClass_match(const LHS_t &LHS, const RHS_t &RHS)
DisjointOr_match(const LHS &L, const RHS &R)
ElementWiseBitCast_match(const Op_t &OpMatch)
Exact_match(const SubPattern_t &SP)
FNeg_match(const Op_t &Op)
Matcher for a single index InsertValue instruction.
InsertValue_match(const T0 &Op0, const T1 &Op1)
IntrinsicID_match(Intrinsic::ID IntrID)
LogicalOp_match(const LHS &L, const RHS &R)
MaxMin_match(const LHS_t &LHS, const RHS_t &RHS)
NNegZExt_match(const Op_t &OpMatch)
NoWrapTrunc_match(const Op_t &OpMatch)
Matches instructions with Opcode and three operands.
OneOps_match(const T0 &Op1)
OneUse_match(const SubPattern_t &SP)
OverflowingBinaryOp_match(const LHS_t &LHS, const RHS_t &RHS)
PtrAdd_match(const PointerOpTy &PointerOp, const OffsetOpTy &OffsetOp)
PtrToIntSameSize_match(const DataLayout &DL, const Op_t &OpMatch)
Shuffle_match(const T0 &Op1, const T1 &Op2, const T2 &Mask)
Signum_match(const Opnd_t &V)
SpecificBinaryOp_match(unsigned Opcode, const LHS_t &LHS, const RHS_t &RHS)
SpecificCmpClass_match(CmpPredicate Pred, const LHS_t &LHS, const RHS_t &RHS)
const CmpPredicate Predicate
Matches instructions with Opcode and three operands.
ThreeOps_match(const T0 &Op1, const T1 &Op2, const T2 &Op3)
Matches instructions with Opcode and three operands.
TwoOps_match(const T0 &Op1, const T1 &Op2)
UAddWithOverflow_match(const LHS_t &L, const RHS_t &R, const Sum_t &S)
Matches patterns for vscale.
XorLike_match(const LHS &L, const RHS &R)
This helper class is used to match scalar and vector constants that satisfy a specified predicate,...
apf_pred_ty(const APFloat *&R)
apfloat_match(const APFloat *&Res, bool AllowPoison)
This helper class is used to match scalar and vector constants that satisfy a specified predicate,...
api_pred_ty(const APInt *&R)
apint_match(const APInt *&Res, bool AllowPoison)
bind_const_intval_ty(uint64_t &V)
br_match(BasicBlock *&Succ)
brc_match(const Cond_t &C, const TrueBlock_t &t, const FalseBlock_t &f)
This helper class is used to match constant scalars, vector splats, and fixed width vectors that sati...
bool isValue(const APTy &C)
function_ref< bool(const APTy &)> CheckFn
Stores a reference to the Value *, not the Value * itself, thus can be used in commutative matchers.
deferredval_ty(Class *const &V)
bool isValue(const APInt &C)
bool isValue(const APInt &C)
bool isValue(const APInt &C)
bool isValue(const APFloat &C)
bool isOpType(unsigned Opcode)
bool isValue(const APFloat &C)
bool isValue(const APFloat &C)
bool isOpType(unsigned Opcode)
bool isValue(const APFloat &C)
bool isOpType(unsigned Opcode)
bool isOpType(unsigned Opcode)
bool isValue(const APInt &C)
bool isValue(const APInt &C)
bool isValue(const APInt &C)
bool isValue(const APFloat &C)
bool isValue(const APFloat &C)
bool isValue(const APInt &C)
bool isValue(const APInt &C)
bool isValue(const APInt &C)
bool isValue(const APFloat &C)
bool isValue(const APFloat &C)
bool isValue(const APFloat &C)
bool isValue(const APFloat &C)
bool isValue(const APInt &C)
bool isValue(const APInt &C)
bool isValue(const APInt &C)
bool isValue(const APFloat &C)
bool isValue(const APInt &C)
bool isValue(const APInt &C)
bool isOpType(unsigned Opcode)
bool isOpType(unsigned Opcode)
bool isValue(const APInt &C)
bool isValue(const APInt &C)
bool isValue(const APInt &C)
bool isValue(const APInt &C)
Intrinsic matches are combinations of ID matchers, and argument matchers.
bool match(ArrayRef< int > Mask)
ArrayRef< int > & MaskRef
m_Mask(ArrayRef< int > &MaskRef)
bool match(ArrayRef< int > Mask)
m_SpecificMask(ArrayRef< int > Val)
bool match(ArrayRef< int > Mask)
m_SplatOrPoisonMask(int &SplatIndex)
bool match(ArrayRef< int > Mask)
match_combine_and(const LTy &Left, const RTy &Right)
match_combine_or(const LTy &Left, const RTy &Right)
match_unless(const Ty &Matcher)
Helper class for identifying ordered max predicates.
static bool match(FCmpInst::Predicate Pred)
Helper class for identifying ordered min predicates.
static bool match(FCmpInst::Predicate Pred)
Helper class for identifying signed max predicates.
static bool match(ICmpInst::Predicate Pred)
Helper class for identifying signed min predicates.
static bool match(ICmpInst::Predicate Pred)
Match a specified basic block value.
specific_bbval(BasicBlock *Val)
Match a specified floating point value or vector of all elements of that value.
specific_intval64(uint64_t V)
Match a specified integer value or vector of all elements of that value.
specific_intval(const APInt &V)
Match a specified Value*.
specificval_ty(const Value *V)
Helper class for identifying unordered max predicates.
static bool match(FCmpInst::Predicate Pred)
Helper class for identifying unordered min predicates.
static bool match(FCmpInst::Predicate Pred)
Helper class for identifying unsigned max predicates.
static bool match(ICmpInst::Predicate Pred)
Helper class for identifying unsigned min predicates.
static bool match(ICmpInst::Predicate Pred)
static bool check(const Value *V)