[PATCH] D140935: [InstCombine] C - cttz(X) => ctlz(X) if C is bitwidth

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 4 02:26:12 PST 2023


nikic requested changes to this revision.
nikic added a comment.
This revision now requires changes to proceed.

In D140935#4025375 <https://reviews.llvm.org/D140935#4025375>, @RKSimon wrote:

> Won't this only work if only a single bit is set (pow2)?

That, and it's off by one (the constant needs to be bitwidth-1, not bitwidth). The right transform would be this: https://alive2.llvm.org/ce/z/v588Fk


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140935



More information about the llvm-commits mailing list