[PATCH] D93888: [GVN] If zext X == N or sext X == N, then X == trunc N.

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 29 09:49:33 PST 2020


nikic added a reviewer: nikic.
nikic added a comment.

I'm not convinced that GVN is really the right place to address this, because it is not the only place that would have to understand this pattern. For example LVI does the inverse reasoning (X == C to zext X == zext C), but not this one. For NewGVN and IPSCCP PredicateInfo would have to handle it, and I'm pretty sure we want to avoid that.

The InstCombine patch that moves the zext into the switch seems like the more promising direction to me. Generally, if we have `switch (f(x)) case C` it makes sense to convert it to `switch (x) case f^{-1}(C)` for invertible `f`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93888/new/

https://reviews.llvm.org/D93888



More information about the llvm-commits mailing list