[PATCH] D132237: [AArch64] expand is-power-of-2 pattern that uses popcount

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 21 06:03:35 PDT 2022


spatel added inline comments.


================
Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:18593-18594
 
+  // (ctpop x) == 1 --> (x != 0) && ((x & x-1) == 0)
+  // (ctpop x) != 1 --> (x == 0) || ((x & x-1) != 0)
+  if (LHS.getOpcode() == ISD::CTPOP && LHS.hasOneUse() && isOneConstant(RHS) &&
----------------
davezarzycki wrote:
> For your consideration:
> 
> (ctpop x) <= 1 --> (x & x-1) == 0
> (ctpop x) > 1 --> (x & x-1) != 0
Ah, I forgot that we added a popcount target hook with D89952. Do you think we should use that for this pattern too? Or did you decide it wasn't worth pursuing (D91093)?

I'm looking back at the comments in:
https://bugs.llvm.org/show_bug.cgi?id=47825
...and we cited AArch64 scalar custom lowering/combining as a missing piece. But we could adapt the TLI hook if that seems better.


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

https://reviews.llvm.org/D132237



More information about the llvm-commits mailing list