提交 5df367bd 编写于 作者: R roland

8214189:...

8214189: test/hotspot/jtreg/compiler/intrinsics/mathexact/MulExactLConstantTest.java fails on Windows x64 when run with -XX:-TieredCompilation
Reviewed-by: kvn
上级 54c4be2a
...@@ -285,20 +285,20 @@ Node *MulLNode::Ideal(PhaseGVN *phase, bool can_reshape) { ...@@ -285,20 +285,20 @@ Node *MulLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
// Check for negative constant; if so negate the final result // Check for negative constant; if so negate the final result
bool sign_flip = false; bool sign_flip = false;
unsigned long abs_con = uabs(con); julong abs_con = uabs(con);
if (abs_con != (unsigned long)con) { if (abs_con != (julong)con) {
sign_flip = true; sign_flip = true;
} }
// Get low bit; check for being the only bit // Get low bit; check for being the only bit
Node *res = NULL; 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? if (bit1 == abs_con) { // Found a power of 2?
res = new (phase->C) LShiftLNode(in(1), phase->intcon(log2_long(bit1))); res = new (phase->C) LShiftLNode(in(1), phase->intcon(log2_long(bit1)));
} else { } else {
// Check for constant with 2 bits set // 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 bit2 = bit2 & (0-bit2); // Extract 2nd bit
if (bit2 + bit1 == abs_con) { // Found all bits in con? 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)))); Node *n1 = phase->transform(new (phase->C) LShiftLNode(in(1), phase->intcon(log2_long(bit1))));
...@@ -307,7 +307,7 @@ Node *MulLNode::Ideal(PhaseGVN *phase, bool can_reshape) { ...@@ -307,7 +307,7 @@ Node *MulLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
} else if (is_power_of_2_long(abs_con+1)) { } else if (is_power_of_2_long(abs_con+1)) {
// Sleezy: power-of-2 -1. Next time be generic. // 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)))); Node *n1 = phase->transform( new (phase->C) LShiftLNode(in(1), phase->intcon(log2_long(temp))));
res = new (phase->C) SubLNode(n1, in(1)); res = new (phase->C) SubLNode(n1, in(1));
} else { } else {
......
...@@ -1232,16 +1232,16 @@ static inline unsigned int uabs(unsigned int n) { ...@@ -1232,16 +1232,16 @@ static inline unsigned int uabs(unsigned int n) {
if (value < 0) result = 0-result; if (value < 0) result = 0-result;
return result; return result;
} }
static inline unsigned long uabs(unsigned long n) { static inline julong uabs(julong n) {
union { union {
unsigned long result; julong result;
long value; jlong value;
}; };
result = n; result = n;
if (value < 0) result = 0-result; if (value < 0) result = 0-result;
return 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); } static inline unsigned int uabs(int n) { return uabs((unsigned int)n); }
// "to" should be greater than "from." // "to" should be greater than "from."
......
/*
* 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;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册