[PATCH] D113291: [AggressiveInstCombine] Lower Table Based CTTZ and enable it for AARCH64 in -O3

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 26 11:19:56 PDT 2022


efriedma added a comment.

> For the table lookup, is there an algorithm for creating the special constant that is used in the multiply? Or would we just hardcode known constants for common sizes.

https://en.wikipedia.org/wiki/De_Bruijn_sequence has a description of the algorithm.  Probably we'd just hard-code constants, though; practically speaking, the only sizes we actually care about are 16, 32, and 64.  (For anything that doesn't fit in a single register, we probably just want to split the cttz.)

> Note, the popcount expansion already uses a multiply without checking if it is legal.

It's a relatively cheap multiply to expand on a target with a shifter, though.


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

https://reviews.llvm.org/D113291



More information about the llvm-commits mailing list