[PATCH] D33125: Introduce isoneof<T0, T1, ...> as an extension of isa<T>

serge via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 1 09:18:14 PDT 2017


serge-sans-paille added a comment.

@chandlerc the extra complexity is worth 15 lines of codes, and thanks to your ``anyof<>`` proposal, it's very local.

As you noted, the benefits of the ``anyof<...>`` syntax compared to a chaining of ``||`` is not on the performance side. It's slightly more concise, and when I did the full replacement, I often met example like this:

  if(isa<T0>(Inst->getOperand(0)) || isa<T1>(Inst->getOperand(0))
      /* stuff*/;

With this proposal, it naturally turns into

  if(isa<anyof<T0, T1>>(Inst->getOperand(0)))
      /* stuff*/;

which avoids the redundancy. Not a big deal yet it avoids some kind of redundancy. In other examples, you had

  if (isa<T0>(V0) || isa <T1>(V1>)) 
      /* stuff*/

which cannot be reduced, but could be confusing while introducing ``anyof<>`` make the two situations visually different.

Again I admit the added value is arguable, so let see what the other think about it.


Repository:
  rL LLVM

https://reviews.llvm.org/D33125





More information about the llvm-commits mailing list