1034 Node* x = andl->in(1);
1035 Node* y = andl->in(2);
1036 assert( x != andl && y != andl, "dead loop in ConvL2INode::Ideal" );
1037 if (phase->type(x) == Type::TOP) return NULL;
1038 if (phase->type(y) == Type::TOP) return NULL;
1039 Node *add1 = phase->transform(new (phase->C, 2) ConvL2INode(x));
1040 Node *add2 = phase->transform(new (phase->C, 2) ConvL2INode(y));
1041 return new (phase->C, 3) AddINode(add1,add2);
1042 }
1043
1044 // Disable optimization: LoadL->ConvL2I ==> LoadI.
1045 // It causes problems (sizes of Load and Store nodes do not match)
1046 // in objects initialization code and Escape Analysis.
1047 return NULL;
1048 }
1049
1050 //=============================================================================
1051 //------------------------------Value------------------------------------------
1052 const Type *CastX2PNode::Value( PhaseTransform *phase ) const {
1053 const Type* t = phase->type(in(1));
1054 if (t->base() == Type_X && t->singleton()) {
1055 uintptr_t bits = (uintptr_t) t->is_intptr_t()->get_con();
1056 if (bits == 0) return TypePtr::NULL_PTR;
1057 return TypeRawPtr::make((address) bits);
1058 }
1059 return CastX2PNode::bottom_type();
1060 }
1061
1062 //------------------------------Idealize---------------------------------------
1063 static inline bool fits_in_int(const Type* t, bool but_not_min_int = false) {
1064 if (t == Type::TOP) return false;
1065 const TypeX* tl = t->is_intptr_t();
1066 jint lo = min_jint;
1067 jint hi = max_jint;
1068 if (but_not_min_int) ++lo; // caller wants to negate the value w/o overflow
1069 return (tl->_lo >= lo) && (tl->_hi <= hi);
1070 }
1071
1072 static inline Node* addP_of_X2P(PhaseGVN *phase,
1073 Node* base,
1104 return addP_of_X2P(phase, x, y);
1105 }
1106 if (fits_in_int(phase->type(x))) {
1107 return addP_of_X2P(phase, y, x);
1108 }
1109 break;
1110 }
1111 return NULL;
1112 }
1113
1114 //------------------------------Identity---------------------------------------
1115 Node *CastX2PNode::Identity( PhaseTransform *phase ) {
1116 if (in(1)->Opcode() == Op_CastP2X) return in(1)->in(1);
1117 return this;
1118 }
1119
1120 //=============================================================================
1121 //------------------------------Value------------------------------------------
1122 const Type *CastP2XNode::Value( PhaseTransform *phase ) const {
1123 const Type* t = phase->type(in(1));
1124 if (t->base() == Type::RawPtr && t->singleton()) {
1125 uintptr_t bits = (uintptr_t) t->is_rawptr()->get_con();
1126 return TypeX::make(bits);
1127 }
1128 return CastP2XNode::bottom_type();
1129 }
1130
1131 Node *CastP2XNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1132 return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL;
1133 }
1134
1135 //------------------------------Identity---------------------------------------
1136 Node *CastP2XNode::Identity( PhaseTransform *phase ) {
1137 if (in(1)->Opcode() == Op_CastX2P) return in(1)->in(1);
1138 return this;
1139 }
1140
1141
1142 //=============================================================================
1143 //------------------------------Identity---------------------------------------
|
1034 Node* x = andl->in(1);
1035 Node* y = andl->in(2);
1036 assert( x != andl && y != andl, "dead loop in ConvL2INode::Ideal" );
1037 if (phase->type(x) == Type::TOP) return NULL;
1038 if (phase->type(y) == Type::TOP) return NULL;
1039 Node *add1 = phase->transform(new (phase->C, 2) ConvL2INode(x));
1040 Node *add2 = phase->transform(new (phase->C, 2) ConvL2INode(y));
1041 return new (phase->C, 3) AddINode(add1,add2);
1042 }
1043
1044 // Disable optimization: LoadL->ConvL2I ==> LoadI.
1045 // It causes problems (sizes of Load and Store nodes do not match)
1046 // in objects initialization code and Escape Analysis.
1047 return NULL;
1048 }
1049
1050 //=============================================================================
1051 //------------------------------Value------------------------------------------
1052 const Type *CastX2PNode::Value( PhaseTransform *phase ) const {
1053 const Type* t = phase->type(in(1));
1054 if (t == Type::TOP) return Type::TOP;
1055 if (t->base() == Type_X && t->singleton()) {
1056 uintptr_t bits = (uintptr_t) t->is_intptr_t()->get_con();
1057 if (bits == 0) return TypePtr::NULL_PTR;
1058 return TypeRawPtr::make((address) bits);
1059 }
1060 return CastX2PNode::bottom_type();
1061 }
1062
1063 //------------------------------Idealize---------------------------------------
1064 static inline bool fits_in_int(const Type* t, bool but_not_min_int = false) {
1065 if (t == Type::TOP) return false;
1066 const TypeX* tl = t->is_intptr_t();
1067 jint lo = min_jint;
1068 jint hi = max_jint;
1069 if (but_not_min_int) ++lo; // caller wants to negate the value w/o overflow
1070 return (tl->_lo >= lo) && (tl->_hi <= hi);
1071 }
1072
1073 static inline Node* addP_of_X2P(PhaseGVN *phase,
1074 Node* base,
1105 return addP_of_X2P(phase, x, y);
1106 }
1107 if (fits_in_int(phase->type(x))) {
1108 return addP_of_X2P(phase, y, x);
1109 }
1110 break;
1111 }
1112 return NULL;
1113 }
1114
1115 //------------------------------Identity---------------------------------------
1116 Node *CastX2PNode::Identity( PhaseTransform *phase ) {
1117 if (in(1)->Opcode() == Op_CastP2X) return in(1)->in(1);
1118 return this;
1119 }
1120
1121 //=============================================================================
1122 //------------------------------Value------------------------------------------
1123 const Type *CastP2XNode::Value( PhaseTransform *phase ) const {
1124 const Type* t = phase->type(in(1));
1125 if (t == Type::TOP) return Type::TOP;
1126 if (t->base() == Type::RawPtr && t->singleton()) {
1127 uintptr_t bits = (uintptr_t) t->is_rawptr()->get_con();
1128 return TypeX::make(bits);
1129 }
1130 return CastP2XNode::bottom_type();
1131 }
1132
1133 Node *CastP2XNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1134 return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL;
1135 }
1136
1137 //------------------------------Identity---------------------------------------
1138 Node *CastP2XNode::Identity( PhaseTransform *phase ) {
1139 if (in(1)->Opcode() == Op_CastX2P) return in(1)->in(1);
1140 return this;
1141 }
1142
1143
1144 //=============================================================================
1145 //------------------------------Identity---------------------------------------
|