[all-commits] [llvm/llvm-project] 1220c9: [InstCombine] Fold the `log2_ceil` idiom (#76661)
Yingwei Zheng via All-commits
all-commits at lists.llvm.org
Wed Jan 10 04:24:35 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 1220c9bafc11a3edf96921a8ab892d777b7ed06b
https://github.com/llvm/llvm-project/commit/1220c9bafc11a3edf96921a8ab892d777b7ed06b
Author: Yingwei Zheng <dtcxzyw2333 at gmail.com>
Date: 2024-01-10 (Wed, 10 Jan 2024)
Changed paths:
M llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
A llvm/test/Transforms/InstCombine/fold-log2-ceil-idiom.ll
Log Message:
-----------
[InstCombine] Fold the `log2_ceil` idiom (#76661)
This patch folds the `log2_ceil` idiom:
```
(BW - ctlz(A)) + (is_power2(A) ? 0 : 1) ->
zext(ctpop(A) >u/!= 1) + (ctlz(A, true) ^ (BW - 1)) (canonical form) ->
BW - ctlz(A - 1, false)
```
Alive2: https://alive2.llvm.org/ce/z/6mSbdi
More information about the All-commits
mailing list