RFR: 8349637: Integer.numberOfLeadingZeros outputs incorrectly in certain cases [v2]
Jasmine Karthikeyan
jkarthikeyan at openjdk.org
Wed Feb 12 17:48:10 UTC 2025
On Wed, 12 Feb 2025 16:33:08 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:
>> I believe the solution should work since my idea was to get rid of low bits when the high bits past 24 are all `1`, as that is the case where rounding behavior can incorrectly bump up the value. In the other cases, not removing all the low bits shouldn't have an impact on rounding and the exponent. At least, when running an [exhaustive test](https://gist.github.com/jaskarth/6b05352c3007a2650bf084fcb4c50c13) I wrote this patch fixes the output discrepancy. I can change it to the compare and blend you suggested, but I think that will be slower than this approach. Killing `src` is my mistake though, I will fix it in the next commit.
>
> Yes you are right, that was my mistake, please make it clearer in the comment. I also think that you don't need to zero `xtmp2` before the right shift, am I right?
I'll make sure to reword the comment to describe the behavior more accurately. You are correct that we don't need to zero xtmp2, Jatin mentioned the same thing and I removed it in the last commit.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23579#discussion_r1953136949
More information about the hotspot-compiler-dev
mailing list