[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
Fri Aug 19 08:20:12 PDT 2022


spatel created this revision.
spatel added reviewers: dmgreen, paulwalker-arm, fhahn, efriedma.
Herald added subscribers: hiraditya, kristof.beyls, mcrosier.
Herald added a project: All.
spatel requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

(ctpop x) == 1 --> (x != 0) && ((x & x-1) == 0)

This duplicates code in generic target combining. That code doesn't fire for AArch64 because we have custom lowering for CTPOP alone, so the generic expansion assumes the target can do better in that case.

Another potential fix would be to add a TLI hook around the generic combine, but I didn't see any other targets or patterns that would benefit.

This should fix issue #57225 <https://github.com/llvm/llvm-project/issues/57225>


https://reviews.llvm.org/D132237

Files:
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/test/CodeGen/AArch64/arm64-popcnt.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132237.454006.patch
Type: text/x-patch
Size: 4301 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220819/54595674/attachment.bin>


More information about the llvm-commits mailing list