< prev index next >
src/share/vm/opto/convertnode.cpp
Print this page
*** 75,85 ****
//------------------------------Identity---------------------------------------
// Float's can be converted to doubles with no loss of bits. Hence
// converting a float to a double and back to a float is a NOP.
Node* ConvD2FNode::Identity(PhaseGVN* phase) {
! return (in(1)->Opcode() == Op_ConvF2D) ? in(1)->in(1) : this;
}
//=============================================================================
//------------------------------Value------------------------------------------
const Type* ConvD2INode::Value(PhaseGVN* phase) const {
--- 75,85 ----
//------------------------------Identity---------------------------------------
// Float's can be converted to doubles with no loss of bits. Hence
// converting a float to a double and back to a float is a NOP.
Node* ConvD2FNode::Identity(PhaseGVN* phase) {
! return (in(1)->Opcode() == Opcodes::Op_ConvF2D) ? in(1)->in(1) : this;
}
//=============================================================================
//------------------------------Value------------------------------------------
const Type* ConvD2INode::Value(PhaseGVN* phase) const {
*** 91,110 ****
}
//------------------------------Ideal------------------------------------------
// If converting to an int type, skip any rounding nodes
Node *ConvD2INode::Ideal(PhaseGVN *phase, bool can_reshape) {
! if( in(1)->Opcode() == Op_RoundDouble )
set_req(1,in(1)->in(1));
return NULL;
}
//------------------------------Identity---------------------------------------
// Int's can be converted to doubles with no loss of bits. Hence
// converting an integer to a double and back to an integer is a NOP.
Node* ConvD2INode::Identity(PhaseGVN* phase) {
! return (in(1)->Opcode() == Op_ConvI2D) ? in(1)->in(1) : this;
}
//=============================================================================
//------------------------------Value------------------------------------------
const Type* ConvD2LNode::Value(PhaseGVN* phase) const {
--- 91,110 ----
}
//------------------------------Ideal------------------------------------------
// If converting to an int type, skip any rounding nodes
Node *ConvD2INode::Ideal(PhaseGVN *phase, bool can_reshape) {
! if( in(1)->Opcode() == Opcodes::Op_RoundDouble )
set_req(1,in(1)->in(1));
return NULL;
}
//------------------------------Identity---------------------------------------
// Int's can be converted to doubles with no loss of bits. Hence
// converting an integer to a double and back to an integer is a NOP.
Node* ConvD2INode::Identity(PhaseGVN* phase) {
! return (in(1)->Opcode() == Opcodes::Op_ConvI2D) ? in(1)->in(1) : this;
}
//=============================================================================
//------------------------------Value------------------------------------------
const Type* ConvD2LNode::Value(PhaseGVN* phase) const {
*** 116,135 ****
}
//------------------------------Identity---------------------------------------
Node* ConvD2LNode::Identity(PhaseGVN* phase) {
// Remove ConvD2L->ConvL2D->ConvD2L sequences.
! if( in(1) ->Opcode() == Op_ConvL2D &&
! in(1)->in(1)->Opcode() == Op_ConvD2L )
return in(1)->in(1);
return this;
}
//------------------------------Ideal------------------------------------------
// If converting to an int type, skip any rounding nodes
Node *ConvD2LNode::Ideal(PhaseGVN *phase, bool can_reshape) {
! if( in(1)->Opcode() == Op_RoundDouble )
set_req(1,in(1)->in(1));
return NULL;
}
//=============================================================================
--- 116,135 ----
}
//------------------------------Identity---------------------------------------
Node* ConvD2LNode::Identity(PhaseGVN* phase) {
// Remove ConvD2L->ConvL2D->ConvD2L sequences.
! if( in(1) ->Opcode() == Opcodes::Op_ConvL2D &&
! in(1)->in(1)->Opcode() == Opcodes::Op_ConvD2L )
return in(1)->in(1);
return this;
}
//------------------------------Ideal------------------------------------------
// If converting to an int type, skip any rounding nodes
Node *ConvD2LNode::Ideal(PhaseGVN *phase, bool can_reshape) {
! if( in(1)->Opcode() == Opcodes::Op_RoundDouble )
set_req(1,in(1)->in(1));
return NULL;
}
//=============================================================================
*** 153,172 ****
}
//------------------------------Identity---------------------------------------
Node* ConvF2INode::Identity(PhaseGVN* phase) {
// Remove ConvF2I->ConvI2F->ConvF2I sequences.
! if( in(1) ->Opcode() == Op_ConvI2F &&
! in(1)->in(1)->Opcode() == Op_ConvF2I )
return in(1)->in(1);
return this;
}
//------------------------------Ideal------------------------------------------
// If converting to an int type, skip any rounding nodes
Node *ConvF2INode::Ideal(PhaseGVN *phase, bool can_reshape) {
! if( in(1)->Opcode() == Op_RoundFloat )
set_req(1,in(1)->in(1));
return NULL;
}
//=============================================================================
--- 153,172 ----
}
//------------------------------Identity---------------------------------------
Node* ConvF2INode::Identity(PhaseGVN* phase) {
// Remove ConvF2I->ConvI2F->ConvF2I sequences.
! if( in(1) ->Opcode() == Opcodes::Op_ConvI2F &&
! in(1)->in(1)->Opcode() == Opcodes::Op_ConvF2I )
return in(1)->in(1);
return this;
}
//------------------------------Ideal------------------------------------------
// If converting to an int type, skip any rounding nodes
Node *ConvF2INode::Ideal(PhaseGVN *phase, bool can_reshape) {
! if( in(1)->Opcode() == Opcodes::Op_RoundFloat )
set_req(1,in(1)->in(1));
return NULL;
}
//=============================================================================
*** 180,199 ****
}
//------------------------------Identity---------------------------------------
Node* ConvF2LNode::Identity(PhaseGVN* phase) {
// Remove ConvF2L->ConvL2F->ConvF2L sequences.
! if( in(1) ->Opcode() == Op_ConvL2F &&
! in(1)->in(1)->Opcode() == Op_ConvF2L )
return in(1)->in(1);
return this;
}
//------------------------------Ideal------------------------------------------
// If converting to an int type, skip any rounding nodes
Node *ConvF2LNode::Ideal(PhaseGVN *phase, bool can_reshape) {
! if( in(1)->Opcode() == Op_RoundFloat )
set_req(1,in(1)->in(1));
return NULL;
}
//=============================================================================
--- 180,199 ----
}
//------------------------------Identity---------------------------------------
Node* ConvF2LNode::Identity(PhaseGVN* phase) {
// Remove ConvF2L->ConvL2F->ConvF2L sequences.
! if( in(1) ->Opcode() == Opcodes::Op_ConvL2F &&
! in(1)->in(1)->Opcode() == Opcodes::Op_ConvF2L )
return in(1)->in(1);
return this;
}
//------------------------------Ideal------------------------------------------
// If converting to an int type, skip any rounding nodes
Node *ConvF2LNode::Ideal(PhaseGVN *phase, bool can_reshape) {
! if( in(1)->Opcode() == Opcodes::Op_RoundFloat )
set_req(1,in(1)->in(1));
return NULL;
}
//=============================================================================
*** 217,228 ****
}
//------------------------------Identity---------------------------------------
Node* ConvI2FNode::Identity(PhaseGVN* phase) {
// Remove ConvI2F->ConvF2I->ConvI2F sequences.
! if( in(1) ->Opcode() == Op_ConvF2I &&
! in(1)->in(1)->Opcode() == Op_ConvI2F )
return in(1)->in(1);
return this;
}
//=============================================================================
--- 217,228 ----
}
//------------------------------Identity---------------------------------------
Node* ConvI2FNode::Identity(PhaseGVN* phase) {
// Remove ConvI2F->ConvF2I->ConvI2F sequences.
! if( in(1) ->Opcode() == Opcodes::Op_ConvF2I &&
! in(1)->in(1)->Opcode() == Opcodes::Op_ConvI2F )
return in(1)->in(1);
return this;
}
//=============================================================================
*** 316,334 ****
// possible before the I2L conversion, because 32-bit math is cheaper.
// There's no common reason to "leak" a constant offset through the I2L.
// Addressing arithmetic will not absorb it as part of a 64-bit AddL.
Node* z = in(1);
! int op = z->Opcode();
Node* ctrl = NULL;
! if (op == Op_CastII && z->as_CastII()->has_range_check()) {
// Skip CastII node but save control dependency
ctrl = z->in(0);
z = z->in(1);
op = z->Opcode();
}
! if (op == Op_AddI || op == Op_SubI) {
Node* x = z->in(1);
Node* y = z->in(2);
assert (x != z && y != z, "dead loop in ConvI2LNode::Ideal");
if (phase->type(x) == Type::TOP) return this_changed;
if (phase->type(y) == Type::TOP) return this_changed;
--- 316,334 ----
// possible before the I2L conversion, because 32-bit math is cheaper.
// There's no common reason to "leak" a constant offset through the I2L.
// Addressing arithmetic will not absorb it as part of a 64-bit AddL.
Node* z = in(1);
! Opcodes op = z->Opcode();
Node* ctrl = NULL;
! if (op == Opcodes::Op_CastII && z->as_CastII()->has_range_check()) {
// Skip CastII node but save control dependency
ctrl = z->in(0);
z = z->in(1);
op = z->Opcode();
}
! if (op == Opcodes::Op_AddI || op == Opcodes::Op_SubI) {
Node* x = z->in(1);
Node* y = z->in(2);
assert (x != z && y != z, "dead loop in ConvI2LNode::Ideal");
if (phase->type(x) == Type::TOP) return this_changed;
if (phase->type(y) == Type::TOP) return this_changed;
*** 341,351 ****
jlong yhi = ty->_hi;
jlong zlo = tz->_lo;
jlong zhi = tz->_hi;
jlong vbit = CONST64(1) << BitsPerInt;
int widen = MAX2(tx->_widen, ty->_widen);
! if (op == Op_SubI) {
jlong ylo0 = ylo;
ylo = -yhi;
yhi = -ylo0;
}
// See if x+y can cause positive overflow into z+2**32
--- 341,351 ----
jlong yhi = ty->_hi;
jlong zlo = tz->_lo;
jlong zhi = tz->_hi;
jlong vbit = CONST64(1) << BitsPerInt;
int widen = MAX2(tx->_widen, ty->_widen);
! if (op == Opcodes::Op_SubI) {
jlong ylo0 = ylo;
ylo = -yhi;
yhi = -ylo0;
}
// See if x+y can cause positive overflow into z+2**32
*** 376,397 ****
jlong rylo = MAX2(ylo, zlo - xhi);
jlong ryhi = MIN2(yhi, zhi - xlo);
if (rxlo > rxhi || rylo > ryhi) {
return this_changed; // x or y is dying; don't mess w/ it
}
! if (op == Op_SubI) {
jlong rylo0 = rylo;
rylo = -ryhi;
ryhi = -rylo0;
}
assert(rxlo == (int)rxlo && rxhi == (int)rxhi, "x should not overflow");
assert(rylo == (int)rylo && ryhi == (int)ryhi, "y should not overflow");
Node* cx = phase->C->constrained_convI2L(phase, x, TypeInt::make(rxlo, rxhi, widen), ctrl);
Node* cy = phase->C->constrained_convI2L(phase, y, TypeInt::make(rylo, ryhi, widen), ctrl);
switch (op) {
! case Op_AddI: return new AddLNode(cx, cy);
! case Op_SubI: return new SubLNode(cx, cy);
default: ShouldNotReachHere();
}
}
#endif //_LP64
--- 376,397 ----
jlong rylo = MAX2(ylo, zlo - xhi);
jlong ryhi = MIN2(yhi, zhi - xlo);
if (rxlo > rxhi || rylo > ryhi) {
return this_changed; // x or y is dying; don't mess w/ it
}
! if (op == Opcodes::Op_SubI) {
jlong rylo0 = rylo;
rylo = -ryhi;
ryhi = -rylo0;
}
assert(rxlo == (int)rxlo && rxhi == (int)rxhi, "x should not overflow");
assert(rylo == (int)rylo && ryhi == (int)ryhi, "y should not overflow");
Node* cx = phase->C->constrained_convI2L(phase, x, TypeInt::make(rxlo, rxhi, widen), ctrl);
Node* cy = phase->C->constrained_convI2L(phase, y, TypeInt::make(rylo, ryhi, widen), ctrl);
switch (op) {
! case Opcodes::Op_AddI: return new AddLNode(cx, cy);
! case Opcodes::Op_SubI: return new SubLNode(cx, cy);
default: ShouldNotReachHere();
}
}
#endif //_LP64
*** 420,430 ****
//=============================================================================
//----------------------------Identity-----------------------------------------
Node* ConvL2INode::Identity(PhaseGVN* phase) {
// Convert L2I(I2L(x)) => x
! if (in(1)->Opcode() == Op_ConvI2L) return in(1)->in(1);
return this;
}
//------------------------------Value------------------------------------------
const Type* ConvL2INode::Value(PhaseGVN* phase) const {
--- 420,430 ----
//=============================================================================
//----------------------------Identity-----------------------------------------
Node* ConvL2INode::Identity(PhaseGVN* phase) {
// Convert L2I(I2L(x)) => x
! if (in(1)->Opcode() == Opcodes::Op_ConvI2L) return in(1)->in(1);
return this;
}
//------------------------------Value------------------------------------------
const Type* ConvL2INode::Value(PhaseGVN* phase) const {
*** 440,461 ****
//------------------------------Ideal------------------------------------------
// Return a node which is more "ideal" than the current node.
// Blow off prior masking to int
Node *ConvL2INode::Ideal(PhaseGVN *phase, bool can_reshape) {
Node *andl = in(1);
! uint andl_op = andl->Opcode();
! if( andl_op == Op_AndL ) {
// Blow off prior masking to int
if( phase->type(andl->in(2)) == TypeLong::make( 0xFFFFFFFF ) ) {
set_req(1,andl->in(1));
return this;
}
}
// Swap with a prior add: convL2I(addL(x,y)) ==> addI(convL2I(x),convL2I(y))
// This replaces an 'AddL' with an 'AddI'.
! if( andl_op == Op_AddL ) {
// Don't do this for nodes which have more than one user since
// we'll end up computing the long add anyway.
if (andl->outcnt() > 1) return NULL;
Node* x = andl->in(1);
--- 440,461 ----
//------------------------------Ideal------------------------------------------
// Return a node which is more "ideal" than the current node.
// Blow off prior masking to int
Node *ConvL2INode::Ideal(PhaseGVN *phase, bool can_reshape) {
Node *andl = in(1);
! Opcodes andl_op = andl->Opcode();
! if( andl_op == Opcodes::Op_AndL ) {
// Blow off prior masking to int
if( phase->type(andl->in(2)) == TypeLong::make( 0xFFFFFFFF ) ) {
set_req(1,andl->in(1));
return this;
}
}
// Swap with a prior add: convL2I(addL(x,y)) ==> addI(convL2I(x),convL2I(y))
// This replaces an 'AddL' with an 'AddI'.
! if( andl_op == Opcodes::Op_AddL ) {
// Don't do this for nodes which have more than one user since
// we'll end up computing the long add anyway.
if (andl->outcnt() > 1) return NULL;
Node* x = andl->in(1);
*** 481,496 ****
// Remove redundant roundings
Node* RoundFloatNode::Identity(PhaseGVN* phase) {
assert(Matcher::strict_fp_requires_explicit_rounding, "should only generate for Intel");
// Do not round constants
if (phase->type(in(1))->base() == Type::FloatCon) return in(1);
! int op = in(1)->Opcode();
// Redundant rounding
! if( op == Op_RoundFloat ) return in(1);
// Already rounded
! if( op == Op_Parm ) return in(1);
! if( op == Op_LoadF ) return in(1);
return this;
}
//------------------------------Value------------------------------------------
const Type* RoundFloatNode::Value(PhaseGVN* phase) const {
--- 481,496 ----
// Remove redundant roundings
Node* RoundFloatNode::Identity(PhaseGVN* phase) {
assert(Matcher::strict_fp_requires_explicit_rounding, "should only generate for Intel");
// Do not round constants
if (phase->type(in(1))->base() == Type::FloatCon) return in(1);
! Opcodes op = in(1)->Opcode();
// Redundant rounding
! if( op == Opcodes::Op_RoundFloat ) return in(1);
// Already rounded
! if( op == Opcodes::Op_Parm ) return in(1);
! if( op == Opcodes::Op_LoadF ) return in(1);
return this;
}
//------------------------------Value------------------------------------------
const Type* RoundFloatNode::Value(PhaseGVN* phase) const {
*** 502,519 ****
// Remove redundant roundings. Incoming arguments are already rounded.
Node* RoundDoubleNode::Identity(PhaseGVN* phase) {
assert(Matcher::strict_fp_requires_explicit_rounding, "should only generate for Intel");
// Do not round constants
if (phase->type(in(1))->base() == Type::DoubleCon) return in(1);
! int op = in(1)->Opcode();
// Redundant rounding
! if( op == Op_RoundDouble ) return in(1);
// Already rounded
! if( op == Op_Parm ) return in(1);
! if( op == Op_LoadD ) return in(1);
! if( op == Op_ConvF2D ) return in(1);
! if( op == Op_ConvI2D ) return in(1);
return this;
}
//------------------------------Value------------------------------------------
const Type* RoundDoubleNode::Value(PhaseGVN* phase) const {
--- 502,519 ----
// Remove redundant roundings. Incoming arguments are already rounded.
Node* RoundDoubleNode::Identity(PhaseGVN* phase) {
assert(Matcher::strict_fp_requires_explicit_rounding, "should only generate for Intel");
// Do not round constants
if (phase->type(in(1))->base() == Type::DoubleCon) return in(1);
! Opcodes op = in(1)->Opcode();
// Redundant rounding
! if( op == Opcodes::Op_RoundDouble ) return in(1);
// Already rounded
! if( op == Opcodes::Op_Parm ) return in(1);
! if( op == Opcodes::Op_LoadD ) return in(1);
! if( op == Opcodes::Op_ConvF2D ) return in(1);
! if( op == Opcodes::Op_ConvI2D ) return in(1);
return this;
}
//------------------------------Value------------------------------------------
const Type* RoundDoubleNode::Value(PhaseGVN* phase) const {
< prev index next >