[PATCH] D122757: [InstCombine] Fold (ctpop(X) == N) || (X != 0) into X != 0 where N > 0
Hirochika Matsumoto via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 30 12:16:29 PDT 2022
hkmatsumoto added a comment.
Proof (This is first time writing proof in English, so sorry for any inconveniences)
Suppose X: i32
1. For 0 < N < 32
- ctpop(X) == N --> X > 0.
- Hence (ctpop(X) == N) || (X != 0) --> X > 0 || X != 0.
- Intuitively X > 0 || X != 0 --> X != 0.
2. For 32 < N
- ctpop(X) == N is always false, because of the semantics of ctpop().
- Hence (ctpop(X) == N) || (X != 0) --> false || X != 0 --> X != 0.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D122757/new/
https://reviews.llvm.org/D122757
More information about the llvm-commits
mailing list