hotspot/src/share/vm/opto/divnode.cpp
changeset 35551 36ef3841fb34
parent 28956 998d9d0b33a4
child 40877 a7a6aada8883
equal deleted inserted replaced
35550:633a22d66bd7 35551:36ef3841fb34
   455 }
   455 }
   456 
   456 
   457 //=============================================================================
   457 //=============================================================================
   458 //------------------------------Identity---------------------------------------
   458 //------------------------------Identity---------------------------------------
   459 // If the divisor is 1, we are an identity on the dividend.
   459 // If the divisor is 1, we are an identity on the dividend.
   460 Node *DivINode::Identity( PhaseTransform *phase ) {
   460 Node* DivINode::Identity(PhaseGVN* phase) {
   461   return (phase->type( in(2) )->higher_equal(TypeInt::ONE)) ? in(1) : this;
   461   return (phase->type( in(2) )->higher_equal(TypeInt::ONE)) ? in(1) : this;
   462 }
   462 }
   463 
   463 
   464 //------------------------------Idealize---------------------------------------
   464 //------------------------------Idealize---------------------------------------
   465 // Divides can be changed to multiplies and/or shifts
   465 // Divides can be changed to multiplies and/or shifts
   491 }
   491 }
   492 
   492 
   493 //------------------------------Value------------------------------------------
   493 //------------------------------Value------------------------------------------
   494 // A DivINode divides its inputs.  The third input is a Control input, used to
   494 // A DivINode divides its inputs.  The third input is a Control input, used to
   495 // prevent hoisting the divide above an unsafe test.
   495 // prevent hoisting the divide above an unsafe test.
   496 const Type *DivINode::Value( PhaseTransform *phase ) const {
   496 const Type* DivINode::Value(PhaseGVN* phase) const {
   497   // Either input is TOP ==> the result is TOP
   497   // Either input is TOP ==> the result is TOP
   498   const Type *t1 = phase->type( in(1) );
   498   const Type *t1 = phase->type( in(1) );
   499   const Type *t2 = phase->type( in(2) );
   499   const Type *t2 = phase->type( in(2) );
   500   if( t1 == Type::TOP ) return Type::TOP;
   500   if( t1 == Type::TOP ) return Type::TOP;
   501   if( t2 == Type::TOP ) return Type::TOP;
   501   if( t2 == Type::TOP ) return Type::TOP;
   557 
   557 
   558 
   558 
   559 //=============================================================================
   559 //=============================================================================
   560 //------------------------------Identity---------------------------------------
   560 //------------------------------Identity---------------------------------------
   561 // If the divisor is 1, we are an identity on the dividend.
   561 // If the divisor is 1, we are an identity on the dividend.
   562 Node *DivLNode::Identity( PhaseTransform *phase ) {
   562 Node* DivLNode::Identity(PhaseGVN* phase) {
   563   return (phase->type( in(2) )->higher_equal(TypeLong::ONE)) ? in(1) : this;
   563   return (phase->type( in(2) )->higher_equal(TypeLong::ONE)) ? in(1) : this;
   564 }
   564 }
   565 
   565 
   566 //------------------------------Idealize---------------------------------------
   566 //------------------------------Idealize---------------------------------------
   567 // Dividing by a power of 2 is a shift.
   567 // Dividing by a power of 2 is a shift.
   593 }
   593 }
   594 
   594 
   595 //------------------------------Value------------------------------------------
   595 //------------------------------Value------------------------------------------
   596 // A DivLNode divides its inputs.  The third input is a Control input, used to
   596 // A DivLNode divides its inputs.  The third input is a Control input, used to
   597 // prevent hoisting the divide above an unsafe test.
   597 // prevent hoisting the divide above an unsafe test.
   598 const Type *DivLNode::Value( PhaseTransform *phase ) const {
   598 const Type* DivLNode::Value(PhaseGVN* phase) const {
   599   // Either input is TOP ==> the result is TOP
   599   // Either input is TOP ==> the result is TOP
   600   const Type *t1 = phase->type( in(1) );
   600   const Type *t1 = phase->type( in(1) );
   601   const Type *t2 = phase->type( in(2) );
   601   const Type *t2 = phase->type( in(2) );
   602   if( t1 == Type::TOP ) return Type::TOP;
   602   if( t1 == Type::TOP ) return Type::TOP;
   603   if( t2 == Type::TOP ) return Type::TOP;
   603   if( t2 == Type::TOP ) return Type::TOP;
   660 
   660 
   661 //=============================================================================
   661 //=============================================================================
   662 //------------------------------Value------------------------------------------
   662 //------------------------------Value------------------------------------------
   663 // An DivFNode divides its inputs.  The third input is a Control input, used to
   663 // An DivFNode divides its inputs.  The third input is a Control input, used to
   664 // prevent hoisting the divide above an unsafe test.
   664 // prevent hoisting the divide above an unsafe test.
   665 const Type *DivFNode::Value( PhaseTransform *phase ) const {
   665 const Type* DivFNode::Value(PhaseGVN* phase) const {
   666   // Either input is TOP ==> the result is TOP
   666   // Either input is TOP ==> the result is TOP
   667   const Type *t1 = phase->type( in(1) );
   667   const Type *t1 = phase->type( in(1) );
   668   const Type *t2 = phase->type( in(2) );
   668   const Type *t2 = phase->type( in(2) );
   669   if( t1 == Type::TOP ) return Type::TOP;
   669   if( t1 == Type::TOP ) return Type::TOP;
   670   if( t2 == Type::TOP ) return Type::TOP;
   670   if( t2 == Type::TOP ) return Type::TOP;
   703 }
   703 }
   704 
   704 
   705 //------------------------------isA_Copy---------------------------------------
   705 //------------------------------isA_Copy---------------------------------------
   706 // Dividing by self is 1.
   706 // Dividing by self is 1.
   707 // If the divisor is 1, we are an identity on the dividend.
   707 // If the divisor is 1, we are an identity on the dividend.
   708 Node *DivFNode::Identity( PhaseTransform *phase ) {
   708 Node* DivFNode::Identity(PhaseGVN* phase) {
   709   return (phase->type( in(2) ) == TypeF::ONE) ? in(1) : this;
   709   return (phase->type( in(2) ) == TypeF::ONE) ? in(1) : this;
   710 }
   710 }
   711 
   711 
   712 
   712 
   713 //------------------------------Idealize---------------------------------------
   713 //------------------------------Idealize---------------------------------------
   748 
   748 
   749 //=============================================================================
   749 //=============================================================================
   750 //------------------------------Value------------------------------------------
   750 //------------------------------Value------------------------------------------
   751 // An DivDNode divides its inputs.  The third input is a Control input, used to
   751 // An DivDNode divides its inputs.  The third input is a Control input, used to
   752 // prevent hoisting the divide above an unsafe test.
   752 // prevent hoisting the divide above an unsafe test.
   753 const Type *DivDNode::Value( PhaseTransform *phase ) const {
   753 const Type* DivDNode::Value(PhaseGVN* phase) const {
   754   // Either input is TOP ==> the result is TOP
   754   // Either input is TOP ==> the result is TOP
   755   const Type *t1 = phase->type( in(1) );
   755   const Type *t1 = phase->type( in(1) );
   756   const Type *t2 = phase->type( in(2) );
   756   const Type *t2 = phase->type( in(2) );
   757   if( t1 == Type::TOP ) return Type::TOP;
   757   if( t1 == Type::TOP ) return Type::TOP;
   758   if( t2 == Type::TOP ) return Type::TOP;
   758   if( t2 == Type::TOP ) return Type::TOP;
   798 
   798 
   799 
   799 
   800 //------------------------------isA_Copy---------------------------------------
   800 //------------------------------isA_Copy---------------------------------------
   801 // Dividing by self is 1.
   801 // Dividing by self is 1.
   802 // If the divisor is 1, we are an identity on the dividend.
   802 // If the divisor is 1, we are an identity on the dividend.
   803 Node *DivDNode::Identity( PhaseTransform *phase ) {
   803 Node* DivDNode::Identity(PhaseGVN* phase) {
   804   return (phase->type( in(2) ) == TypeD::ONE) ? in(1) : this;
   804   return (phase->type( in(2) ) == TypeD::ONE) ? in(1) : this;
   805 }
   805 }
   806 
   806 
   807 //------------------------------Idealize---------------------------------------
   807 //------------------------------Idealize---------------------------------------
   808 Node *DivDNode::Ideal(PhaseGVN *phase, bool can_reshape) {
   808 Node *DivDNode::Ideal(PhaseGVN *phase, bool can_reshape) {
   970   // return the value
   970   // return the value
   971   return result;
   971   return result;
   972 }
   972 }
   973 
   973 
   974 //------------------------------Value------------------------------------------
   974 //------------------------------Value------------------------------------------
   975 const Type *ModINode::Value( PhaseTransform *phase ) const {
   975 const Type* ModINode::Value(PhaseGVN* phase) const {
   976   // Either input is TOP ==> the result is TOP
   976   // Either input is TOP ==> the result is TOP
   977   const Type *t1 = phase->type( in(1) );
   977   const Type *t1 = phase->type( in(1) );
   978   const Type *t2 = phase->type( in(2) );
   978   const Type *t2 = phase->type( in(2) );
   979   if( t1 == Type::TOP ) return Type::TOP;
   979   if( t1 == Type::TOP ) return Type::TOP;
   980   if( t2 == Type::TOP ) return Type::TOP;
   980   if( t2 == Type::TOP ) return Type::TOP;
  1143   // return the value
  1143   // return the value
  1144   return result;
  1144   return result;
  1145 }
  1145 }
  1146 
  1146 
  1147 //------------------------------Value------------------------------------------
  1147 //------------------------------Value------------------------------------------
  1148 const Type *ModLNode::Value( PhaseTransform *phase ) const {
  1148 const Type* ModLNode::Value(PhaseGVN* phase) const {
  1149   // Either input is TOP ==> the result is TOP
  1149   // Either input is TOP ==> the result is TOP
  1150   const Type *t1 = phase->type( in(1) );
  1150   const Type *t1 = phase->type( in(1) );
  1151   const Type *t2 = phase->type( in(2) );
  1151   const Type *t2 = phase->type( in(2) );
  1152   if( t1 == Type::TOP ) return Type::TOP;
  1152   if( t1 == Type::TOP ) return Type::TOP;
  1153   if( t2 == Type::TOP ) return Type::TOP;
  1153   if( t2 == Type::TOP ) return Type::TOP;
  1184 }
  1184 }
  1185 
  1185 
  1186 
  1186 
  1187 //=============================================================================
  1187 //=============================================================================
  1188 //------------------------------Value------------------------------------------
  1188 //------------------------------Value------------------------------------------
  1189 const Type *ModFNode::Value( PhaseTransform *phase ) const {
  1189 const Type* ModFNode::Value(PhaseGVN* phase) const {
  1190   // Either input is TOP ==> the result is TOP
  1190   // Either input is TOP ==> the result is TOP
  1191   const Type *t1 = phase->type( in(1) );
  1191   const Type *t1 = phase->type( in(1) );
  1192   const Type *t2 = phase->type( in(2) );
  1192   const Type *t2 = phase->type( in(2) );
  1193   if( t1 == Type::TOP ) return Type::TOP;
  1193   if( t1 == Type::TOP ) return Type::TOP;
  1194   if( t2 == Type::TOP ) return Type::TOP;
  1194   if( t2 == Type::TOP ) return Type::TOP;
  1228 }
  1228 }
  1229 
  1229 
  1230 
  1230 
  1231 //=============================================================================
  1231 //=============================================================================
  1232 //------------------------------Value------------------------------------------
  1232 //------------------------------Value------------------------------------------
  1233 const Type *ModDNode::Value( PhaseTransform *phase ) const {
  1233 const Type* ModDNode::Value(PhaseGVN* phase) const {
  1234   // Either input is TOP ==> the result is TOP
  1234   // Either input is TOP ==> the result is TOP
  1235   const Type *t1 = phase->type( in(1) );
  1235   const Type *t1 = phase->type( in(1) );
  1236   const Type *t2 = phase->type( in(2) );
  1236   const Type *t2 = phase->type( in(2) );
  1237   if( t1 == Type::TOP ) return Type::TOP;
  1237   if( t1 == Type::TOP ) return Type::TOP;
  1238   if( t2 == Type::TOP ) return Type::TOP;
  1238   if( t2 == Type::TOP ) return Type::TOP;