src/share/vm/opto/mulnode.cpp

Print this page




 135 const Type *MulNode::Value( PhaseTransform *phase ) const {
 136   const Type *t1 = phase->type( in(1) );
 137   const Type *t2 = phase->type( in(2) );
 138   // Either input is TOP ==> the result is TOP
 139   if( t1 == Type::TOP ) return Type::TOP;
 140   if( t2 == Type::TOP ) return Type::TOP;
 141 
 142   // Either input is ZERO ==> the result is ZERO.
 143   // Not valid for floats or doubles since +0.0 * -0.0 --> +0.0
 144   int op = Opcode();
 145   if( op == Op_MulI || op == Op_AndI || op == Op_MulL || op == Op_AndL ) {
 146     const Type *zero = add_id();        // The multiplicative zero
 147     if( t1->higher_equal( zero ) ) return zero;
 148     if( t2->higher_equal( zero ) ) return zero;
 149   }
 150 
 151   // Either input is BOTTOM ==> the result is the local BOTTOM
 152   if( t1 == Type::BOTTOM || t2 == Type::BOTTOM )
 153     return bottom_type();
 154 








 155   return mul_ring(t1,t2);            // Local flavor of type multiplication
 156 }
 157 
 158 
 159 //=============================================================================
 160 //------------------------------Ideal------------------------------------------
 161 // Check for power-of-2 multiply, then try the regular MulNode::Ideal
 162 Node *MulINode::Ideal(PhaseGVN *phase, bool can_reshape) {
 163   // Swap constant to right
 164   jint con;
 165   if ((con = in(1)->find_int_con(0)) != 0) {
 166     swap_edges(1, 2);
 167     // Finish rest of method to use info in 'con'
 168   } else if ((con = in(2)->find_int_con(0)) == 0) {
 169     return MulNode::Ideal(phase, can_reshape);
 170   }
 171 
 172   // Now we have a constant Node on the right and the constant in con
 173   if( con == 0 ) return NULL;   // By zero is handled by Value call
 174   if( con == 1 ) return NULL;   // By one  is handled by Identity call


 343   } else {
 344     if( D < lo0 ) lo0 = D;
 345     if( C > hi0 ) hi0 = C;
 346   }
 347   return TypeLong::make(lo0, hi0, MAX2(r0->_widen,r1->_widen));
 348 }
 349 
 350 //=============================================================================
 351 //------------------------------mul_ring---------------------------------------
 352 // Compute the product type of two double ranges into this node.
 353 const Type *MulFNode::mul_ring(const Type *t0, const Type *t1) const {
 354   if( t0 == Type::FLOAT || t1 == Type::FLOAT ) return Type::FLOAT;
 355   return TypeF::make( t0->getf() * t1->getf() );
 356 }
 357 
 358 //=============================================================================
 359 //------------------------------mul_ring---------------------------------------
 360 // Compute the product type of two double ranges into this node.
 361 const Type *MulDNode::mul_ring(const Type *t0, const Type *t1) const {
 362   if( t0 == Type::DOUBLE || t1 == Type::DOUBLE ) return Type::DOUBLE;
 363   // We must be adding 2 double constants.
 364   return TypeD::make( t0->getd() * t1->getd() );
 365 }
 366 
 367 //=============================================================================
 368 //------------------------------Value------------------------------------------
 369 const Type *MulHiLNode::Value( PhaseTransform *phase ) const {
 370   // Either input is TOP ==> the result is TOP
 371   const Type *t1 = phase->type( in(1) );
 372   const Type *t2 = phase->type( in(2) );
 373   if( t1 == Type::TOP ) return Type::TOP;
 374   if( t2 == Type::TOP ) return Type::TOP;
 375 
 376   // Either input is BOTTOM ==> the result is the local BOTTOM
 377   const Type *bot = bottom_type();
 378   if( (t1 == bot) || (t2 == bot) ||
 379       (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) )
 380     return bot;
 381 
 382   // It is not worth trying to constant fold this stuff!
 383   return TypeLong::LONG;




 135 const Type *MulNode::Value( PhaseTransform *phase ) const {
 136   const Type *t1 = phase->type( in(1) );
 137   const Type *t2 = phase->type( in(2) );
 138   // Either input is TOP ==> the result is TOP
 139   if( t1 == Type::TOP ) return Type::TOP;
 140   if( t2 == Type::TOP ) return Type::TOP;
 141 
 142   // Either input is ZERO ==> the result is ZERO.
 143   // Not valid for floats or doubles since +0.0 * -0.0 --> +0.0
 144   int op = Opcode();
 145   if( op == Op_MulI || op == Op_AndI || op == Op_MulL || op == Op_AndL ) {
 146     const Type *zero = add_id();        // The multiplicative zero
 147     if( t1->higher_equal( zero ) ) return zero;
 148     if( t2->higher_equal( zero ) ) return zero;
 149   }
 150 
 151   // Either input is BOTTOM ==> the result is the local BOTTOM
 152   if( t1 == Type::BOTTOM || t2 == Type::BOTTOM )
 153     return bottom_type();
 154 
 155 #if defined(IA32)
 156   // Can't trust native compilers to properly fold strict double
 157   // multiplication with round-to-zero on this platform.
 158   if (op == Op_MulD && phase->C->method()->is_strict()) {
 159     return TypeD::DOUBLE;
 160   }
 161 #endif
 162 
 163   return mul_ring(t1,t2);            // Local flavor of type multiplication
 164 }
 165 
 166 
 167 //=============================================================================
 168 //------------------------------Ideal------------------------------------------
 169 // Check for power-of-2 multiply, then try the regular MulNode::Ideal
 170 Node *MulINode::Ideal(PhaseGVN *phase, bool can_reshape) {
 171   // Swap constant to right
 172   jint con;
 173   if ((con = in(1)->find_int_con(0)) != 0) {
 174     swap_edges(1, 2);
 175     // Finish rest of method to use info in 'con'
 176   } else if ((con = in(2)->find_int_con(0)) == 0) {
 177     return MulNode::Ideal(phase, can_reshape);
 178   }
 179 
 180   // Now we have a constant Node on the right and the constant in con
 181   if( con == 0 ) return NULL;   // By zero is handled by Value call
 182   if( con == 1 ) return NULL;   // By one  is handled by Identity call


 351   } else {
 352     if( D < lo0 ) lo0 = D;
 353     if( C > hi0 ) hi0 = C;
 354   }
 355   return TypeLong::make(lo0, hi0, MAX2(r0->_widen,r1->_widen));
 356 }
 357 
 358 //=============================================================================
 359 //------------------------------mul_ring---------------------------------------
 360 // Compute the product type of two double ranges into this node.
 361 const Type *MulFNode::mul_ring(const Type *t0, const Type *t1) const {
 362   if( t0 == Type::FLOAT || t1 == Type::FLOAT ) return Type::FLOAT;
 363   return TypeF::make( t0->getf() * t1->getf() );
 364 }
 365 
 366 //=============================================================================
 367 //------------------------------mul_ring---------------------------------------
 368 // Compute the product type of two double ranges into this node.
 369 const Type *MulDNode::mul_ring(const Type *t0, const Type *t1) const {
 370   if( t0 == Type::DOUBLE || t1 == Type::DOUBLE ) return Type::DOUBLE;
 371   // We must be multiplying 2 double constants.
 372   return TypeD::make( t0->getd() * t1->getd() );
 373 }
 374 
 375 //=============================================================================
 376 //------------------------------Value------------------------------------------
 377 const Type *MulHiLNode::Value( PhaseTransform *phase ) const {
 378   // Either input is TOP ==> the result is TOP
 379   const Type *t1 = phase->type( in(1) );
 380   const Type *t2 = phase->type( in(2) );
 381   if( t1 == Type::TOP ) return Type::TOP;
 382   if( t2 == Type::TOP ) return Type::TOP;
 383 
 384   // Either input is BOTTOM ==> the result is the local BOTTOM
 385   const Type *bot = bottom_type();
 386   if( (t1 == bot) || (t2 == bot) ||
 387       (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) )
 388     return bot;
 389 
 390   // It is not worth trying to constant fold this stuff!
 391   return TypeLong::LONG;