src/share/vm/opto/divnode.cpp

Print this page




 693   const Type *t2 = phase->type( in(2) );
 694   if( t1 == Type::TOP ) return Type::TOP;
 695   if( t2 == Type::TOP ) return Type::TOP;
 696 
 697   // Either input is BOTTOM ==> the result is the local BOTTOM
 698   const Type *bot = bottom_type();
 699   if( (t1 == bot) || (t2 == bot) ||
 700       (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) )
 701     return bot;
 702 
 703   // x/x == 1, we ignore 0/0.
 704   // Note: if t1 and t2 are zero then result is NaN (JVMS page 213)
 705   // Does not work for variables because of NaN's
 706   if( phase->eqv( in(1), in(2) ) && t1->base() == Type::DoubleCon)
 707     if (!g_isnan(t1->getd()) && g_isfinite(t1->getd()) && t1->getd() != 0.0) // could be negative ZERO or NaN
 708       return TypeD::ONE;
 709 
 710   if( t2 == TypeD::ONE )
 711     return t1;
 712 






 713   // If divisor is a constant and not zero, divide them numbers
 714   if( t1->base() == Type::DoubleCon &&
 715       t2->base() == Type::DoubleCon &&
 716       t2->getd() != 0.0 ) // could be negative zero
 717     return TypeD::make( t1->getd()/t2->getd() );

 718 
 719   // If the dividend is a constant zero
 720   // Note: if t1 and t2 are zero then result is NaN (JVMS page 213)
 721   // Test TypeF::ZERO is not sufficient as it could be negative zero
 722   if( t1 == TypeD::ZERO && !g_isnan(t2->getd()) && t2->getd() != 0.0 )
 723     return TypeD::ZERO;
 724 
 725   // Otherwise we give up all hope
 726   return Type::DOUBLE;
 727 }
 728 
 729 
 730 //------------------------------isA_Copy---------------------------------------
 731 // Dividing by self is 1.
 732 // If the divisor is 1, we are an identity on the dividend.
 733 Node *DivDNode::Identity( PhaseTransform *phase ) {
 734   return (phase->type( in(2) ) == TypeD::ONE) ? in(1) : this;
 735 }
 736 
 737 //------------------------------Idealize---------------------------------------




 693   const Type *t2 = phase->type( in(2) );
 694   if( t1 == Type::TOP ) return Type::TOP;
 695   if( t2 == Type::TOP ) return Type::TOP;
 696 
 697   // Either input is BOTTOM ==> the result is the local BOTTOM
 698   const Type *bot = bottom_type();
 699   if( (t1 == bot) || (t2 == bot) ||
 700       (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) )
 701     return bot;
 702 
 703   // x/x == 1, we ignore 0/0.
 704   // Note: if t1 and t2 are zero then result is NaN (JVMS page 213)
 705   // Does not work for variables because of NaN's
 706   if( phase->eqv( in(1), in(2) ) && t1->base() == Type::DoubleCon)
 707     if (!g_isnan(t1->getd()) && g_isfinite(t1->getd()) && t1->getd() != 0.0) // could be negative ZERO or NaN
 708       return TypeD::ONE;
 709 
 710   if( t2 == TypeD::ONE )
 711     return t1;
 712 
 713 #if defined(IA32)
 714   if (!phase->C->method()->is_strict())
 715     // Can't trust native compilers to properly fold strict double
 716     // multiplication with round-to-zero on this platform.
 717 #endif
 718     {
 719       // If divisor is a constant and not zero, divide them numbers
 720       if( t1->base() == Type::DoubleCon &&
 721           t2->base() == Type::DoubleCon &&
 722           t2->getd() != 0.0 ) // could be negative zero
 723         return TypeD::make( t1->getd()/t2->getd() );
 724     }
 725 
 726   // If the dividend is a constant zero
 727   // Note: if t1 and t2 are zero then result is NaN (JVMS page 213)
 728   // Test TypeF::ZERO is not sufficient as it could be negative zero
 729   if( t1 == TypeD::ZERO && !g_isnan(t2->getd()) && t2->getd() != 0.0 )
 730     return TypeD::ZERO;
 731 
 732   // Otherwise we give up all hope
 733   return Type::DOUBLE;
 734 }
 735 
 736 
 737 //------------------------------isA_Copy---------------------------------------
 738 // Dividing by self is 1.
 739 // If the divisor is 1, we are an identity on the dividend.
 740 Node *DivDNode::Identity( PhaseTransform *phase ) {
 741   return (phase->type( in(2) ) == TypeD::ONE) ? in(1) : this;
 742 }
 743 
 744 //------------------------------Idealize---------------------------------------