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, 5:45 PM
Reviewer
alc
Differential Revision
D45330: subr_pctrie: use ilog2(x) instead of fls(x)-1
Parents
rGb0056b31e900: libkern: add ilog2 macro
Branches
Unknown
Tags
Unknown
Reverted By
rGe3537f9235ba: Revert "subr_pctrie: use ilog2(x) instead of fls(x)-1"