mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 17:13:52 +02:00
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
This commit is contained in:
parent
0717b1392d
commit
e29c5d0e5d
|
|
@ -267,10 +267,7 @@ static __always_inline unsigned long variable__ffs(unsigned long word)
|
|||
|
||||
static __always_inline unsigned long variable_ffz(unsigned long word)
|
||||
{
|
||||
asm("tzcnt %1,%0"
|
||||
: "=r" (word)
|
||||
: "r" (~word));
|
||||
return word;
|
||||
return variable__ffs(~word);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user