[PATCH] D122077: [InstCombine] Fold (ctpop(X) == 1) | (X == 0) into ctpop(X) < 2

Hirochika Matsumoto via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 23 13:18:22 PDT 2022


hkmatsumoto marked 3 inline comments as done.
hkmatsumoto added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:921
+  if (IsAnd &&
+      match(Cmp0, m_ICmp(Pred0, m_Intrinsic<Intrinsic::ctpop>(m_Value(X)),
+                         m_SpecificInt(1))) &&
----------------
craig.topper wrote:
> Since the m_ICmp matches are the same for And/Or can we share those and possibly early out from the function if they don't match. Then only use `IsAnd` to check the predicates and control the what we emit?
You are definitely right! Changed accordingly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122077



More information about the cfe-commits mailing list