[PATCH] D24419: [InstCombine] use commutative matchers for patterns with commutative operators

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 8 07:03:29 PST 2016


spatel added a comment.

Ping.

https://reviews.llvm.org/D27531 reminded me of this patch. Another possibility (this is in InstSimplify) looks like this:

  if (auto *ICILHS = dyn_cast<ICmpInst>(Op0)) {
    if (auto *ICIRHS = dyn_cast<ICmpInst>(Op1)) {
      if (Value *V = SimplifyAndOfICmps(ICILHS, ICIRHS))
        return V;
      if (Value *V = SimplifyAndOfICmps(ICIRHS, ICILHS))
        return V;
    }
  }

So put a pile of folds in a helper function and then call it with all permutations of the commutative parameters. Better than using m_c_*?


https://reviews.llvm.org/D24419





More information about the llvm-commits mailing list