< prev index next >

src/hotspot/share/opto/castnode.cpp

Print this page




 220   }
 221   return res;
 222 }
 223 
 224 Node *CastIINode::Ideal(PhaseGVN *phase, bool can_reshape) {
 225   Node* progress = ConstraintCastNode::Ideal(phase, can_reshape);
 226   if (progress != NULL) {
 227     return progress;
 228   }
 229 
 230   // Similar to ConvI2LNode::Ideal() for the same reasons
 231   // Do not narrow the type of range check dependent CastIINodes to
 232   // avoid corruption of the graph if a CastII is replaced by TOP but
 233   // the corresponding range check is not removed.
 234   if (can_reshape && !_range_check_dependency && !phase->C->major_progress()) {
 235     const TypeInt* this_type = this->type()->is_int();
 236     const TypeInt* in_type = phase->type(in(1))->isa_int();
 237     if (in_type != NULL && this_type != NULL &&
 238         (in_type->_lo != this_type->_lo ||
 239          in_type->_hi != this_type->_hi)) {
 240       int lo1 = this_type->_lo;
 241       int hi1 = this_type->_hi;
 242       int w1  = this_type->_widen;
 243 
 244       if (lo1 >= 0) {
 245         // Keep a range assertion of >=0.
 246         lo1 = 0;        hi1 = max_jint;
 247       } else if (hi1 < 0) {
 248         // Keep a range assertion of <0.
 249         lo1 = min_jint; hi1 = -1;
 250       } else {
 251         lo1 = min_jint; hi1 = max_jint;
 252       }
 253       const TypeInt* wtype = TypeInt::make(MAX2(in_type->_lo, lo1),
 254                                            MIN2(in_type->_hi, hi1),
 255                                            MAX2((int)in_type->_widen, w1));
 256       if (wtype != type()) {
 257         set_type(wtype);
 258         return this;
 259       }
 260     }
 261   }




 220   }
 221   return res;
 222 }
 223 
 224 Node *CastIINode::Ideal(PhaseGVN *phase, bool can_reshape) {
 225   Node* progress = ConstraintCastNode::Ideal(phase, can_reshape);
 226   if (progress != NULL) {
 227     return progress;
 228   }
 229 
 230   // Similar to ConvI2LNode::Ideal() for the same reasons
 231   // Do not narrow the type of range check dependent CastIINodes to
 232   // avoid corruption of the graph if a CastII is replaced by TOP but
 233   // the corresponding range check is not removed.
 234   if (can_reshape && !_range_check_dependency && !phase->C->major_progress()) {
 235     const TypeInt* this_type = this->type()->is_int();
 236     const TypeInt* in_type = phase->type(in(1))->isa_int();
 237     if (in_type != NULL && this_type != NULL &&
 238         (in_type->_lo != this_type->_lo ||
 239          in_type->_hi != this_type->_hi)) {
 240       jint lo1 = this_type->_lo;
 241       jint hi1 = this_type->_hi;
 242       int w1  = this_type->_widen;
 243 
 244       if (lo1 >= 0) {
 245         // Keep a range assertion of >=0.
 246         lo1 = 0;        hi1 = max_jint;
 247       } else if (hi1 < 0) {
 248         // Keep a range assertion of <0.
 249         lo1 = min_jint; hi1 = -1;
 250       } else {
 251         lo1 = min_jint; hi1 = max_jint;
 252       }
 253       const TypeInt* wtype = TypeInt::make(MAX2(in_type->_lo, lo1),
 254                                            MIN2(in_type->_hi, hi1),
 255                                            MAX2((int)in_type->_widen, w1));
 256       if (wtype != type()) {
 257         set_type(wtype);
 258         return this;
 259       }
 260     }
 261   }


< prev index next >