src/share/vm/opto/mulnode.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/opto

src/share/vm/opto/mulnode.cpp

Print this page




 218     } else {
 219       return MulNode::Ideal(phase, can_reshape);
 220     }
 221   }
 222 
 223   if( sign_flip ) {             // Need to negate result?
 224     res = phase->transform(res);// Transform, before making the zero con
 225     res = new (phase->C) SubINode(phase->intcon(0),res);
 226   }
 227 
 228   return res;                   // Return final result
 229 }
 230 
 231 //------------------------------mul_ring---------------------------------------
 232 // Compute the product type of two integer ranges into this node.
 233 const Type *MulINode::mul_ring(const Type *t0, const Type *t1) const {
 234   const TypeInt *r0 = t0->is_int(); // Handy access
 235   const TypeInt *r1 = t1->is_int();
 236 
 237   // Fetch endpoints of all ranges
 238   int32 lo0 = r0->_lo;
 239   double a = (double)lo0;
 240   int32 hi0 = r0->_hi;
 241   double b = (double)hi0;
 242   int32 lo1 = r1->_lo;
 243   double c = (double)lo1;
 244   int32 hi1 = r1->_hi;
 245   double d = (double)hi1;
 246 
 247   // Compute all endpoints & check for overflow
 248   int32 A = lo0*lo1;
 249   if( (double)A != a*c ) return TypeInt::INT; // Overflow?
 250   int32 B = lo0*hi1;
 251   if( (double)B != a*d ) return TypeInt::INT; // Overflow?
 252   int32 C = hi0*lo1;
 253   if( (double)C != b*c ) return TypeInt::INT; // Overflow?
 254   int32 D = hi0*hi1;
 255   if( (double)D != b*d ) return TypeInt::INT; // Overflow?
 256 
 257   if( A < B ) { lo0 = A; hi0 = B; } // Sort range endpoints
 258   else { lo0 = B; hi0 = A; }
 259   if( C < D ) {
 260     if( C < lo0 ) lo0 = C;
 261     if( D > hi0 ) hi0 = D;
 262   } else {
 263     if( D < lo0 ) lo0 = D;
 264     if( C > hi0 ) hi0 = C;
 265   }
 266   return TypeInt::make(lo0, hi0, MAX2(r0->_widen,r1->_widen));
 267 }
 268 
 269 
 270 //=============================================================================
 271 //------------------------------Ideal------------------------------------------
 272 // Check for power-of-2 multiply, then try the regular MulNode::Ideal
 273 Node *MulLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
 274   // Swap constant to right


