1 /* 2 * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "opto/addnode.hpp" 27 #include "opto/callnode.hpp" 28 #include "opto/castnode.hpp" 29 #include "opto/connode.hpp" 30 #include "opto/graphKit.hpp" 31 #include "opto/inlinetypenode.hpp" 32 #include "opto/matcher.hpp" 33 #include "opto/phaseX.hpp" 34 #include "opto/rootnode.hpp" 35 #include "opto/subnode.hpp" 36 #include "opto/type.hpp" 37 #include "castnode.hpp" 38 39 //============================================================================= 40 // If input is already higher or equal to cast type, then this is an identity. 41 Node* ConstraintCastNode::Identity(PhaseGVN* phase) { 42 Node* dom = dominating_cast(phase, phase); 43 if (dom != nullptr) { 44 return dom; 45 } 46 if (_dependency != RegularDependency) { 47 return this; 48 } 49 return phase->type(in(1))->higher_equal_speculative(_type) ? in(1) : this; 50 } 51 52 //------------------------------Value------------------------------------------ 53 // Take 'join' of input and cast-up type 54 const Type* ConstraintCastNode::Value(PhaseGVN* phase) const { 55 if (in(0) && phase->type(in(0)) == Type::TOP) return Type::TOP; 56 57 const Type* in_type = phase->type(in(1)); 58 const Type* ft = in_type->filter_speculative(_type); 59 60 // Check if both _type and in_type had a speculative type, but for the just 61 // computed ft the speculative type was dropped. 62 if (ft->speculative() == nullptr && 63 _type->speculative() != nullptr && 64 in_type->speculative() != nullptr) { 65 // Speculative type may have disagreed between cast and input, and was 66 // dropped in filtering. Recompute so that ft can take speculative type 67 // of in_type. If we did not do it now, a subsequent ::Value call would 68 // do it, and violate idempotence of ::Value. 69 ft = in_type->filter_speculative(ft); 70 } 71 72 #ifdef ASSERT 73 // Previous versions of this function had some special case logic, 74 // which is no longer necessary. Make sure of the required effects. 75 switch (Opcode()) { 76 case Op_CastII: 77 { 78 if (in_type == Type::TOP) { 79 assert(ft == Type::TOP, "special case #1"); 80 } 81 const Type* rt = in_type->join_speculative(_type); 82 if (rt->empty()) { 83 assert(ft == Type::TOP, "special case #2"); 84 } 85 break; 86 } 87 case Op_CastPP: 88 if (in_type == TypePtr::NULL_PTR && 89 _type->isa_ptr() && _type->is_ptr()->_ptr == TypePtr::NotNull) { 90 assert(ft == Type::TOP, "special case #3"); 91 break; 92 } 93 } 94 #endif //ASSERT 95 96 return ft; 97 } 98 99 //------------------------------Ideal------------------------------------------ 100 // Return a node which is more "ideal" than the current node. Strip out 101 // control copies 102 Node *ConstraintCastNode::Ideal(PhaseGVN *phase, bool can_reshape) { 103 if (in(0) && remove_dead_region(phase, can_reshape)) { 104 return this; 105 } 106 107 // Push cast through InlineTypeNode 108 InlineTypeNode* vt = in(1)->isa_InlineType(); 109 if (vt != nullptr && phase->type(vt)->filter_speculative(_type) != Type::TOP) { 110 Node* cast = clone(); 111 cast->set_req(1, vt->get_oop()); 112 vt = vt->clone()->as_InlineType(); 113 vt->set_oop(phase->transform(cast)); 114 return vt; 115 } 116 117 return nullptr; 118 } 119 120 bool ConstraintCastNode::cmp(const Node &n) const { 121 return TypeNode::cmp(n) && ((ConstraintCastNode&)n)._dependency == _dependency; 122 } 123 124 uint ConstraintCastNode::size_of() const { 125 return sizeof(*this); 126 } 127 128 Node* ConstraintCastNode::make_cast(int opcode, Node* c, Node *n, const Type *t, DependencyType dependency) { 129 switch(opcode) { 130 case Op_CastII: { 131 Node* cast = new CastIINode(n, t, dependency); 132 cast->set_req(0, c); 133 return cast; 134 } 135 case Op_CastLL: { 136 Node* cast = new CastLLNode(n, t, dependency); 137 cast->set_req(0, c); 138 return cast; 139 } 140 case Op_CastPP: { 141 Node* cast = new CastPPNode(n, t, dependency); 142 cast->set_req(0, c); 143 return cast; 144 } 145 case Op_CastFF: { 146 Node* cast = new CastFFNode(n, t, dependency); 147 cast->set_req(0, c); 148 return cast; 149 } 150 case Op_CastDD: { 151 Node* cast = new CastDDNode(n, t, dependency); 152 cast->set_req(0, c); 153 return cast; 154 } 155 case Op_CastVV: { 156 Node* cast = new CastVVNode(n, t, dependency); 157 cast->set_req(0, c); 158 return cast; 159 } 160 case Op_CheckCastPP: return new CheckCastPPNode(c, n, t, dependency); 161 default: 162 fatal("Bad opcode %d", opcode); 163 } 164 return nullptr; 165 } 166 167 Node* ConstraintCastNode::make(Node* c, Node *n, const Type *t, DependencyType dependency, BasicType bt) { 168 switch(bt) { 169 case T_INT: { 170 return make_cast(Op_CastII, c, n, t, dependency); 171 } 172 case T_LONG: { 173 return make_cast(Op_CastLL, c, n, t, dependency); 174 } 175 default: 176 fatal("Bad basic type %s", type2name(bt)); 177 } 178 return nullptr; 179 } 180 181 TypeNode* ConstraintCastNode::dominating_cast(PhaseGVN* gvn, PhaseTransform* pt) const { 182 if (_dependency == UnconditionalDependency) { 183 return nullptr; 184 } 185 Node* val = in(1); 186 Node* ctl = in(0); 187 int opc = Opcode(); 188 if (ctl == nullptr) { 189 return nullptr; 190 } 191 // Range check CastIIs may all end up under a single range check and 192 // in that case only the narrower CastII would be kept by the code 193 // below which would be incorrect. 194 if (is_CastII() && as_CastII()->has_range_check()) { 195 return nullptr; 196 } 197 if (type()->isa_rawptr() && (gvn->type_or_null(val) == nullptr || gvn->type(val)->isa_oopptr())) { 198 return nullptr; 199 } 200 for (DUIterator_Fast imax, i = val->fast_outs(imax); i < imax; i++) { 201 Node* u = val->fast_out(i); 202 if (u != this && 203 u->outcnt() > 0 && 204 u->Opcode() == opc && 205 u->in(0) != nullptr && 206 u->bottom_type()->higher_equal(type())) { 207 if (pt->is_dominator(u->in(0), ctl)) { 208 return u->as_Type(); 209 } 210 if (is_CheckCastPP() && u->in(1)->is_Proj() && u->in(1)->in(0)->is_Allocate() && 211 u->in(0)->is_Proj() && u->in(0)->in(0)->is_Initialize() && 212 u->in(1)->in(0)->as_Allocate()->initialization() == u->in(0)->in(0)) { 213 // CheckCastPP following an allocation always dominates all 214 // use of the allocation result 215 return u->as_Type(); 216 } 217 } 218 } 219 return nullptr; 220 } 221 222 #ifndef PRODUCT 223 void ConstraintCastNode::dump_spec(outputStream *st) const { 224 TypeNode::dump_spec(st); 225 if (_dependency != RegularDependency) { 226 st->print(" %s dependency", _dependency == StrongDependency ? "strong" : "unconditional"); 227 } 228 } 229 #endif 230 231 const Type* CastIINode::Value(PhaseGVN* phase) const { 232 const Type *res = ConstraintCastNode::Value(phase); 233 if (res == Type::TOP) { 234 return Type::TOP; 235 } 236 assert(res->isa_int(), "res must be int"); 237 238 // Similar to ConvI2LNode::Value() for the same reasons 239 // see if we can remove type assertion after loop opts 240 // But here we have to pay extra attention: 241 // Do not narrow the type of range check dependent CastIINodes to 242 // avoid corruption of the graph if a CastII is replaced by TOP but 243 // the corresponding range check is not removed. 244 if (!_range_check_dependency) { 245 res = widen_type(phase, res, T_INT); 246 } 247 248 // Try to improve the type of the CastII if we recognize a CmpI/If pattern. 249 // 250 // in1 in2 251 // | | 252 // +--- | --+ 253 // | | | 254 // CmpINode | 255 // | | 256 // BoolNode | 257 // | | 258 // IfNode | 259 // | | 260 // IfProj | 261 // | | 262 // CastIINode 263 // 264 if (carry_dependency()) { 265 if (in(0) != nullptr && in(0)->in(0) != nullptr && in(0)->in(0)->is_If()) { 266 assert(in(0)->is_IfFalse() || in(0)->is_IfTrue(), "should be If proj"); 267 Node* proj = in(0); 268 if (proj->in(0)->in(1)->is_Bool()) { 269 Node* b = proj->in(0)->in(1); 270 if (b->in(1)->Opcode() == Op_CmpI) { 271 Node* cmp = b->in(1); 272 if (cmp->in(1) == in(1) && phase->type(cmp->in(2))->isa_int()) { 273 const TypeInt* in2_t = phase->type(cmp->in(2))->is_int(); 274 const Type* t = TypeInt::INT; 275 BoolTest test = b->as_Bool()->_test; 276 if (proj->is_IfFalse()) { 277 test = test.negate(); 278 } 279 BoolTest::mask m = test._test; 280 jlong lo_long = min_jint; 281 jlong hi_long = max_jint; 282 if (m == BoolTest::le || m == BoolTest::lt) { 283 hi_long = in2_t->_hi; 284 if (m == BoolTest::lt) { 285 hi_long -= 1; 286 } 287 } else if (m == BoolTest::ge || m == BoolTest::gt) { 288 lo_long = in2_t->_lo; 289 if (m == BoolTest::gt) { 290 lo_long += 1; 291 } 292 } else if (m == BoolTest::eq) { 293 lo_long = in2_t->_lo; 294 hi_long = in2_t->_hi; 295 } else if (m == BoolTest::ne) { 296 // can't do any better 297 } else { 298 stringStream ss; 299 test.dump_on(&ss); 300 fatal("unexpected comparison %s", ss.freeze()); 301 } 302 int lo_int = (int)lo_long; 303 int hi_int = (int)hi_long; 304 305 if (lo_long != (jlong)lo_int) { 306 lo_int = min_jint; 307 } 308 if (hi_long != (jlong)hi_int) { 309 hi_int = max_jint; 310 } 311 312 t = TypeInt::make(lo_int, hi_int, Type::WidenMax); 313 314 res = res->filter_speculative(t); 315 return res; 316 } 317 } 318 } 319 } 320 } 321 return res; 322 } 323 324 static Node* find_or_make_integer_cast(PhaseIterGVN* igvn, Node* parent, Node* control, const TypeInteger* type, ConstraintCastNode::DependencyType dependency, BasicType bt) { 325 Node* n = ConstraintCastNode::make(control, parent, type, dependency, bt); 326 Node* existing = igvn->hash_find_insert(n); 327 if (existing != nullptr) { 328 n->destruct(igvn); 329 return existing; 330 } 331 return igvn->register_new_node_with_optimizer(n); 332 } 333 334 Node *CastIINode::Ideal(PhaseGVN *phase, bool can_reshape) { 335 Node* progress = ConstraintCastNode::Ideal(phase, can_reshape); 336 if (progress != nullptr) { 337 return progress; 338 } 339 if (can_reshape && !_range_check_dependency && !phase->C->post_loop_opts_phase()) { 340 // makes sure we run ::Value to potentially remove type assertion after loop opts 341 phase->C->record_for_post_loop_opts_igvn(this); 342 } 343 if (!_range_check_dependency) { 344 return optimize_integer_cast(phase, T_INT); 345 } 346 return nullptr; 347 } 348 349 Node* CastIINode::Identity(PhaseGVN* phase) { 350 Node* progress = ConstraintCastNode::Identity(phase); 351 if (progress != this) { 352 return progress; 353 } 354 if (_range_check_dependency) { 355 if (phase->C->post_loop_opts_phase()) { 356 return this->in(1); 357 } else { 358 phase->C->record_for_post_loop_opts_igvn(this); 359 } 360 } 361 return this; 362 } 363 364 bool CastIINode::cmp(const Node &n) const { 365 return ConstraintCastNode::cmp(n) && ((CastIINode&)n)._range_check_dependency == _range_check_dependency; 366 } 367 368 uint CastIINode::size_of() const { 369 return sizeof(*this); 370 } 371 372 #ifndef PRODUCT 373 void CastIINode::dump_spec(outputStream* st) const { 374 ConstraintCastNode::dump_spec(st); 375 if (_range_check_dependency) { 376 st->print(" range check dependency"); 377 } 378 } 379 #endif 380 381 const Type* CastLLNode::Value(PhaseGVN* phase) const { 382 const Type* res = ConstraintCastNode::Value(phase); 383 if (res == Type::TOP) { 384 return Type::TOP; 385 } 386 assert(res->isa_long(), "res must be long"); 387 388 return widen_type(phase, res, T_LONG); 389 } 390 391 Node* CastLLNode::Ideal(PhaseGVN* phase, bool can_reshape) { 392 Node* progress = ConstraintCastNode::Ideal(phase, can_reshape); 393 if (progress != nullptr) { 394 return progress; 395 } 396 if (!phase->C->post_loop_opts_phase()) { 397 // makes sure we run ::Value to potentially remove type assertion after loop opts 398 phase->C->record_for_post_loop_opts_igvn(this); 399 } 400 // transform (CastLL (ConvI2L ..)) into (ConvI2L (CastII ..)) if the type of the CastLL is narrower than the type of 401 // the ConvI2L. 402 Node* in1 = in(1); 403 if (in1 != nullptr && in1->Opcode() == Op_ConvI2L) { 404 const Type* t = Value(phase); 405 const Type* t_in = phase->type(in1); 406 if (t != Type::TOP && t_in != Type::TOP) { 407 const TypeLong* tl = t->is_long(); 408 const TypeLong* t_in_l = t_in->is_long(); 409 assert(tl->_lo >= t_in_l->_lo && tl->_hi <= t_in_l->_hi, "CastLL type should be narrower than or equal to the type of its input"); 410 assert((tl != t_in_l) == (tl->_lo > t_in_l->_lo || tl->_hi < t_in_l->_hi), "if type differs then this nodes's type must be narrower"); 411 if (tl != t_in_l) { 412 const TypeInt* ti = TypeInt::make(checked_cast<jint>(tl->_lo), checked_cast<jint>(tl->_hi), tl->_widen); 413 Node* castii = phase->transform(new CastIINode(in(0), in1->in(1), ti)); 414 Node* convi2l = in1->clone(); 415 convi2l->set_req(1, castii); 416 return convi2l; 417 } 418 } 419 } 420 return optimize_integer_cast(phase, T_LONG); 421 } 422 423 //============================================================================= 424 //------------------------------Identity--------------------------------------- 425 // If input is already higher or equal to cast type, then this is an identity. 426 Node* CheckCastPPNode::Identity(PhaseGVN* phase) { 427 if (in(1)->is_InlineType() && _type->isa_instptr() && phase->type(in(1))->inline_klass()->is_subtype_of(_type->is_instptr()->instance_klass())) { 428 return in(1); 429 } 430 return ConstraintCastNode::Identity(phase); 431 } 432 433 //------------------------------Value------------------------------------------ 434 // Take 'join' of input and cast-up type, unless working with an Interface 435 const Type* CheckCastPPNode::Value(PhaseGVN* phase) const { 436 if( in(0) && phase->type(in(0)) == Type::TOP ) return Type::TOP; 437 438 const Type *inn = phase->type(in(1)); 439 if( inn == Type::TOP ) return Type::TOP; // No information yet 440 441 if (inn->isa_oopptr() && _type->isa_oopptr()) { 442 return ConstraintCastNode::Value(phase); 443 } 444 445 const TypePtr *in_type = inn->isa_ptr(); 446 const TypePtr *my_type = _type->isa_ptr(); 447 const Type *result = _type; 448 if (in_type != nullptr && my_type != nullptr) { 449 // TODO 8302672 450 if (!StressReflectiveCode && my_type->isa_aryptr() && in_type->isa_aryptr()) { 451 // Propagate array properties (not flat/null-free) 452 // Don't do this when StressReflectiveCode is enabled because it might lead to 453 // a dying data path while the corresponding flat/null-free check is not folded. 454 my_type = my_type->is_aryptr()->update_properties(in_type->is_aryptr()); 455 if (my_type == nullptr) { 456 return Type::TOP; // Inconsistent properties 457 } 458 } 459 TypePtr::PTR in_ptr = in_type->ptr(); 460 if (in_ptr == TypePtr::Null) { 461 result = in_type; 462 } else if (in_ptr != TypePtr::Constant) { 463 result = my_type->cast_to_ptr_type(my_type->join_ptr(in_ptr)); 464 } 465 } 466 467 return result; 468 } 469 470 //============================================================================= 471 //------------------------------Value------------------------------------------ 472 const Type* CastX2PNode::Value(PhaseGVN* phase) const { 473 const Type* t = phase->type(in(1)); 474 if (t == Type::TOP) return Type::TOP; 475 if (t->base() == Type_X && t->singleton()) { 476 uintptr_t bits = (uintptr_t) t->is_intptr_t()->get_con(); 477 if (bits == 0) return TypePtr::NULL_PTR; 478 return TypeRawPtr::make((address) bits); 479 } 480 return CastX2PNode::bottom_type(); 481 } 482 483 //------------------------------Idealize--------------------------------------- 484 static inline bool fits_in_int(const Type* t, bool but_not_min_int = false) { 485 if (t == Type::TOP) return false; 486 const TypeX* tl = t->is_intptr_t(); 487 jint lo = min_jint; 488 jint hi = max_jint; 489 if (but_not_min_int) ++lo; // caller wants to negate the value w/o overflow 490 return (tl->_lo >= lo) && (tl->_hi <= hi); 491 } 492 493 static inline Node* addP_of_X2P(PhaseGVN *phase, 494 Node* base, 495 Node* dispX, 496 bool negate = false) { 497 if (negate) { 498 dispX = phase->transform(new SubXNode(phase->MakeConX(0), dispX)); 499 } 500 return new AddPNode(phase->C->top(), 501 phase->transform(new CastX2PNode(base)), 502 dispX); 503 } 504 505 Node *CastX2PNode::Ideal(PhaseGVN *phase, bool can_reshape) { 506 // convert CastX2P(AddX(x, y)) to AddP(CastX2P(x), y) if y fits in an int 507 int op = in(1)->Opcode(); 508 Node* x; 509 Node* y; 510 switch (op) { 511 case Op_SubX: 512 x = in(1)->in(1); 513 // Avoid ideal transformations ping-pong between this and AddP for raw pointers. 514 if (phase->find_intptr_t_con(x, -1) == 0) 515 break; 516 y = in(1)->in(2); 517 if (fits_in_int(phase->type(y), true)) { 518 return addP_of_X2P(phase, x, y, true); 519 } 520 break; 521 case Op_AddX: 522 x = in(1)->in(1); 523 y = in(1)->in(2); 524 if (fits_in_int(phase->type(y))) { 525 return addP_of_X2P(phase, x, y); 526 } 527 if (fits_in_int(phase->type(x))) { 528 return addP_of_X2P(phase, y, x); 529 } 530 break; 531 } 532 return nullptr; 533 } 534 535 //------------------------------Identity--------------------------------------- 536 Node* CastX2PNode::Identity(PhaseGVN* phase) { 537 if (in(1)->Opcode() == Op_CastP2X) return in(1)->in(1); 538 return this; 539 } 540 541 //============================================================================= 542 //------------------------------Value------------------------------------------ 543 const Type* CastP2XNode::Value(PhaseGVN* phase) const { 544 const Type* t = phase->type(in(1)); 545 if (t == Type::TOP) return Type::TOP; 546 if (t->base() == Type::RawPtr && t->singleton()) { 547 uintptr_t bits = (uintptr_t) t->is_rawptr()->get_con(); 548 return TypeX::make(bits); 549 } 550 551 if (t->is_zero_type() || !t->maybe_null()) { 552 for (DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++) { 553 Node* u = fast_out(i); 554 if (u->Opcode() == Op_OrL) { 555 for (DUIterator_Fast jmax, j = u->fast_outs(jmax); j < jmax; j++) { 556 Node* cmp = u->fast_out(j); 557 if (cmp->Opcode() == Op_CmpL) { 558 // Give CmpL a chance to get optimized 559 phase->record_for_igvn(cmp); 560 } 561 } 562 } 563 } 564 } 565 566 return CastP2XNode::bottom_type(); 567 } 568 569 Node *CastP2XNode::Ideal(PhaseGVN *phase, bool can_reshape) { 570 return (in(0) && remove_dead_region(phase, can_reshape)) ? this : nullptr; 571 } 572 573 //------------------------------Identity--------------------------------------- 574 Node* CastP2XNode::Identity(PhaseGVN* phase) { 575 if (in(1)->Opcode() == Op_CastX2P) return in(1)->in(1); 576 return this; 577 } 578 579 Node* ConstraintCastNode::make_cast_for_type(Node* c, Node* in, const Type* type, DependencyType dependency) { 580 Node* cast= nullptr; 581 if (type->isa_int()) { 582 cast = make_cast(Op_CastII, c, in, type, dependency); 583 } else if (type->isa_long()) { 584 cast = make_cast(Op_CastLL, c, in, type, dependency); 585 } else if (type->isa_float()) { 586 cast = make_cast(Op_CastFF, c, in, type, dependency); 587 } else if (type->isa_double()) { 588 cast = make_cast(Op_CastDD, c, in, type, dependency); 589 } else if (type->isa_vect()) { 590 cast = make_cast(Op_CastVV, c, in, type, dependency); 591 } else if (type->isa_ptr()) { 592 cast = make_cast(Op_CastPP, c, in, type, dependency); 593 } 594 return cast; 595 } 596 597 Node* ConstraintCastNode::optimize_integer_cast(PhaseGVN* phase, BasicType bt) { 598 PhaseIterGVN *igvn = phase->is_IterGVN(); 599 const TypeInteger* this_type = this->type()->is_integer(bt); 600 Node* z = in(1); 601 const TypeInteger* rx = nullptr; 602 const TypeInteger* ry = nullptr; 603 // Similar to ConvI2LNode::Ideal() for the same reasons 604 if (Compile::push_thru_add(phase, z, this_type, rx, ry, bt, bt)) { 605 if (igvn == nullptr) { 606 // Postpone this optimization to iterative GVN, where we can handle deep 607 // AddI chains without an exponential number of recursive Ideal() calls. 608 phase->record_for_igvn(this); 609 return nullptr; 610 } 611 int op = z->Opcode(); 612 Node* x = z->in(1); 613 Node* y = z->in(2); 614 615 Node* cx = find_or_make_integer_cast(igvn, x, in(0), rx, _dependency, bt); 616 Node* cy = find_or_make_integer_cast(igvn, y, in(0), ry, _dependency, bt); 617 if (op == Op_Add(bt)) { 618 return AddNode::make(cx, cy, bt); 619 } else { 620 assert(op == Op_Sub(bt), ""); 621 return SubNode::make(cx, cy, bt); 622 } 623 return nullptr; 624 } 625 return nullptr; 626 } 627 628 const Type* ConstraintCastNode::widen_type(const PhaseGVN* phase, const Type* res, BasicType bt) const { 629 if (!phase->C->post_loop_opts_phase()) { 630 return res; 631 } 632 const TypeInteger* this_type = res->is_integer(bt); 633 const TypeInteger* in_type = phase->type(in(1))->isa_integer(bt); 634 if (in_type != nullptr && 635 (in_type->lo_as_long() != this_type->lo_as_long() || 636 in_type->hi_as_long() != this_type->hi_as_long())) { 637 jlong lo1 = this_type->lo_as_long(); 638 jlong hi1 = this_type->hi_as_long(); 639 int w1 = this_type->_widen; 640 if (lo1 >= 0) { 641 // Keep a range assertion of >=0. 642 lo1 = 0; hi1 = max_signed_integer(bt); 643 } else if (hi1 < 0) { 644 // Keep a range assertion of <0. 645 lo1 = min_signed_integer(bt); hi1 = -1; 646 } else { 647 lo1 = min_signed_integer(bt); hi1 = max_signed_integer(bt); 648 } 649 return TypeInteger::make(MAX2(in_type->lo_as_long(), lo1), 650 MIN2(in_type->hi_as_long(), hi1), 651 MAX2((int)in_type->_widen, w1), bt); 652 } 653 return res; 654 }