[PATCH] D141798: Remove ZeroBehavior of countLeadingZeros and the like (NFC)

Kazu Hirata via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 18 18:25:31 PST 2023


kazu marked an inline comment as done.
kazu added a comment.

In D141798#4055050 <https://reviews.llvm.org/D141798#4055050>, @barannikov88 wrote:

> It would be nice to have comments reflecting the new behavior in the case of 0 / max value.

I've added comments to all four functions -- count{Leading,Trailing}{Zeros,Ones}.



================
Comment at: llvm/include/llvm/Support/MathExtras.h:212
 /// Only unsigned integral types are allowed.
-///
-/// \param ZB the behavior on an input of 0. Only ZB_Max and ZB_Undefined are
-///   valid arguments.
-template <typename T> T findFirstSet(T Val, ZeroBehavior ZB = ZB_Max) {
-  if (ZB == ZB_Max && Val == 0)
+template <typename T> T findFirstSet(T Val) {
+  if (Val == 0)
----------------
craig.topper wrote:
> Note, x86 does not have an efficient instruction for find first set with zero returning -1. It will require a cmov to handle zero.
The new iteration of the patch leaves findFirstSet and findLastSet untouched.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141798



More information about the llvm-commits mailing list