[llvm] [PatternMatching] Add generic API for matching constants using custom conditions (PR #85676)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 25 08:51:14 PDT 2024
================
@@ -7144,33 +7144,37 @@ Instruction *InstCombinerImpl::foldICmpCommutative(ICmpInst::Predicate Pred,
// Folding (X / Y) pred X => X swap(pred) 0 for constant Y other than 0 or 1
{
- const APInt *Divisor;
- if (match(Op0, m_UDiv(m_Specific(Op1), m_APInt(Divisor))) &&
- Divisor->ugt(1)) {
+ if (match(Op0,
+ m_UDiv(m_Specific(Op1), m_CheckedInt([](const APInt &Divisor) {
+ return Divisor.ugt(1);
+ })))) {
----------------
goldsteinn wrote:
I don't think it would be ugly if we made the lambda a helper. Ill do so.
https://github.com/llvm/llvm-project/pull/85676
More information about the llvm-commits
mailing list