@@ -350,8 +350,9 @@ template <int64_t Val> inline constantint_match<Val> m_ConstantInt() {
350
350
351
351
// / This helper class is used to match constant scalars, vector splats,
352
352
// / and fixed width vectors that satisfy a specified predicate.
353
- // / For fixed width vector constants, poison elements are ignored.
354
- template <typename Predicate, typename ConstantVal>
353
+ // / For fixed width vector constants, poison elements are ignored if AllowPoison
354
+ // / is true.
355
+ template <typename Predicate, typename ConstantVal, bool AllowPoison>
355
356
struct cstval_pred_ty : public Predicate {
356
357
template <typename ITy> bool match (ITy *V) {
357
358
if (const auto *CV = dyn_cast<ConstantVal>(V))
@@ -374,7 +375,7 @@ struct cstval_pred_ty : public Predicate {
374
375
Constant *Elt = C->getAggregateElement (i);
375
376
if (!Elt)
376
377
return false ;
377
- if (isa<PoisonValue>(Elt))
378
+ if (AllowPoison && isa<PoisonValue>(Elt))
378
379
continue ;
379
380
auto *CV = dyn_cast<ConstantVal>(Elt);
380
381
if (!CV || !this ->isValue (CV->getValue ()))
@@ -389,12 +390,13 @@ struct cstval_pred_ty : public Predicate {
389
390
};
390
391
391
392
// / specialization of cstval_pred_ty for ConstantInt
392
- template <typename Predicate>
393
- using cst_pred_ty = cstval_pred_ty<Predicate, ConstantInt>;
393
+ template <typename Predicate, bool AllowPoison = true >
394
+ using cst_pred_ty = cstval_pred_ty<Predicate, ConstantInt, AllowPoison >;
394
395
395
396
// / specialization of cstval_pred_ty for ConstantFP
396
397
template <typename Predicate>
397
- using cstfp_pred_ty = cstval_pred_ty<Predicate, ConstantFP>;
398
+ using cstfp_pred_ty = cstval_pred_ty<Predicate, ConstantFP,
399
+ /* AllowPoison=*/ true >;
398
400
399
401
// / This helper class is used to match scalar and vector constants that
400
402
// / satisfy a specified predicate, and bind them to an APInt.
@@ -484,6 +486,10 @@ inline cst_pred_ty<is_all_ones> m_AllOnes() {
484
486
return cst_pred_ty<is_all_ones>();
485
487
}
486
488
489
+ inline cst_pred_ty<is_all_ones, false > m_AllOnesForbidPoison () {
490
+ return cst_pred_ty<is_all_ones, false >();
491
+ }
492
+
487
493
struct is_maxsignedvalue {
488
494
bool isValue (const APInt &C) { return C.isMaxSignedValue (); }
489
495
};
@@ -2596,6 +2602,13 @@ m_Not(const ValTy &V) {
2596
2602
return m_c_Xor (m_AllOnes (), V);
2597
2603
}
2598
2604
2605
+ template <typename ValTy>
2606
+ inline BinaryOp_match<cst_pred_ty<is_all_ones, false >, ValTy, Instruction::Xor,
2607
+ true >
2608
+ m_NotForbidPoison (const ValTy &V) {
2609
+ return m_c_Xor (m_AllOnesForbidPoison (), V);
2610
+ }
2611
+
2599
2612
// / Matches an SMin with LHS and RHS in either order.
2600
2613
template <typename LHS, typename RHS>
2601
2614
inline MaxMin_match<ICmpInst, LHS, RHS, smin_pred_ty, true >
0 commit comments