RFR: 8257985: count_trailing_zeros doesn't handle 64-bit values on 32-bit JVM [v9]

Kim Barrett kim.barrett at oracle.com
Fri Dec 11 16:01:53 UTC 2020


> On Dec 11, 2020, at 10:43 AM, Thomas Schatzl <tschatzl at openjdk.java.net> wrote:
> 
> On Fri, 11 Dec 2020 15:31:09 GMT, Claes Redestad <redestad at openjdk.org> wrote:
> 
>>> Re-implement count_trailing_zeros as a template function similar to count_leading_zeros, adding support for 8 and 16 bit types as well as for 64-bit types on 32-bit builds, which is currently not supported. This prohibits implementing the log2i_exact proposed by #1663 using count_trailing_zeros, as suggested during review.
>>> 
>>> Compared to count_leading_zeros the implementation can be slightly simpler since subword specializations can simply use the internal 32-bit variant.
>>> 
>>> Windows doesn't define _BitScanForward64 on 32-bit targets, so the 32-bit variant for handling 64-bit values becomes more convoluted.
>> 
>> Claes Redestad has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>  Explicit, static_cast to 32-bit unsigned
> 
> These casts are actually not needed - (unsigned) long on Windows is always 32 bits so there is already an implicit cast that is sufficient in both cases. I think @kimbarrett correctly identified them as such.

That should be true.  However

(1) These are intrinsics; I don’t know if the rules for them differ from normal functions.

(2) These are narrowing conversions, which a compiler *might* warn about if left implicit,
possibly depending on compiler settings.  (-Wconversion anyone?)




More information about the hotspot-dev mailing list