HomeFreeBSD

subr_pctrie: use ilog2(x) instead of fls(x)-1

Description

subr_pctrie: use ilog2(x) instead of fls(x)-1

In three instances where fls(x)-1 is used, the compiler does not know
that x is nonzero and so adds needless zero checks. Using ilog(x)
instead saves, in each instance, about 4 instructions, including a
conditional, and 16 or so bytes, on an amd64 build.

Reviewed by: alc
Differential Revision: https://reviews.freebsd.org/D45330

Details

Provenance
dougmAuthored on Jun 3 2024, 6:31 PM
Reviewer
alc
Differential Revision
D45330: subr_pctrie: use ilog2(x) instead of fls(x)-1
Parents
rG08f6f78f81e2: libkern: don't use MPASS
Branches
Unknown
Tags
Unknown