in ctpop(X) eq/ne 1 or ctpop(X) ugt/ule 1, if there is any
known-bit in X, instead of going through ctpop, we can just test
if there are any other known bits in X. If there are, X is not a
power of 2. If there aren't, X is a power of 2.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | ||
---|---|---|
6973 | Shouldn't this code be in foldICmpIntrinsicWithConstant? | |
6975 | Do you think it would make sense to canonicalize ctpop(X) < 2 to ctpop(X) == 1 if isKnownNonZero(X)? Or does this run into the issue that ctpop(X) < 2 is actually the cheaper check once expanded, and we might not recover the non-zero fact at that point anymore? | |
6992 |
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | ||
---|---|---|
6975 | ctpop(X) < 2 is cheaper for the backend and indeed isknownnonzero is often 'lost' by the backend. |
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | ||
---|---|---|
3777–3796 | If you rebase, there should be a switch here where you can handle both equality and non-equality comparisons in one place. |
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | ||
---|---|---|
3777–3796 | Hmm? Don't see any change to the function signiture on master. |
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | ||
---|---|---|
3777–3796 | I'm referring to the switch directly above. |
Bah, sorry must have copied wrong link. Updated summary with: https://alive2.llvm.org/ce/z/eLMJgU
Unnecessary llvm prefix.