Request for reviews (L): 6823354: Add intrinsics for{Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()

Vladimir Kozlov Vladimir.Kozlov at Sun.COM
Thu Apr 23 09:57:10 PDT 2009


"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.

The same in countLeadingZerosL_bsr in x86_64.ad, in x86_32.ad
it is not needed in countTrailingZerosI.

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:" %}


Could you also run your benchmark again to see if performance is changed.

Vladimir

Christian Thalinger wrote:
> Here is the updated version:
> 
> http://cr.openjdk.java.net/~twisti/6823354/webrev.02/
> 



More information about the hotspot-compiler-dev mailing list