src/hotspot/share/opto/library_call.cpp
changeset 48396 3c9975e46464
parent 47587 bf73ca31add9
child 48404 177e1783d886
--- a/src/hotspot/share/opto/library_call.cpp	Wed Dec 13 07:14:18 2017 -0500
+++ b/src/hotspot/share/opto/library_call.cpp	Wed Dec 13 19:32:48 2017 +0300
@@ -1789,10 +1789,19 @@
     return StubRoutines::dexp() != NULL ?
       runtime_math(OptoRuntime::Math_D_D_Type(), StubRoutines::dexp(),  "dexp") :
       runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dexp),  "EXP");
-  case vmIntrinsics::_dpow:
-    return StubRoutines::dpow() != NULL ?
-      runtime_math(OptoRuntime::Math_DD_D_Type(), StubRoutines::dpow(), "dpow") :
+  case vmIntrinsics::_dpow: {
+    Node* exp = round_double_node(argument(2));
+    const TypeD* d = _gvn.type(exp)->isa_double_constant();
+    if (d != NULL && d->getd() == 2.0) {
+      // Special case: pow(x, 2.0) => x * x
+      Node* base = round_double_node(argument(0));
+      set_result(_gvn.transform(new MulDNode(base, base)));
+      return true;
+    }
+    return StubRoutines::dexp() != NULL ?
+      runtime_math(OptoRuntime::Math_DD_D_Type(), StubRoutines::dpow(),  "dpow") :
       runtime_math(OptoRuntime::Math_DD_D_Type(), FN_PTR(SharedRuntime::dpow),  "POW");
+  }
 #undef FN_PTR
 
    // These intrinsics are not yet correctly implemented