< prev index next >

src/hotspot/share/opto/castnode.cpp

Print this page




 393     return TypeRawPtr::make((address) bits);
 394   }
 395   return CastX2PNode::bottom_type();
 396 }
 397 
 398 //------------------------------Idealize---------------------------------------
 399 static inline bool fits_in_int(const Type* t, bool but_not_min_int = false) {
 400   if (t == Type::TOP)  return false;
 401   const TypeX* tl = t->is_intptr_t();
 402   jint lo = min_jint;
 403   jint hi = max_jint;
 404   if (but_not_min_int)  ++lo;  // caller wants to negate the value w/o overflow
 405   return (tl->_lo >= lo) && (tl->_hi <= hi);
 406 }
 407 
 408 static inline Node* addP_of_X2P(PhaseGVN *phase,
 409                                 Node* base,
 410                                 Node* dispX,
 411                                 bool negate = false) {
 412   if (negate) {
 413     dispX = new SubXNode(phase->MakeConX(0), phase->transform(dispX));
 414   }
 415   return new AddPNode(phase->C->top(),
 416                       phase->transform(new CastX2PNode(base)),
 417                       phase->transform(dispX));
 418 }
 419 
 420 Node *CastX2PNode::Ideal(PhaseGVN *phase, bool can_reshape) {
 421   // convert CastX2P(AddX(x, y)) to AddP(CastX2P(x), y) if y fits in an int
 422   int op = in(1)->Opcode();
 423   Node* x;
 424   Node* y;
 425   switch (op) {
 426     case Op_SubX:
 427     x = in(1)->in(1);
 428     // Avoid ideal transformations ping-pong between this and AddP for raw pointers.
 429     if (phase->find_intptr_t_con(x, -1) == 0)
 430     break;
 431     y = in(1)->in(2);
 432     if (fits_in_int(phase->type(y), true)) {
 433       return addP_of_X2P(phase, x, y, true);
 434     }
 435     break;
 436     case Op_AddX:
 437     x = in(1)->in(1);




 393     return TypeRawPtr::make((address) bits);
 394   }
 395   return CastX2PNode::bottom_type();
 396 }
 397 
 398 //------------------------------Idealize---------------------------------------
 399 static inline bool fits_in_int(const Type* t, bool but_not_min_int = false) {
 400   if (t == Type::TOP)  return false;
 401   const TypeX* tl = t->is_intptr_t();
 402   jint lo = min_jint;
 403   jint hi = max_jint;
 404   if (but_not_min_int)  ++lo;  // caller wants to negate the value w/o overflow
 405   return (tl->_lo >= lo) && (tl->_hi <= hi);
 406 }
 407 
 408 static inline Node* addP_of_X2P(PhaseGVN *phase,
 409                                 Node* base,
 410                                 Node* dispX,
 411                                 bool negate = false) {
 412   if (negate) {
 413     dispX = phase->transform(new SubXNode(phase->MakeConX(0), dispX));
 414   }
 415   return new AddPNode(phase->C->top(),
 416                       phase->transform(new CastX2PNode(base)),
 417                       dispX);
 418 }
 419 
 420 Node *CastX2PNode::Ideal(PhaseGVN *phase, bool can_reshape) {
 421   // convert CastX2P(AddX(x, y)) to AddP(CastX2P(x), y) if y fits in an int
 422   int op = in(1)->Opcode();
 423   Node* x;
 424   Node* y;
 425   switch (op) {
 426     case Op_SubX:
 427     x = in(1)->in(1);
 428     // Avoid ideal transformations ping-pong between this and AddP for raw pointers.
 429     if (phase->find_intptr_t_con(x, -1) == 0)
 430     break;
 431     y = in(1)->in(2);
 432     if (fits_in_int(phase->type(y), true)) {
 433       return addP_of_X2P(phase, x, y, true);
 434     }
 435     break;
 436     case Op_AddX:
 437     x = in(1)->in(1);


< prev index next >