[llvm] [InstCombine] Fold `(ct{t, l}z Pow2)` -> `Log2(Pow2)` (PR #122620)

via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 12 08:26:11 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()) {
----------------
goldsteinn wrote:

:/ fixed....

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


More information about the llvm-commits mailing list