6795362: 32bit server compiler leads to wrong results on solaris-x86
The C2 compiler leads to wrong results on solaris-i486 (32-bit) for a testcase given in the CR. Reviewed-by: never, rasbold
This commit is contained in:
parent
3b8452da93
commit
ecbdf3bb83
hotspot
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1997-2009 Sun Microsystems, 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
|
||||
@ -449,9 +449,10 @@ Node *AndINode::Identity( PhaseTransform *phase ) {
|
||||
// needed either.
|
||||
if( lop == Op_URShiftI ) {
|
||||
const TypeInt *t12 = phase->type( load->in(2) )->isa_int();
|
||||
if( t12 && t12->is_con() ) {
|
||||
int shift_con = t12->get_con();
|
||||
int mask = max_juint >> shift_con;
|
||||
if( t12 && t12->is_con() ) { // Shift is by a constant
|
||||
int shift = t12->get_con();
|
||||
shift &= BitsPerJavaInteger - 1; // semantics of Java shifts
|
||||
int mask = max_juint >> shift;
|
||||
if( (mask&con) == mask ) // If AND is useless, skip it
|
||||
return load;
|
||||
}
|
||||
@ -579,9 +580,10 @@ Node *AndLNode::Identity( PhaseTransform *phase ) {
|
||||
// needed either.
|
||||
if( lop == Op_URShiftL ) {
|
||||
const TypeInt *t12 = phase->type( usr->in(2) )->isa_int();
|
||||
if( t12 && t12->is_con() ) {
|
||||
int shift_con = t12->get_con();
|
||||
jlong mask = max_julong >> shift_con;
|
||||
if( t12 && t12->is_con() ) { // Shift is by a constant
|
||||
int shift = t12->get_con();
|
||||
shift &= BitsPerJavaLong - 1; // semantics of Java shifts
|
||||
jlong mask = max_julong >> shift;
|
||||
if( (mask&con) == mask ) // If AND is useless, skip it
|
||||
return usr;
|
||||
}
|
||||
@ -605,8 +607,8 @@ Node *AndLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
|
||||
const TypeInt *t12 = phase->type(rsh->in(2))->isa_int();
|
||||
if( t12 && t12->is_con() ) { // Shift is by a constant
|
||||
int shift = t12->get_con();
|
||||
shift &= (BitsPerJavaInteger*2)-1; // semantics of Java shifts
|
||||
const jlong sign_bits_mask = ~(((jlong)CONST64(1) << (jlong)(BitsPerJavaInteger*2 - shift)) -1);
|
||||
shift &= BitsPerJavaLong - 1; // semantics of Java shifts
|
||||
const jlong sign_bits_mask = ~(((jlong)CONST64(1) << (jlong)(BitsPerJavaLong - shift)) -1);
|
||||
// If the AND'ing of the 2 masks has no bits, then only original shifted
|
||||
// bits survive. NO sign-extension bits survive the maskings.
|
||||
if( (sign_bits_mask & mask) == 0 ) {
|
||||
@ -786,7 +788,7 @@ Node *LShiftLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
|
||||
|
||||
// Check for ((x & ((CONST64(1)<<(64-c0))-1)) << c0) which ANDs off high bits
|
||||
// before shifting them away.
|
||||
const jlong bits_mask = ((jlong)CONST64(1) << (jlong)(BitsPerJavaInteger*2 - con)) - CONST64(1);
|
||||
const jlong bits_mask = ((jlong)CONST64(1) << (jlong)(BitsPerJavaLong - con)) - CONST64(1);
|
||||
if( add1_op == Op_AndL &&
|
||||
phase->type(add1->in(2)) == TypeLong::make( bits_mask ) )
|
||||
return new (phase->C, 3) LShiftLNode( add1->in(1), in(2) );
|
||||
@ -820,7 +822,7 @@ const Type *LShiftLNode::Value( PhaseTransform *phase ) const {
|
||||
return TypeLong::LONG;
|
||||
|
||||
uint shift = r2->get_con();
|
||||
shift &= (BitsPerJavaInteger*2)-1; // semantics of Java shifts
|
||||
shift &= BitsPerJavaLong - 1; // semantics of Java shifts
|
||||
// Shift by a multiple of 64 does nothing:
|
||||
if (shift == 0) return t1;
|
||||
|
||||
@ -1235,7 +1237,7 @@ Node *URShiftLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
|
||||
if ( con == 0 ) return NULL; // let Identity() handle a 0 shift count
|
||||
// note: mask computation below does not work for 0 shift count
|
||||
// We'll be wanting the right-shift amount as a mask of that many bits
|
||||
const jlong mask = (((jlong)CONST64(1) << (jlong)(BitsPerJavaInteger*2 - con)) -1);
|
||||
const jlong mask = (((jlong)CONST64(1) << (jlong)(BitsPerJavaLong - con)) -1);
|
||||
|
||||
// Check for ((x << z) + Y) >>> z. Replace with x + con>>>z
|
||||
// The idiom for rounding to a power of 2 is "(Q+(2^z-1)) >>> z".
|
||||
@ -1302,7 +1304,7 @@ const Type *URShiftLNode::Value( PhaseTransform *phase ) const {
|
||||
|
||||
if (r2->is_con()) {
|
||||
uint shift = r2->get_con();
|
||||
shift &= (2*BitsPerJavaInteger)-1; // semantics of Java shifts
|
||||
shift &= BitsPerJavaLong - 1; // semantics of Java shifts
|
||||
// Shift by a multiple of 64 does nothing:
|
||||
if (shift == 0) return t1;
|
||||
// Calculate reasonably aggressive bounds for the result.
|
||||
@ -1325,7 +1327,7 @@ const Type *URShiftLNode::Value( PhaseTransform *phase ) const {
|
||||
const TypeLong* tl = TypeLong::make(lo, hi, MAX2(r1->_widen,r2->_widen));
|
||||
#ifdef ASSERT
|
||||
// Make sure we get the sign-capture idiom correct.
|
||||
if (shift == (2*BitsPerJavaInteger)-1) {
|
||||
if (shift == BitsPerJavaLong - 1) {
|
||||
if (r1->_lo >= 0) assert(tl == TypeLong::ZERO, ">>>63 of + is 0");
|
||||
if (r1->_hi < 0) assert(tl == TypeLong::ONE, ">>>63 of - is +1");
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1997-2009 Sun Microsystems, 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
|
||||
@ -74,6 +74,7 @@ extern int BytesPerHeapOop;
|
||||
extern int BitsPerHeapOop;
|
||||
|
||||
const int BitsPerJavaInteger = 32;
|
||||
const int BitsPerJavaLong = 64;
|
||||
const int BitsPerSize_t = size_tSize * BitsPerByte;
|
||||
|
||||
// Size of a char[] needed to represent a jint as a string in decimal.
|
||||
|
48
hotspot/test/compiler/6795362/Test6795362.java
Normal file
48
hotspot/test/compiler/6795362/Test6795362.java
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2009 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 6795362
|
||||
* @summary 32bit server compiler leads to wrong results on solaris-x86
|
||||
*
|
||||
* @run main/othervm -Xcomp -XX:CompileOnly=Test6795362.sub Test6795362
|
||||
*/
|
||||
|
||||
public class Test6795362 {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
sub();
|
||||
|
||||
if (var_bad != 0)
|
||||
throw new InternalError(var_bad + " != 0");
|
||||
}
|
||||
|
||||
static long var_bad = -1L;
|
||||
|
||||
static void sub()
|
||||
{
|
||||
var_bad >>= 65;
|
||||
var_bad /= 65;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user