44 #include "math.h" |
44 #include "math.h" |
45 |
45 |
46 //============================================================================= |
46 //============================================================================= |
47 //------------------------------Identity--------------------------------------- |
47 //------------------------------Identity--------------------------------------- |
48 // If right input is a constant 0, return the left input. |
48 // If right input is a constant 0, return the left input. |
49 Node *SubNode::Identity( PhaseTransform *phase ) { |
49 Node* SubNode::Identity(PhaseGVN* phase) { |
50 assert(in(1) != this, "Must already have called Value"); |
50 assert(in(1) != this, "Must already have called Value"); |
51 assert(in(2) != this, "Must already have called Value"); |
51 assert(in(2) != this, "Must already have called Value"); |
52 |
52 |
53 // Remove double negation |
53 // Remove double negation |
54 const Type *zero = add_id(); |
54 const Type *zero = add_id(); |
376 } |
376 } |
377 |
377 |
378 //============================================================================= |
378 //============================================================================= |
379 //------------------------------Value------------------------------------------ |
379 //------------------------------Value------------------------------------------ |
380 // A subtract node differences its two inputs. |
380 // A subtract node differences its two inputs. |
381 const Type *SubFPNode::Value( PhaseTransform *phase ) const { |
381 const Type* SubFPNode::Value(PhaseGVN* phase) const { |
382 const Node* in1 = in(1); |
382 const Node* in1 = in(1); |
383 const Node* in2 = in(2); |
383 const Node* in2 = in(2); |
384 // Either input is TOP ==> the result is TOP |
384 // Either input is TOP ==> the result is TOP |
385 const Type* t1 = (in1 == this) ? Type::TOP : phase->type(in1); |
385 const Type* t1 = (in1 == this) ? Type::TOP : phase->type(in1); |
386 if( t1 == Type::TOP ) return Type::TOP; |
386 if( t1 == Type::TOP ) return Type::TOP; |
492 //============================================================================= |
492 //============================================================================= |
493 //------------------------------Idealize--------------------------------------- |
493 //------------------------------Idealize--------------------------------------- |
494 // Unlike SubNodes, compare must still flatten return value to the |
494 // Unlike SubNodes, compare must still flatten return value to the |
495 // range -1, 0, 1. |
495 // range -1, 0, 1. |
496 // And optimizations like those for (X + Y) - X fail if overflow happens. |
496 // And optimizations like those for (X + Y) - X fail if overflow happens. |
497 Node *CmpNode::Identity( PhaseTransform *phase ) { |
497 Node* CmpNode::Identity(PhaseGVN* phase) { |
498 return this; |
498 return this; |
499 } |
499 } |
500 |
500 |
501 #ifndef PRODUCT |
501 #ifndef PRODUCT |
502 //----------------------------related------------------------------------------ |
502 //----------------------------related------------------------------------------ |
609 if ((jint)lo0 >= 0 && (jint)lo1 >= 0 && is_index_range_check()) |
609 if ((jint)lo0 >= 0 && (jint)lo1 >= 0 && is_index_range_check()) |
610 return TypeInt::CC_LT; |
610 return TypeInt::CC_LT; |
611 return TypeInt::CC; // else use worst case results |
611 return TypeInt::CC; // else use worst case results |
612 } |
612 } |
613 |
613 |
614 const Type* CmpUNode::Value(PhaseTransform *phase) const { |
614 const Type* CmpUNode::Value(PhaseGVN* phase) const { |
615 const Type* t = SubNode::Value_common(phase); |
615 const Type* t = SubNode::Value_common(phase); |
616 if (t != NULL) { |
616 if (t != NULL) { |
617 return t; |
617 return t; |
618 } |
618 } |
619 const Node* in1 = in(1); |
619 const Node* in1 = in(1); |
1051 |
1051 |
1052 //============================================================================= |
1052 //============================================================================= |
1053 //------------------------------Value------------------------------------------ |
1053 //------------------------------Value------------------------------------------ |
1054 // Simplify an CmpF (compare 2 floats ) node, based on local information. |
1054 // Simplify an CmpF (compare 2 floats ) node, based on local information. |
1055 // If both inputs are constants, compare them. |
1055 // If both inputs are constants, compare them. |
1056 const Type *CmpFNode::Value( PhaseTransform *phase ) const { |
1056 const Type* CmpFNode::Value(PhaseGVN* phase) const { |
1057 const Node* in1 = in(1); |
1057 const Node* in1 = in(1); |
1058 const Node* in2 = in(2); |
1058 const Node* in2 = in(2); |
1059 // Either input is TOP ==> the result is TOP |
1059 // Either input is TOP ==> the result is TOP |
1060 const Type* t1 = (in1 == this) ? Type::TOP : phase->type(in1); |
1060 const Type* t1 = (in1 == this) ? Type::TOP : phase->type(in1); |
1061 if( t1 == Type::TOP ) return Type::TOP; |
1061 if( t1 == Type::TOP ) return Type::TOP; |
1081 |
1081 |
1082 //============================================================================= |
1082 //============================================================================= |
1083 //------------------------------Value------------------------------------------ |
1083 //------------------------------Value------------------------------------------ |
1084 // Simplify an CmpD (compare 2 doubles ) node, based on local information. |
1084 // Simplify an CmpD (compare 2 doubles ) node, based on local information. |
1085 // If both inputs are constants, compare them. |
1085 // If both inputs are constants, compare them. |
1086 const Type *CmpDNode::Value( PhaseTransform *phase ) const { |
1086 const Type* CmpDNode::Value(PhaseGVN* phase) const { |
1087 const Node* in1 = in(1); |
1087 const Node* in1 = in(1); |
1088 const Node* in2 = in(2); |
1088 const Node* in2 = in(2); |
1089 // Either input is TOP ==> the result is TOP |
1089 // Either input is TOP ==> the result is TOP |
1090 const Type* t1 = (in1 == this) ? Type::TOP : phase->type(in1); |
1090 const Type* t1 = (in1 == this) ? Type::TOP : phase->type(in1); |
1091 if( t1 == Type::TOP ) return Type::TOP; |
1091 if( t1 == Type::TOP ) return Type::TOP; |
1421 } |
1421 } |
1422 |
1422 |
1423 //------------------------------Value------------------------------------------ |
1423 //------------------------------Value------------------------------------------ |
1424 // Simplify a Bool (convert condition codes to boolean (1 or 0)) node, |
1424 // Simplify a Bool (convert condition codes to boolean (1 or 0)) node, |
1425 // based on local information. If the input is constant, do it. |
1425 // based on local information. If the input is constant, do it. |
1426 const Type *BoolNode::Value( PhaseTransform *phase ) const { |
1426 const Type* BoolNode::Value(PhaseGVN* phase) const { |
1427 return _test.cc2logical( phase->type( in(1) ) ); |
1427 return _test.cc2logical( phase->type( in(1) ) ); |
1428 } |
1428 } |
1429 |
1429 |
1430 #ifndef PRODUCT |
1430 #ifndef PRODUCT |
1431 //------------------------------dump_spec-------------------------------------- |
1431 //------------------------------dump_spec-------------------------------------- |
1464 } |
1464 } |
1465 |
1465 |
1466 //============================================================================= |
1466 //============================================================================= |
1467 //------------------------------Value------------------------------------------ |
1467 //------------------------------Value------------------------------------------ |
1468 // Compute sqrt |
1468 // Compute sqrt |
1469 const Type *SqrtDNode::Value( PhaseTransform *phase ) const { |
1469 const Type* SqrtDNode::Value(PhaseGVN* phase) const { |
1470 const Type *t1 = phase->type( in(1) ); |
1470 const Type *t1 = phase->type( in(1) ); |
1471 if( t1 == Type::TOP ) return Type::TOP; |
1471 if( t1 == Type::TOP ) return Type::TOP; |
1472 if( t1->base() != Type::DoubleCon ) return Type::DOUBLE; |
1472 if( t1->base() != Type::DoubleCon ) return Type::DOUBLE; |
1473 double d = t1->getd(); |
1473 double d = t1->getd(); |
1474 if( d < 0.0 ) return Type::DOUBLE; |
1474 if( d < 0.0 ) return Type::DOUBLE; |
1476 } |
1476 } |
1477 |
1477 |
1478 //============================================================================= |
1478 //============================================================================= |
1479 //------------------------------Value------------------------------------------ |
1479 //------------------------------Value------------------------------------------ |
1480 // Compute tan |
1480 // Compute tan |
1481 const Type *TanDNode::Value( PhaseTransform *phase ) const { |
1481 const Type* TanDNode::Value(PhaseGVN* phase) const { |
1482 const Type *t1 = phase->type( in(1) ); |
1482 const Type *t1 = phase->type( in(1) ); |
1483 if( t1 == Type::TOP ) return Type::TOP; |
1483 if( t1 == Type::TOP ) return Type::TOP; |
1484 if( t1->base() != Type::DoubleCon ) return Type::DOUBLE; |
1484 if( t1->base() != Type::DoubleCon ) return Type::DOUBLE; |
1485 double d = t1->getd(); |
1485 double d = t1->getd(); |
1486 return TypeD::make( StubRoutines::intrinsic_tan( d ) ); |
1486 return TypeD::make( StubRoutines::intrinsic_tan( d ) ); |
1487 } |
1487 } |
1488 |
1488 |
1489 //============================================================================= |
1489 //============================================================================= |
1490 //------------------------------Value------------------------------------------ |
1490 //------------------------------Value------------------------------------------ |
1491 // Compute log10 |
1491 // Compute log10 |
1492 const Type *Log10DNode::Value( PhaseTransform *phase ) const { |
1492 const Type* Log10DNode::Value(PhaseGVN* phase) const { |
1493 const Type *t1 = phase->type( in(1) ); |
1493 const Type *t1 = phase->type( in(1) ); |
1494 if( t1 == Type::TOP ) return Type::TOP; |
1494 if( t1 == Type::TOP ) return Type::TOP; |
1495 if( t1->base() != Type::DoubleCon ) return Type::DOUBLE; |
1495 if( t1->base() != Type::DoubleCon ) return Type::DOUBLE; |
1496 double d = t1->getd(); |
1496 double d = t1->getd(); |
1497 return TypeD::make( StubRoutines::intrinsic_log10( d ) ); |
1497 return TypeD::make( StubRoutines::intrinsic_log10( d ) ); |