aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/include/asm/bitops.h
diff options
context:
space:
mode:
authorHeiko Carstens <hca@linux.ibm.com>2025-09-22 13:40:20 +0200
committerAlexander Gordeev <agordeev@linux.ibm.com>2025-09-24 16:24:18 +0200
commit6c4e0cb3d87ad63a30e05e7624a45a6f01240e70 (patch)
treeed7c8c1268499a0568fe9f2a52e36d7ba60bfa14 /arch/s390/include/asm/bitops.h
parents390/bitops: Switch to generic fls(), fls64(), etc. (diff)
downloadlinux-6c4e0cb3d87ad63a30e05e7624a45a6f01240e70.tar.gz
linux-6c4e0cb3d87ad63a30e05e7624a45a6f01240e70.zip
s390/bitops: Switch to generic ffs() if supported by compiler
Use generic ffs() / __builtin_ffs() if supported by the compiler. GCC 16 will have support for __builtin_ffs(). See gcc commit f50cff9766c5 ("s390: Implement clz and ctz for SI mode"). In the distant future when GCC 16 becomes the minimum supported version, this allows to get rid of the flogr inline assembly. Kernel image size is reduced by ~500 bytes (gcc 16 beta + defconfig). Acked-by: Alexander Gordeev <agordeev@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Diffstat (limited to 'arch/s390/include/asm/bitops.h')
-rw-r--r--arch/s390/include/asm/bitops.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/arch/s390/include/asm/bitops.h b/arch/s390/include/asm/bitops.h
index 8b9060c26c52..1564dd3a5a82 100644
--- a/arch/s390/include/asm/bitops.h
+++ b/arch/s390/include/asm/bitops.h
@@ -122,6 +122,8 @@ static inline bool test_bit_inv(unsigned long nr,
return test_bit(nr ^ (BITS_PER_LONG - 1), ptr);
}
+#ifndef CONFIG_CC_HAS_BUILTIN_FFS
+
/**
* __flogr - find leftmost one
* @word - The word to search
@@ -194,6 +196,12 @@ static __always_inline __flatten int ffs(int word)
return BITS_PER_LONG - __flogr(-val & val);
}
+#else /* CONFIG_CC_HAS_BUILTIN_FFS */
+
+#include <asm-generic/bitops/builtin-ffs.h>
+
+#endif /* CONFIG_CC_HAS_BUILTIN_FFS */
+
#include <asm-generic/bitops/builtin-__ffs.h>
#include <asm-generic/bitops/ffz.h>
#include <asm-generic/bitops/builtin-__fls.h>