1.1 --- a/src/share/vm/opto/connode.cpp Mon Dec 01 09:38:52 2014 -0500 1.2 +++ b/src/share/vm/opto/connode.cpp Mon Dec 01 22:27:00 2014 +0100 1.3 @@ -441,6 +441,101 @@ 1.4 return this; 1.5 } 1.6 1.7 +uint CastIINode::size_of() const { 1.8 + return sizeof(*this); 1.9 +} 1.10 + 1.11 +uint CastIINode::cmp(const Node &n) const { 1.12 + return TypeNode::cmp(n) && ((CastIINode&)n)._carry_dependency == _carry_dependency; 1.13 +} 1.14 + 1.15 +Node *CastIINode::Identity(PhaseTransform *phase) { 1.16 + if (_carry_dependency) { 1.17 + return this; 1.18 + } 1.19 + return ConstraintCastNode::Identity(phase); 1.20 +} 1.21 + 1.22 +const Type *CastIINode::Value(PhaseTransform *phase) const { 1.23 + const Type *res = ConstraintCastNode::Value(phase); 1.24 + 1.25 + // Try to improve the type of the CastII if we recognize a CmpI/If 1.26 + // pattern. 1.27 + if (_carry_dependency) { 1.28 + if (in(0) != NULL && (in(0)->is_IfFalse() || in(0)->is_IfTrue())) { 1.29 + Node* proj = in(0); 1.30 + if (proj->in(0)->in(1)->is_Bool()) { 1.31 + Node* b = proj->in(0)->in(1); 1.32 + if (b->in(1)->Opcode() == Op_CmpI) { 1.33 + Node* cmp = b->in(1); 1.34 + if (cmp->in(1) == in(1) && phase->type(cmp->in(2))->isa_int()) { 1.35 + const TypeInt* in2_t = phase->type(cmp->in(2))->is_int(); 1.36 + const Type* t = TypeInt::INT; 1.37 + BoolTest test = b->as_Bool()->_test; 1.38 + if (proj->is_IfFalse()) { 1.39 + test = test.negate(); 1.40 + } 1.41 + BoolTest::mask m = test._test; 1.42 + jlong lo_long = min_jint; 1.43 + jlong hi_long = max_jint; 1.44 + if (m == BoolTest::le || m == BoolTest::lt) { 1.45 + hi_long = in2_t->_hi; 1.46 + if (m == BoolTest::lt) { 1.47 + hi_long -= 1; 1.48 + } 1.49 + } else if (m == BoolTest::ge || m == BoolTest::gt) { 1.50 + lo_long = in2_t->_lo; 1.51 + if (m == BoolTest::gt) { 1.52 + lo_long += 1; 1.53 + } 1.54 + } else if (m == BoolTest::eq) { 1.55 + lo_long = in2_t->_lo; 1.56 + hi_long = in2_t->_hi; 1.57 + } else if (m == BoolTest::ne) { 1.58 + // can't do any better 1.59 + } else { 1.60 + stringStream ss; 1.61 + test.dump_on(&ss); 1.62 + fatal(err_msg_res("unexpected comparison %s", ss.as_string())); 1.63 + } 1.64 + int lo_int = (int)lo_long; 1.65 + int hi_int = (int)hi_long; 1.66 + 1.67 + if (lo_long != (jlong)lo_int) { 1.68 + lo_int = min_jint; 1.69 + } 1.70 + if (hi_long != (jlong)hi_int) { 1.71 + hi_int = max_jint; 1.72 + } 1.73 + 1.74 + t = TypeInt::make(lo_int, hi_int, Type::WidenMax); 1.75 + 1.76 + res = res->filter_speculative(t); 1.77 + 1.78 + return res; 1.79 + } 1.80 + } 1.81 + } 1.82 + } 1.83 + } 1.84 + return res; 1.85 +} 1.86 + 1.87 +Node *CastIINode::Ideal_DU_postCCP(PhaseCCP *ccp) { 1.88 + if (_carry_dependency) { 1.89 + return NULL; 1.90 + } 1.91 + return ConstraintCastNode::Ideal_DU_postCCP(ccp); 1.92 +} 1.93 + 1.94 +#ifndef PRODUCT 1.95 +void CastIINode::dump_spec(outputStream *st) const { 1.96 + TypeNode::dump_spec(st); 1.97 + if (_carry_dependency) { 1.98 + st->print(" carry dependency"); 1.99 + } 1.100 +} 1.101 +#endif 1.102 1.103 //============================================================================= 1.104