Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6512096

u32*u32=>u64 from bug 4850191 does not work with one u32 being a constant

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P5
    • Resolution: Won't Fix
    • Affects Version/s: 6
    • Fix Version/s: 11
    • Component/s: hotspot
    • Subcomponent:
    • Introduced In Version:
      5.0
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      Java HotSpot(TM) Server VM (1.6.0-rc-fastdebug-b90) for windows-x86, built on Jun 30 2006 01:51:43 by "java_re" with unknown MS VC++

      FULL OS VERSION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      The u32*u32=>u64 multiplication from bug 4850194 works only with 2 variables like this:

          private static int DIV3_CONST = (int)0xAAAAAAABL;

          public static int udiv3(int value) {
              return (int)(((value & 0xffffffffL) * (DIV3_CONST & 0xffffffffL)) >>> 33);
          }

      but when I declare the DIV3_CONST final it will not use the u32*u32=>u64 marco

      I verified this with the following VM options on a fastdebug build:
      -server -Xbatch -XX:+PrintCompilation -XX:+PrintInlining -XX:+PrintOptoAssembly


      as an alternative to this implement the division by constant that is mentioned in AMD optimisation guide.

      THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: No

      THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Yes

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      this hotspot macro should also work with one constant
      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.Random;

      public class X {

          private static int DIV3_CONST = (int)0xAAAAAAABL;

          public static int udiv3(int value) {
              return (int)(((value & 0xffffffffL) * (DIV3_CONST & 0xffffffffL)) >>> 33);
          }

          public static void main(String[] args) {
              Random r = new Random();
              int sum0 = 0;
              for(int i=0 ; i<10000 ; i++) {
                  sum0 += Signed.udiv3(r.nextInt());
              }
              System.out.println(sum0);
          }

      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      do not use final - but this will cause an additional memory access

        Attachments

          Activity

            People

            • Assignee:
              neliasso Nils Eliasson
              Reporter:
              ndcosta Nelson Dcosta
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: