[llvm] [InstCombine] Fold `(ct{t, l}z Pow2)` -> `Log2(Pow2)` (PR #122620)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 12 08:18:03 PST 2025
================
@@ -588,6 +588,22 @@ static Instruction *foldCttzCtlz(IntrinsicInst &II, InstCombinerImpl &IC) {
}
}
+ // cttz(Pow2) -> Log2(Pow2)
+ // ctlz(Pow2) -> BitWidth - 1 - Log2(Pow2)
+ if (IsTZ || II.hasOneUse()) {
----------------
nikic wrote:
Your new condition effectively drops ctlz entirely :)
https://github.com/llvm/llvm-project/pull/122620
More information about the llvm-commits
mailing list