[PATCH] D144329: [InstCombine] canonicalize "extract lowest set bit" away from cttz intrinsic
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 19 07:31:29 PST 2023
spatel added a comment.
In D144329#4136980 <https://reviews.llvm.org/D144329#4136980>, @nikic wrote:
> Worth noting that for pow2 detection we canonicalize in the reverse direction (towards ctpop and icmp), and I don't quite remember why we ended up going with that somewhat unusual choice.
For this pattern:
(-A & A) != A --> ctpop(A) > 1
It was a combination of less instructions, less uses, and being the more obvious spelling for, "Is more than one bit set?"
We can make the same argument about cttz with the low-set-bit in this pattern, but it's the same number of instructions and has the other noted benefits. Both ways have advantages, so we just have to make a choice.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D144329/new/
https://reviews.llvm.org/D144329
More information about the llvm-commits
mailing list