JDK-6921969 : optimize 64 long multiply for case with high bits zero
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: hs17
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_9
  • CPU: sparc
  • Submitted: 2010-02-01
  • Updated: 2010-04-02
  • Resolved: 2010-02-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7 Other
6u21Fixed 7Fixed hs17Fixed
Hi Tom, Christian, and others,

Here's a patch I'd like to contribute:

With it, C2 generates shorter long multiplication sequences on x86_32
when the high 32 bits are known to be zero.

Particularly, this applies to the loop in BigInteger.mulAdd():

   private final static long LONG_MASK = 0xffffffffL;

   static int mulAdd(int[] out, int[] in, int offset, int len, int k) {
       long kLong = k & LONG_MASK;
       long carry = 0;

       offset = out.length-offset - 1;
       for (int j=len-1; j >= 0; j--) {
           long product = (in[j] & LONG_MASK) * kLong +
                          (out[offset] & LONG_MASK) + carry;
           out[offset--] = (int)product;
           carry = product >>> 32;
       return (int)carry;

In my measurements, one of our internal microbenchmarks that uses
BigInteger.mulAdd sped up about 12%. Also, SPECjvm2008's crypto.rsa
and crypto.signverify improved about 7% and 2.3%, respectively.

EVALUATION See description.

EVALUATION ChangeSet=http://hg.openjdk.java.net/jdk7/hotspot-comp/hotspot/rev/e8443c7be117,ChangeRequest=6921969