changeset 47329:bf73ca31add9

8187684: Intrinsify Math.multiplyHigh(long, long) Reviewed-by: kvn, aph, lucy
author dpochepk
date Wed, 04 Oct 2017 11:52:07 -0700
parents 07ad034e0c29
children 974275a24b74
files src/hotspot/share/classfile/vmSymbols.hpp src/hotspot/share/opto/c2compiler.cpp src/hotspot/share/opto/library_call.cpp src/java.base/share/classes/java/lang/Math.java
diffstat 4 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/classfile/vmSymbols.hpp	Wed Oct 04 16:44:45 2017 +0200
+++ b/src/hotspot/share/classfile/vmSymbols.hpp	Wed Oct 04 11:52:07 2017 -0700
@@ -781,6 +781,7 @@
   do_name(decrementExact_name,"decrementExact")                                                                         \
   do_name(incrementExact_name,"incrementExact")                                                                         \
   do_name(multiplyExact_name,"multiplyExact")                                                                           \
+  do_name(multiplyHigh_name,"multiplyHigh")                                                                             \
   do_name(negateExact_name,"negateExact")                                                                               \
   do_name(subtractExact_name,"subtractExact")                                                                           \
   do_name(fma_name, "fma")                                                                                              \
@@ -805,6 +806,7 @@
   do_intrinsic(_incrementExactL,          java_lang_Math,         incrementExact_name, long_long_signature,      F_S)   \
   do_intrinsic(_multiplyExactI,           java_lang_Math,         multiplyExact_name, int2_int_signature,        F_S)   \
   do_intrinsic(_multiplyExactL,           java_lang_Math,         multiplyExact_name, long2_long_signature,      F_S)   \
+  do_intrinsic(_multiplyHigh,             java_lang_Math,         multiplyHigh_name, long2_long_signature,       F_S)   \
   do_intrinsic(_negateExactI,             java_lang_Math,         negateExact_name, int_int_signature,           F_S)   \
   do_intrinsic(_negateExactL,             java_lang_Math,         negateExact_name, long_long_signature,         F_S)   \
   do_intrinsic(_subtractExactI,           java_lang_Math,         subtractExact_name, int2_int_signature,        F_S)   \
--- a/src/hotspot/share/opto/c2compiler.cpp	Wed Oct 04 16:44:45 2017 +0200
+++ b/src/hotspot/share/opto/c2compiler.cpp	Wed Oct 04 11:52:07 2017 -0700
@@ -410,6 +410,9 @@
   case vmIntrinsics::_multiplyExactL:
     if (!Matcher::match_rule_supported(Op_OverflowMulL)) return false;
     break;
+  case vmIntrinsics::_multiplyHigh:
+    if (!Matcher::match_rule_supported(Op_MulHiL)) return false;
+    break;
   case vmIntrinsics::_getCallerClass:
     if (SystemDictionary::reflect_CallerSensitive_klass() == NULL) return false;
     break;
--- a/src/hotspot/share/opto/library_call.cpp	Wed Oct 04 16:44:45 2017 +0200
+++ b/src/hotspot/share/opto/library_call.cpp	Wed Oct 04 11:52:07 2017 -0700
@@ -231,6 +231,7 @@
   bool inline_math_addExactL(bool is_increment);
   bool inline_math_multiplyExactI();
   bool inline_math_multiplyExactL();
+  bool inline_math_multiplyHigh();
   bool inline_math_negateExactI();
   bool inline_math_negateExactL();
   bool inline_math_subtractExactI(bool is_decrement);
@@ -549,6 +550,7 @@
   case vmIntrinsics::_incrementExactL:          return inline_math_addExactL(true /* increment */);
   case vmIntrinsics::_multiplyExactI:           return inline_math_multiplyExactI();
   case vmIntrinsics::_multiplyExactL:           return inline_math_multiplyExactL();
+  case vmIntrinsics::_multiplyHigh:             return inline_math_multiplyHigh();
   case vmIntrinsics::_negateExactI:             return inline_math_negateExactI();
   case vmIntrinsics::_negateExactL:             return inline_math_negateExactL();
   case vmIntrinsics::_subtractExactI:           return inline_math_subtractExactI(false /* subtract */);
@@ -1897,6 +1899,11 @@
   return inline_math_overflow<OverflowMulLNode>(argument(0), argument(2));
 }
 
+bool LibraryCallKit::inline_math_multiplyHigh() {
+  set_result(_gvn.transform(new MulHiLNode(argument(0), argument(2))));
+  return true;
+}
+
 Node*
 LibraryCallKit::generate_min_max(vmIntrinsics::ID id, Node* x0, Node* y0) {
   // These are the candidate return value:
--- a/src/java.base/share/classes/java/lang/Math.java	Wed Oct 04 16:44:45 2017 +0200
+++ b/src/java.base/share/classes/java/lang/Math.java	Wed Oct 04 11:52:07 2017 -0700
@@ -1094,6 +1094,7 @@
      * @return the result
      * @since 9
      */
+    @HotSpotIntrinsicCandidate
     public static long multiplyHigh(long x, long y) {
         if (x < 0 || y < 0) {
             // Use technique from section 8-2 of Henry S. Warren, Jr.,