diff options
| author | Heiko Carstens <hca@linux.ibm.com> | 2025-08-04 17:08:54 +0200 |
|---|---|---|
| committer | Alexander Gordeev <agordeev@linux.ibm.com> | 2025-08-20 16:38:23 +0200 |
| commit | de88e74889a30bd9ff4047726021cde857348b4b (patch) | |
| tree | 1dd8ecc103aa0870d9b6ff09dddd8f419c20881d | |
| parent | f9de6cdf4cf8c932ee94f6e25cd7434a97c78bf3 (diff) | |
s390/bitops: Slightly optimize ffs() and fls64()
Use a simpler algorithm to calculate the result of ffs() and fls64().
This generates slightly better code and increases readability.
Kernel image size is reduced by ~3kb (gcc 15.1.0 + defconfig).
Suggested-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
| -rw-r--r-- | arch/s390/include/asm/bitops.h | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/arch/s390/include/asm/bitops.h b/arch/s390/include/asm/bitops.h index a5ca0a947691..10d7573d1582 100644 --- a/arch/s390/include/asm/bitops.h +++ b/arch/s390/include/asm/bitops.h @@ -193,10 +193,9 @@ static inline unsigned long __ffs(unsigned long word) */ static inline int ffs(int word) { - unsigned long mask = 2 * BITS_PER_LONG - 1; unsigned int val = (unsigned int)word; - return (1 + (__flogr(-val & val) ^ (BITS_PER_LONG - 1))) & mask; + return BITS_PER_LONG - __flogr(-val & val); } /** @@ -223,9 +222,7 @@ static inline unsigned long __fls(unsigned long word) */ static inline int fls64(unsigned long word) { - unsigned long mask = 2 * BITS_PER_LONG - 1; - - return (1 + (__flogr(word) ^ (BITS_PER_LONG - 1))) & mask; + return BITS_PER_LONG - __flogr(word); } /** |
