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

[macos]UnsignedMultiplyHigh is not implemented as an intrinsic

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      os_x

      Description

      ADDITIONAL SYSTEM INFORMATION :
      JDK 18 build 11
      macOS 10.14.6
      Intel Core i7

      A DESCRIPTION OF THE PROBLEM :
      Computing the upper 64 bits can be easily computed in java with multiplies, adds and shifts on long data. However it cannot be done nearly as efficiently as what the underlying CPUs can do. x64 and ARM cpus can compute the high 64 bits in the same amount of time it takes to calculate the lower 64 bits of a 128 bit product.

      Math.unsignedMultiplyHigh is primarily needed for performance reasons. However in the current version of JDK 18 Math.unsignedMultiplyHigh performs poorly. It should have performance that is comparable to its signed version Math.multiplyHigh.

      Using JMH the time to execute is
      09 regular 64 bit multiply
      13 Math.multiplyHigh
      22 Math.unsignedMultiplyHigh

      Running with -XX:+UnlockDiagnosticVMOptions -XX:+PrintIntrinsics only the following is reported (no intrinsic for unsignedMultipleHigh).
             java.lang.Math::multiplyHigh (86 bytes) (intrinsic)


      Note: Bug (JDK-8188044) shows that this was supposed to be fixed and delivered in JDK 18 build 5 and is now closed. This was tested on JDK18 build 11


        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated: