[clang] [InstCombine] Convert or concat to fshl if opposite or concat exists (PR #68502)

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 24 03:30:38 PDT 2023


nikic wrote:

> See most recent comments about missing tests. That being said code looks functionally correct to me. Still not 100% sure this is a desirable change. Will defer to @nikic about that.

I'm also skeptical about accepting this optimization. Looking at the motivating case in https://github.com/llvm/llvm-project/pull/68502#discussion_r1351618002, this seems like a bad approach to the problem: It means that in order to fold the pattern to `bitreverse(%xy)`, we must just so happen to have the right `%xy` lying around in the IR, even though it doesn't have any relation to the main pattern (it's not used inside it, just injected via an extra use). It sounds to me like the better way to handle that case would be to support matching a variant of plain bitreverse in the form of `bitreverse(rot(%yx))`.

Replacing the `rot(%yx)` by `%xy` is then an extra optimization opportunity, but it's no longer a precondition to performing the transform.

https://github.com/llvm/llvm-project/pull/68502


More information about the cfe-commits mailing list