Branch: refs/heads/blead Home: https://github.com/Perl/perl5 Commit: e2b6b05ee153b1f2dad24d3b736a6ea974780183 https://github.com/Perl/perl5/commit/e2b6b05ee153b1f2dad24d3b736a6ea974780183 Author: Karl Williamson <k...@cpan.org> Date: 2023-12-20 (Wed, 20 Dec 2023)
Changed paths: M inline.h Log Message: ----------- Fallback to use BitScan(Forward|Reverse) on MingW Perl has functions that return the positions of the least or most significant one bit in a word. gcc has builtins that do these specific operations, and they get compiled to a single instruction on many hardware platforms. Windows instead has various BitScan functions that do the same thing. MingW has both gcc and Windows, so it should have access to both the builtins and to the BitScan functions, but prior to this commit, if we didn't find gcc builtins on MingW, we wouldn't bother to look for the BitScan functions. Reading the code caused me to pause to try to figure out why not use these BitScan functions, and asked on #irc. The answer from @xenu was that on MingW (as opposed to MSVC) they're emulated, and not as efficient as the gcc builtins. Then I looked at the code again, and realized we don't try them unless the gcc builtins aren't available, unlikely these days. But we should do something so that people who read this code in the future don't also end up spending time unnecessarily wondering why we treat MingW specially. We could add a comment, but it seems to me better to just not make MingW a special case. It's likely that the MingW emulation of the BitScan functions is better than our further fallback, so I see that as better and cleaner than special casing MingW.