summaryrefslogtreecommitdiff
path: root/inline.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2021-07-20 10:41:39 -0600
committerKarl Williamson <khw@cpan.org>2021-07-30 05:41:28 -0600
commit250e5324a59b505b79ee7b1dc924b0e8e5b51f95 (patch)
tree664af473905f4b4db84482551cde769034e91516 /inline.h
parente88dde507ccbbc2140c509d1e6b0a960d868c6d7 (diff)
downloadperl-250e5324a59b505b79ee7b1dc924b0e8e5b51f95.tar.gz
Comment why ffs() isn't used for lsbit_pos()
Diffstat (limited to 'inline.h')
-rw-r--r--inline.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/inline.h b/inline.h
index 57db98f3bc..eddb3710c3 100644
--- a/inline.h
+++ b/inline.h
@@ -727,6 +727,15 @@ Perl_is_utf8_invariant_string_loc(const U8* const s, STRLEN len, const U8 ** ep)
# endif
#endif
+/* The reason there are not checks to see if ffs() and ffsl() are available for
+ * determining the lsb, is because these don't improve on the deBruijn method
+ * fallback, which is just a branchless integer multiply, array element
+ * retrieval, and shift. The others, even if the function call overhead is
+ * optimized out, have to cope with the possibility of the input being all
+ * zeroes, and almost certainly will have conditionals for this eventuality.
+ * khw, at the time of this commit, looked at the source for both gcc and clang
+ * to verify this. (gcc used a method inferior to deBruijn.) */
+
/* Below are functions to find the first, last, or only set bit in a word. On
* platforms with 64-bit capability, there is a pair for each operation; the
* first taking a 64 bit operand, and the second a 32 bit one. The logic is