changeset 8934:71bd8f8ad1fb

8214189: test/hotspot/jtreg/compiler/intrinsics/mathexact/MulExactLConstantTest.java fails on Windows x64 when run with -XX:-TieredCompilation Reviewed-by: kvn
author roland
date Mon, 26 Nov 2018 17:35:35 +0100
parents 3999f5f297f2
children 97d605522fcb
files src/share/vm/opto/mulnode.cpp src/share/vm/utilities/globalDefinitions.hpp test/compiler/integerArithmetic/MultiplyByConstantLongMax.java
diffstat 3 files changed, 54 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/opto/mulnode.cpp	Tue Feb 19 10:06:13 2019 +0100
+++ b/src/share/vm/opto/mulnode.cpp	Mon Nov 26 17:35:35 2018 +0100
@@ -285,20 +285,20 @@
 
   // Check for negative constant; if so negate the final result
   bool sign_flip = false;
-  unsigned long abs_con = uabs(con);
-  if (abs_con != (unsigned long)con) {
+  julong abs_con = uabs(con);
+  if (abs_con != (julong)con) {
     sign_flip = true;
   }
 
   // Get low bit; check for being the only bit
   Node *res = NULL;
-  unsigned long bit1 = abs_con & (0-abs_con);      // Extract low bit
+  julong bit1 = abs_con & (0-abs_con);      // Extract low bit
   if (bit1 == abs_con) {           // Found a power of 2?
     res = new (phase->C) LShiftLNode(in(1), phase->intcon(log2_long(bit1)));
   } else {
 
     // Check for constant with 2 bits set
-    unsigned long bit2 = abs_con-bit1;
+    julong bit2 = abs_con-bit1;
     bit2 = bit2 & (0-bit2);          // Extract 2nd bit
     if (bit2 + bit1 == abs_con) {    // Found all bits in con?
       Node *n1 = phase->transform(new (phase->C) LShiftLNode(in(1), phase->intcon(log2_long(bit1))));
@@ -307,7 +307,7 @@
 
     } else if (is_power_of_2_long(abs_con+1)) {
       // Sleezy: power-of-2 -1.  Next time be generic.
-      unsigned long temp = abs_con + 1;
+      julong temp = abs_con + 1;
       Node *n1 = phase->transform( new (phase->C) LShiftLNode(in(1), phase->intcon(log2_long(temp))));
       res = new (phase->C) SubLNode(n1, in(1));
     } else {
--- a/src/share/vm/utilities/globalDefinitions.hpp	Tue Feb 19 10:06:13 2019 +0100
+++ b/src/share/vm/utilities/globalDefinitions.hpp	Mon Nov 26 17:35:35 2018 +0100
@@ -1232,16 +1232,16 @@
   if (value < 0) result = 0-result;
   return result;
 }
-static inline unsigned long uabs(unsigned long n) {
+static inline julong uabs(julong n) {
   union {
-    unsigned long result;
-    long value;
+    julong result;
+    jlong value;
   };
   result = n;
   if (value < 0) result = 0-result;
   return result;
 }
-static inline unsigned long uabs(jlong n) { return uabs((unsigned long)n); }
+static inline julong uabs(jlong n) { return uabs((julong)n); }
 static inline unsigned int uabs(int n) { return uabs((unsigned int)n); }
 
 // "to" should be greater than "from."
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compiler/integerArithmetic/MultiplyByConstantLongMax.java	Mon Nov 26 17:35:35 2018 +0100
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2018, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8214189
+ * @summary test/hotspot/jtreg/compiler/intrinsics/mathexact/MulExactLConstantTest.java fails on Windows x64 when run with -XX:-TieredCompilation
+ *
+ * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation -XX:-UseOnStackReplacement MultiplyByConstantLongMax
+ *
+ */
+
+public class MultiplyByConstantLongMax {
+    public static void main(String[] args) {
+        for (int i = 0; i < 20_000; i++) {
+            if (test(1) != Long.MAX_VALUE) {
+                throw new RuntimeException("incorrect result");
+            }
+        }
+    }
+
+    private static long test(long v) {
+        return v * Long.MAX_VALUE;
+    }
+}