1211     }
1212     assert(lo <= hi, "must have valid bounds");
1213     const TypeInt* ti = TypeInt::make(lo, hi, MAX2(r1->_widen,r2->_widen));
1214     #ifdef ASSERT
1215     // Make sure we get the sign-capture idiom correct.
1216     if (shift == BitsPerJavaInteger-1) {
1217       if (r1->_lo >= 0) assert(ti == TypeInt::ZERO, ">>>31 of + is 0");
1218       if (r1->_hi < 0)  assert(ti == TypeInt::ONE,  ">>>31 of - is +1");
1219     }
1220     #endif
1221     return ti;
1222   }
1223 
1224   //
1225   // Do not support shifted oops in info for GC
1226   //
1227   // else if( t1->base() == Type::InstPtr ) {
1228   //
1229   //   const TypeInstPtr *o = t1->is_instptr();
1230   //   if( t1->singleton() )
1231   //     return TypeInt::make( ((uint32)o->const_oop() + o->_offset) >> shift );
1232   // }
1233   // else if( t1->base() == Type::KlassPtr ) {
1234   //   const TypeKlassPtr *o = t1->is_klassptr();
1235   //   if( t1->singleton() )
1236   //     return TypeInt::make( ((uint32)o->const_oop() + o->_offset) >> shift );
1237   // }
1238 
1239   return TypeInt::INT;
1240 }
1241 
1242 //=============================================================================
1243 //------------------------------Identity---------------------------------------
1244 Node *URShiftLNode::Identity( PhaseTransform *phase ) {
1245   const TypeInt *ti = phase->type( in(2) )->isa_int(); // shift count is an int
1246   return ( ti && ti->is_con() && ( ti->get_con() & ( BitsPerLong - 1 ) ) == 0 ) ? in(1) : this;
1247 }
1248 
1249 //------------------------------Ideal------------------------------------------
1250 Node *URShiftLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1251   const TypeInt *t2 = phase->type( in(2) )->isa_int();
1252   if( !t2 || !t2->is_con() ) return NULL; // Right input is a constant
1253   const int con = t2->get_con() & ( BitsPerLong - 1 ); // Shift count is always masked
1254   if ( con == 0 ) return NULL;  // let Identity() handle a 0 shift count
1255                               // note: mask computation below does not work for 0 shift count
1256   // We'll be wanting the right-shift amount as a mask of that many bits




 218     } else {
 219       return MulNode::Ideal(phase, can_reshape);
 220     }
 221   }
 222 
 223   if( sign_flip ) {             // Need to negate result?
 224     res = phase->transform(res);// Transform, before making the zero con
 225     res = new (phase->C) SubINode(phase->intcon(0),res);
 226   }
 227 
 228   return res;                   // Return final result
 229 }
 230 
 231 //------------------------------mul_ring---------------------------------------
 232 // Compute the product type of two integer ranges into this node.
 233 const Type *MulINode::mul_ring(const Type *t0, const Type *t1) const {
 234   const TypeInt *r0 = t0->is_int(); // Handy access
 235   const TypeInt *r1 = t1->is_int();
 236 
 237   // Fetch endpoints of all ranges
 238   int32_t lo0 = r0->_lo;
 239   double a = (double)lo0;
 240   int32_t hi0 = r0->_hi;
 241   double b = (double)hi0;
 242   int32_t lo1 = r1->_lo;
 243   double c = (double)lo1;
 244   int32_t hi1 = r1->_hi;
 245   double d = (double)hi1;
 246 
 247   // Compute all endpoints & check for overflow
 248   int32_t A = lo0*lo1;
 249   if( (double)A != a*c ) return TypeInt::INT; // Overflow?
 250   int32_t B = lo0*hi1;
 251   if( (double)B != a*d ) return TypeInt::INT; // Overflow?
 252   int32_t C = hi0*lo1;
 253   if( (double)C != b*c ) return TypeInt::INT; // Overflow?
 254   int32_t D = hi0*hi1;
 255   if( (double)D != b*d ) return TypeInt::INT; // Overflow?
 256 
 257   if( A < B ) { lo0 = A; hi0 = B; } // Sort range endpoints
 258   else { lo0 = B; hi0 = A; }
 259   if( C < D ) {
 260     if( C < lo0 ) lo0 = C;
 261     if( D > hi0 ) hi0 = D;
 262   } else {
 263     if( D < lo0 ) lo0 = D;
 264     if( C > hi0 ) hi0 = C;
 265   }
 266   return TypeInt::make(lo0, hi0, MAX2(r0->_widen,r1->_widen));
 267 }
 268 
 269 
 270 //=============================================================================
 271 //------------------------------Ideal------------------------------------------
 272 // Check for power-of-2 multiply, then try the regular MulNode::Ideal
 273 Node *MulLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
 274   // Swap constant to right


1211     }
1212     assert(lo <= hi, "must have valid bounds");
1213     const TypeInt* ti = TypeInt::make(lo, hi, MAX2(r1->_widen,r2->_widen));
1214     #ifdef ASSERT
1215     // Make sure we get the sign-capture idiom correct.
1216     if (shift == BitsPerJavaInteger-1) {
1217       if (r1->_lo >= 0) assert(ti == TypeInt::ZERO, ">>>31 of + is 0");
1218       if (r1->_hi < 0)  assert(ti == TypeInt::ONE,  ">>>31 of - is +1");
1219     }
1220     #endif
1221     return ti;
1222   }
1223 
1224   //
1225   // Do not support shifted oops in info for GC
1226   //
1227   // else if( t1->base() == Type::InstPtr ) {
1228   //
1229   //   const TypeInstPtr *o = t1->is_instptr();
1230   //   if( t1->singleton() )
1231   //     return TypeInt::make( ((uint32_t)o->const_oop() + o->_offset) >> shift );
1232   // }
1233   // else if( t1->base() == Type::KlassPtr ) {
1234   //   const TypeKlassPtr *o = t1->is_klassptr();
1235   //   if( t1->singleton() )
1236   //     return TypeInt::make( ((uint32_t)o->const_oop() + o->_offset) >> shift );
1237   // }
1238 
1239   return TypeInt::INT;
1240 }
1241 
1242 //=============================================================================
1243 //------------------------------Identity---------------------------------------
1244 Node *URShiftLNode::Identity( PhaseTransform *phase ) {
1245   const TypeInt *ti = phase->type( in(2) )->isa_int(); // shift count is an int
1246   return ( ti && ti->is_con() && ( ti->get_con() & ( BitsPerLong - 1 ) ) == 0 ) ? in(1) : this;
1247 }
1248 
1249 //------------------------------Ideal------------------------------------------
1250 Node *URShiftLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1251   const TypeInt *t2 = phase->type( in(2) )->isa_int();
1252   if( !t2 || !t2->is_con() ) return NULL; // Right input is a constant
1253   const int con = t2->get_con() & ( BitsPerLong - 1 ); // Shift count is always masked
1254   if ( con == 0 ) return NULL;  // let Identity() handle a 0 shift count
1255                               // note: mask computation below does not work for 0 shift count
1256   // We'll be wanting the right-shift amount as a mask of that many bits


src/share/vm/opto/mulnode.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File