@@ -184,6 +184,7 @@ m_scev_PtrToInt(const Op0_t &Op0) {
184184
185185// / Match a binary SCEV.
186186template <typename SCEVTy, typename Op0_t, typename Op1_t,
187+ SCEV::NoWrapFlags WrapFlags = SCEV::FlagAnyWrap,
187188 bool Commutable = false >
188189struct SCEVBinaryExpr_match {
189190 Op0_t Op0;
@@ -192,6 +193,10 @@ struct SCEVBinaryExpr_match {
192193 SCEVBinaryExpr_match (Op0_t Op0, Op1_t Op1) : Op0(Op0), Op1(Op1) {}
193194
194195 bool match (const SCEV *S) const {
196+ if (auto WrappingS = dyn_cast<SCEVNAryExpr>(S))
197+ if (WrappingS->getNoWrapFlags (WrapFlags) != WrapFlags)
198+ return false ;
199+
195200 auto *E = dyn_cast<SCEVTy>(S);
196201 return E && E->getNumOperands () == 2 &&
197202 ((Op0.match (E->getOperand (0 )) && Op1.match (E->getOperand (1 ))) ||
@@ -201,10 +206,12 @@ struct SCEVBinaryExpr_match {
201206};
202207
203208template <typename SCEVTy, typename Op0_t, typename Op1_t,
209+ SCEV::NoWrapFlags WrapFlags = SCEV::FlagAnyWrap,
204210 bool Commutable = false >
205- inline SCEVBinaryExpr_match<SCEVTy, Op0_t, Op1_t, Commutable>
211+ inline SCEVBinaryExpr_match<SCEVTy, Op0_t, Op1_t, WrapFlags, Commutable>
206212m_scev_Binary (const Op0_t &Op0, const Op1_t &Op1) {
207- return SCEVBinaryExpr_match<SCEVTy, Op0_t, Op1_t, Commutable>(Op0, Op1);
213+ return SCEVBinaryExpr_match<SCEVTy, Op0_t, Op1_t, WrapFlags, Commutable>(Op0,
214+ Op1);
208215}
209216
210217template <typename Op0_t, typename Op1_t>
@@ -220,9 +227,17 @@ m_scev_Mul(const Op0_t &Op0, const Op1_t &Op1) {
220227}
221228
222229template <typename Op0_t, typename Op1_t>
223- inline SCEVBinaryExpr_match<SCEVMulExpr, Op0_t, Op1_t, true >
230+ inline SCEVBinaryExpr_match<SCEVMulExpr, Op0_t, Op1_t, SCEV::FlagAnyWrap, true >
224231m_scev_c_Mul (const Op0_t &Op0, const Op1_t &Op1) {
225- return m_scev_Binary<SCEVMulExpr, Op0_t, Op1_t, true >(Op0, Op1);
232+ return m_scev_Binary<SCEVMulExpr, Op0_t, Op1_t, SCEV::FlagAnyWrap, true >(Op0,
233+ Op1);
234+ }
235+
236+ template <typename Op0_t, typename Op1_t>
237+ inline SCEVBinaryExpr_match<SCEVMulExpr, Op0_t, Op1_t, SCEV::FlagNUW, true >
238+ m_scev_c_NUWMul (const Op0_t &Op0, const Op1_t &Op1) {
239+ return m_scev_Binary<SCEVMulExpr, Op0_t, Op1_t, SCEV::FlagNUW, true >(Op0,
240+ Op1);
226241}
227242
228243template <typename Op0_t, typename Op1_t>
0 commit comments