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