[aarch64-port-dev ] RFR(M): 8212043: Add floating-point Math.min/max intrinsics

Andrew Dinn adinn at redhat.com
Wed Dec 19 09:19:09 UTC 2018


On 18/12/2018 11:38, Andrew Dinn wrote:
> On 18/12/2018 11:05, Andrew Haley wrote:
>> On 12/18/18 10:21 AM, Pengfei Li (Arm Technology China) wrote:
>>> http://cr.openjdk.java.net/~pli/rfr/8212043/webrev.04/
>>> Today I tested this webrev on Linux/x86_64, Linux/AArch64, macOS and Windows10. All the builds completed with no failure. So do you like this solution?
>>
>> Yes. Let's try to submit that.
> I am preparing the submit job now ...
Well, we all liked that solution. Unfortunately, solaris-sparcv9 did not
like it :-/. Either it does not implement the standard header files
correctly or they need to be included using a different path.

I followed Andrew's suggestion and used a union to perform the long/int
to double/float conversion. It worked on all architectures. Note that I
used int64_t and int32_t for the integer fields of the unions used to
convert the double and float, respectively (n.b. int64_t and int32_t are
defined for all architectures in the generic global header file). I have
included the diff for file type.cpp below my sig (the rest was unchanged
from the latest patch).

Andrew, if you are ok with this tweak I will push the patch to the JDK
dev repo.

regards,


Andrew Dinn
-----------
Senior Principal Software Engineer
Red Hat UK Ltd
Registered in England and Wales under Company Registration No. 03798903
Directors: Michael Cunningham, Michael ("Mike") O'Neill, Eric Shander


--- a/src/hotspot/share/opto/type.cpp	Tue Dec 18 10:26:15 2018 +0000
+++ b/src/hotspot/share/opto/type.cpp	Tue Dec 18 16:50:35 2018 +0000
@@ -416,6 +416,18 @@

 #define SMALLINT ((juint)3)  // a value too insignificant to consider
widening

+static double pos_dinf() {
+  union { int64_t i; double d; } v;
+  v.i = CONST64(0x7ff0000000000000);
+  return v.d;
+}
+
+static float pos_finf() {
+  union { int32_t i; float f; } v;
+  v.i = 0x7f800000;
+  return v.f;
+}
+
 //--------------------------Initialize_shared----------------------------------
 void Type::Initialize_shared(Compile* current) {
   // This method does not need to be locked because the first system
@@ -445,9 +457,13 @@

   TypeF::ZERO = TypeF::make(0.0); // Float 0 (positive zero)
   TypeF::ONE  = TypeF::make(1.0); // Float 1
+  TypeF::POS_INF = TypeF::make(pos_finf());
+  TypeF::NEG_INF = TypeF::make(-pos_finf());

   TypeD::ZERO = TypeD::make(0.0); // Double 0 (positive zero)
   TypeD::ONE  = TypeD::make(1.0); // Double 1
+  TypeD::POS_INF = TypeD::make(pos_dinf());
+  TypeD::NEG_INF = TypeD::make(-pos_dinf());

   TypeInt::MINUS_1 = TypeInt::make(-1);  // -1
   TypeInt::ZERO    = TypeInt::make( 0);  //  0
@@ -1087,6 +1103,8 @@
 // Convenience common pre-built types.
 const TypeF *TypeF::ZERO;       // Floating point zero
 const TypeF *TypeF::ONE;        // Floating point one
+const TypeF *TypeF::POS_INF;    // Floating point positive infinity
+const TypeF *TypeF::NEG_INF;    // Floating point negative infinity

 //------------------------------make-------------------------------------------
 // Create a float constant
@@ -1195,6 +1213,8 @@
 // Convenience common pre-built types.
 const TypeD *TypeD::ZERO;       // Floating point zero
 const TypeD *TypeD::ONE;        // Floating point one
+const TypeD *TypeD::POS_INF;    // Floating point positive infinity
+const TypeD *TypeD::NEG_INF;    // Floating point negative infinity

 //------------------------------make-------------------------------------------
 const TypeD *TypeD::make(double d) {


More information about the aarch64-port-dev mailing list