Mon, 26 Nov 2018 17:35:35 +0100
8214189: test/hotspot/jtreg/compiler/intrinsics/mathexact/MulExactLConstantTest.java fails on Windows x64 when run with -XX:-TieredCompilation
Reviewed-by: kvn
1.1 --- a/src/share/vm/opto/mulnode.cpp Tue Feb 19 10:06:13 2019 +0100 1.2 +++ b/src/share/vm/opto/mulnode.cpp Mon Nov 26 17:35:35 2018 +0100 1.3 @@ -285,20 +285,20 @@ 1.4 1.5 // Check for negative constant; if so negate the final result 1.6 bool sign_flip = false; 1.7 - unsigned long abs_con = uabs(con); 1.8 - if (abs_con != (unsigned long)con) { 1.9 + julong abs_con = uabs(con); 1.10 + if (abs_con != (julong)con) { 1.11 sign_flip = true; 1.12 } 1.13 1.14 // Get low bit; check for being the only bit 1.15 Node *res = NULL; 1.16 - unsigned long bit1 = abs_con & (0-abs_con); // Extract low bit 1.17 + julong bit1 = abs_con & (0-abs_con); // Extract low bit 1.18 if (bit1 == abs_con) { // Found a power of 2? 1.19 res = new (phase->C) LShiftLNode(in(1), phase->intcon(log2_long(bit1))); 1.20 } else { 1.21 1.22 // Check for constant with 2 bits set 1.23 - unsigned long bit2 = abs_con-bit1; 1.24 + julong bit2 = abs_con-bit1; 1.25 bit2 = bit2 & (0-bit2); // Extract 2nd bit 1.26 if (bit2 + bit1 == abs_con) { // Found all bits in con? 1.27 Node *n1 = phase->transform(new (phase->C) LShiftLNode(in(1), phase->intcon(log2_long(bit1)))); 1.28 @@ -307,7 +307,7 @@ 1.29 1.30 } else if (is_power_of_2_long(abs_con+1)) { 1.31 // Sleezy: power-of-2 -1. Next time be generic. 1.32 - unsigned long temp = abs_con + 1; 1.33 + julong temp = abs_con + 1; 1.34 Node *n1 = phase->transform( new (phase->C) LShiftLNode(in(1), phase->intcon(log2_long(temp)))); 1.35 res = new (phase->C) SubLNode(n1, in(1)); 1.36 } else {
2.1 --- a/src/share/vm/utilities/globalDefinitions.hpp Tue Feb 19 10:06:13 2019 +0100 2.2 +++ b/src/share/vm/utilities/globalDefinitions.hpp Mon Nov 26 17:35:35 2018 +0100 2.3 @@ -1232,16 +1232,16 @@ 2.4 if (value < 0) result = 0-result; 2.5 return result; 2.6 } 2.7 -static inline unsigned long uabs(unsigned long n) { 2.8 +static inline julong uabs(julong n) { 2.9 union { 2.10 - unsigned long result; 2.11 - long value; 2.12 + julong result; 2.13 + jlong value; 2.14 }; 2.15 result = n; 2.16 if (value < 0) result = 0-result; 2.17 return result; 2.18 } 2.19 -static inline unsigned long uabs(jlong n) { return uabs((unsigned long)n); } 2.20 +static inline julong uabs(jlong n) { return uabs((julong)n); } 2.21 static inline unsigned int uabs(int n) { return uabs((unsigned int)n); } 2.22 2.23 // "to" should be greater than "from."
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/test/compiler/integerArithmetic/MultiplyByConstantLongMax.java Mon Nov 26 17:35:35 2018 +0100 3.3 @@ -0,0 +1,45 @@ 3.4 +/* 3.5 + * Copyright (c) 2018, Red Hat, Inc. All rights reserved. 3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.7 + * 3.8 + * This code is free software; you can redistribute it and/or modify it 3.9 + * under the terms of the GNU General Public License version 2 only, as 3.10 + * published by the Free Software Foundation. 3.11 + * 3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 3.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 3.15 + * version 2 for more details (a copy is included in the LICENSE file that 3.16 + * accompanied this code). 3.17 + * 3.18 + * You should have received a copy of the GNU General Public License version 3.19 + * 2 along with this work; if not, write to the Free Software Foundation, 3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 3.21 + * 3.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 3.23 + * or visit www.oracle.com if you need additional information or have any 3.24 + * questions. 3.25 + */ 3.26 + 3.27 +/** 3.28 + * @test 3.29 + * @bug 8214189 3.30 + * @summary test/hotspot/jtreg/compiler/intrinsics/mathexact/MulExactLConstantTest.java fails on Windows x64 when run with -XX:-TieredCompilation 3.31 + * 3.32 + * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation -XX:-UseOnStackReplacement MultiplyByConstantLongMax 3.33 + * 3.34 + */ 3.35 + 3.36 +public class MultiplyByConstantLongMax { 3.37 + public static void main(String[] args) { 3.38 + for (int i = 0; i < 20_000; i++) { 3.39 + if (test(1) != Long.MAX_VALUE) { 3.40 + throw new RuntimeException("incorrect result"); 3.41 + } 3.42 + } 3.43 + } 3.44 + 3.45 + private static long test(long v) { 3.46 + return v * Long.MAX_VALUE; 3.47 + } 3.48 +}