[PATCH] D141990: [InstCombine] Add transform ctpop(X) -> 1 iff X is non-zero power of 2

David Majnemer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 18 09:27:31 PST 2023


majnemer added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp:623-627
 
+  // ctpop(X) -> 1 iff X is non-zero power of 2. Maybe better also to just
+  // return icmp X, 0 if its known power of 2 but not known non-zero.
+  if (IC.isKnownToBeAPowerOfTwo(Op0, /* OrZero */ false))
+    return IC.replaceInstUsesWith(II, ConstantInt::get(Ty, 1));
----------------
Should this be in simplifyIntrinsic?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141990/new/

https://reviews.llvm.org/D141990



More information about the llvm-commits mailing list