Request for reviews (L): 6823354: Add intrinsics for{Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
Christian Thalinger
Christian.Thalinger at Sun.COM
Sat Apr 25 23:58:00 PDT 2009
On Thu, 2009-04-23 at 09:57 -0700, Vladimir Kozlov wrote:
> "TEMP dst" is not needed in countLeadingZerosI_bsr (32- and 64-bit .ad)
> since the code will work even if src and dst registers are the same.
Ahh, right.
>
> The same in countLeadingZerosL_bsr in x86_64.ad, in x86_32.ad
> it is not needed in countTrailingZerosI.
Yes.
>
> x86_32.ad:
>
> You can avoid tmp register in countLeadingZerosL:
>
> + format %{ "LZCNT $dst, $src.hi\t# count leading zeros (long)\n\t"
> + "JNC done\n\t"
> + "LZCNT $dst, $src.lo\n\t"
> + "ADD $dst, 32\n"
> + "done:" %}
>
> and in countLeadingZerosL_bsr:
>
> + format %{ "BSR $dst, $src.hi\t# count leading zeros (long)\n\t"
> + "JZ msw_is_zero\n\t"
> + "ADD $dst, 32\n\t"
> + "JMP not_zero\n"
> + "msw_is_zero:\n\t"
> + "BSR $dst, $src.lo\n\t"
> + "JNZ not_zero\n\t"
> + "MOV $dst, -1\n"
> + "not_zero:\n\t"
> + "NEG $dst\n\t"
> + "ADD $dst, 63\n" %}
>
> and in countTrailingZerosL:
>
> + format %{ "BSF $dst, $src.lo\t# count trailing zeros (long)\n\t"
> + "JNZ done\n\t"
> + "BSF $dst, $src.hi\n\t"
> + "JNZ skip\n\t"
> + "MOV $dst, 32\n"
> + "skip:\n\t"
> + "ADD $dst, 32\n"
> + "done:" %}
These are good ones! Thanks!
>
>
> Could you also run your benchmark again to see if performance is changed.
I will.
-- Christian
More information about the hotspot-compiler-dev
mailing list