x86/bitops: Simplify variable_ffz() as variable__ffs(~word)
authorUros Bizjak <ubizjak@gmail.com>
Thu, 27 Mar 2025 09:56:28 +0000 (10:56 +0100)
committerIngo Molnar <mingo@kernel.org>
Fri, 28 Mar 2025 22:24:16 +0000 (23:24 +0100)
commite29c5d0e5dc35ed8b8920b573925d8aa2f8bafb0
tree63aafc5bf3a1a5dbf4571b7c4419e80d126242c0
parent0717b1392dc7e3f350e5a5d25ea794aa92210684
x86/bitops: Simplify variable_ffz() as variable__ffs(~word)

Find first zero (FFZ) can be implemented by negating the
input and using find first set (FFS).

Before/after code generation comparison on ffz()-using
kernel code shows that code generation has not changed:

  # kernel/signal.o:

   text    data     bss     dec     hex filename
  42121    3472       8   45601    b221 signal.o.before
  42121    3472       8   45601    b221 signal.o.after

md5:
   ce4c31e1bce96af19b62a5f9659842f1  signal.o.before.asm
   ce4c31e1bce96af19b62a5f9659842f1  signal.o.after.asm

[ mingo: Added code generation check. ]

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20250327095641.131483-1-ubizjak@gmail.com
arch/x86/include/asm/bitops.h