[PATCH] D45173: [InstCombine] Recognize idioms for ctpop and ctlz
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 3 13:20:46 PDT 2018
craig.topper added inline comments.
================
Comment at: lib/Transforms/AggressiveInstCombine/BitCountCombine.cpp:52
+Value *BitCountCombine::matchCtpopW(Instruction &In, unsigned BW) {
+ auto matchStep = [] (Value *V, unsigned S, APInt M, bool ShiftAlone)
+ -> Value* {
----------------
Should take APInt M by const reference if possible to avoid a costly copy if its larger than 64 bits.
================
Comment at: lib/Transforms/AggressiveInstCombine/BitCountCombine.cpp:73
+ }
+ if (!APInt::isSameValue(M, *P))
+ return nullptr;
----------------
APInt::isSameValue is most useful when the APInts have different widths. Is that the case here? If not we should just use operator==
================
Comment at: lib/Transforms/AggressiveInstCombine/BitCountCombine.cpp:194
+
+ IntegerType *Ty = cast<IntegerType>(V->getType());
+ KnownBits K(Ty->getBitWidth());
----------------
What if the ctpop returns a vector type?
Repository:
rL LLVM
https://reviews.llvm.org/D45173
More information about the llvm-commits
mailing list