RFR: 8349637: Integer.numberOfLeadingZeros outputs incorrectly in certain cases [v3]

Jasmine Karthikeyan jkarthikeyan at openjdk.org
Fri Feb 21 02:45:55 UTC 2025


On Thu, 20 Feb 2025 14:19:15 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> @rgiulietti Shifting by 1 instead of 24 is a really good idea, it makes showing the validity a lot more simple as you mention. I've applied the suggestion in the latest commit. The updated instruction sequence is also very interesting, I'd like to take a look at it in a followup RFE. I was planning on taking a closer look at the long intrinsic after this patch, since it doesn't use the floating point trick that int does and I was very curious to see what the performance would be like with it.
>> 
>> @TobiHartmann I've pushed an adapted version of your test that checks for `numberOfLeadingZeros`/`numberOfTrailingZeros` correctness for int and long. Let me know what you think!
>
> @jaskarth Would it make sense to add this VectorAPI test as well?
> https://github.com/openjdk/jdk/pull/23579#issuecomment-2659586753

@eme64 I think adding the Vector API test is a good idea. I added a new IR test to the file that exercises the logic with the vector api, and checked that it fails without the patch and passes with it. Let me know what you think!

@rgiulietti I agree, I think it would be better to keep this as a bug fix and clean up the logic in a followup patch. I filed an RFE for it: https://bugs.openjdk.org/browse/JDK-8350468

-------------

PR Comment: https://git.openjdk.org/jdk/pull/23579#issuecomment-2673213072


More information about the hotspot-compiler-dev mailing list