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

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 29 03:07:41 PDT 2022


xbolva00 added a comment.

In D122077#3413550 <https://reviews.llvm.org/D122077#3413550>, @joerg wrote:

> Why is this fold preferable to `(X & (X-1)) == 0`? At least on all architectures without native population count, the binary-and based test is preferable and it might even be better with it.

Less IR instructions. I think SDAG already expands some ctpop patterns to logic (backends should decide about optimal form)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122077



More information about the llvm-commits mailing list