Merge

Thu, 22 May 2014 13:05:24 -0700

author
drchase
date
Thu, 22 May 2014 13:05:24 -0700
changeset 6681
1555c0843770
parent 6680
78bbf4d43a14
parent 6679
968a17f18337
child 6682
0fb5b60ab4a2

Merge

src/share/vm/opto/doCall.cpp file | annotate | diff | comparison | revisions
src/share/vm/opto/phaseX.cpp file | annotate | diff | comparison | revisions
src/share/vm/opto/subnode.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/opto/c2_globals.hpp	Thu May 22 15:52:41 2014 -0400
     1.2 +++ b/src/share/vm/opto/c2_globals.hpp	Thu May 22 13:05:24 2014 -0700
     1.3 @@ -455,7 +455,7 @@
     1.4    notproduct(bool, PrintEliminateLocks, false,                              \
     1.5            "Print out when locks are eliminated")                            \
     1.6                                                                              \
     1.7 -  product(bool, EliminateAutoBox, false,                                    \
     1.8 +  product(bool, EliminateAutoBox, true,                                     \
     1.9            "Control optimizations for autobox elimination")                  \
    1.10                                                                              \
    1.11    diagnostic(bool, UseImplicitStableValues, true,                           \
     2.1 --- a/src/share/vm/opto/callGenerator.cpp	Thu May 22 15:52:41 2014 -0400
     2.2 +++ b/src/share/vm/opto/callGenerator.cpp	Thu May 22 13:05:24 2014 -0700
     2.3 @@ -381,7 +381,7 @@
     2.4    }
     2.5  
     2.6    // Setup default node notes to be picked up by the inlining
     2.7 -  Node_Notes* old_nn = C->default_node_notes();
     2.8 +  Node_Notes* old_nn = C->node_notes_at(call->_idx);
     2.9    if (old_nn != NULL) {
    2.10      Node_Notes* entry_nn = old_nn->clone(C);
    2.11      entry_nn->set_jvms(jvms);
     3.1 --- a/src/share/vm/opto/doCall.cpp	Thu May 22 15:52:41 2014 -0400
     3.2 +++ b/src/share/vm/opto/doCall.cpp	Thu May 22 13:05:24 2014 -0700
     3.3 @@ -358,7 +358,7 @@
     3.4  bool Compile::should_delay_boxing_inlining(ciMethod* call_method, JVMState* jvms) {
     3.5    if (eliminate_boxing() && call_method->is_boxing_method()) {
     3.6      set_has_boxed_value(true);
     3.7 -    return true;
     3.8 +    return aggressive_unboxing();
     3.9    }
    3.10    return false;
    3.11  }
     4.1 --- a/src/share/vm/opto/ifnode.cpp	Thu May 22 15:52:41 2014 -0400
     4.2 +++ b/src/share/vm/opto/ifnode.cpp	Thu May 22 13:05:24 2014 -0700
     4.3 @@ -673,7 +673,7 @@
     4.4  //           /    Region
     4.5  //
     4.6  Node* IfNode::fold_compares(PhaseGVN* phase) {
     4.7 -  if (!phase->C->eliminate_boxing() || Opcode() != Op_If) return NULL;
     4.8 +  if (Opcode() != Op_If) return NULL;
     4.9  
    4.10    Node* this_cmp = in(1)->in(1);
    4.11    if (this_cmp != NULL && this_cmp->Opcode() == Op_CmpI &&
     5.1 --- a/src/share/vm/opto/phaseX.cpp	Thu May 22 15:52:41 2014 -0400
     5.2 +++ b/src/share/vm/opto/phaseX.cpp	Thu May 22 13:05:24 2014 -0700
     5.3 @@ -1379,6 +1379,15 @@
     5.4            _worklist.push(u);
     5.5        }
     5.6      }
     5.7 +    // If changed AddI/SubI inputs, check CmpU for range check optimization.
     5.8 +    if (use_op == Op_AddI || use_op == Op_SubI) {
     5.9 +      for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) {
    5.10 +        Node* u = use->fast_out(i2);
    5.11 +        if (u->is_Cmp() && (u->Opcode() == Op_CmpU)) {
    5.12 +          _worklist.push(u);
    5.13 +        }
    5.14 +      }
    5.15 +    }
    5.16      // If changed AddP inputs, check Stores for loop invariant
    5.17      if( use_op == Op_AddP ) {
    5.18        for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) {
     6.1 --- a/src/share/vm/opto/subnode.cpp	Thu May 22 15:52:41 2014 -0400
     6.2 +++ b/src/share/vm/opto/subnode.cpp	Thu May 22 13:05:24 2014 -0700
     6.3 @@ -80,7 +80,7 @@
     6.4  
     6.5  //------------------------------Value------------------------------------------
     6.6  // A subtract node differences it's two inputs.
     6.7 -const Type *SubNode::Value( PhaseTransform *phase ) const {
     6.8 +const Type* SubNode::Value_common(PhaseTransform *phase) const {
     6.9    const Node* in1 = in(1);
    6.10    const Node* in2 = in(2);
    6.11    // Either input is TOP ==> the result is TOP
    6.12 @@ -97,6 +97,16 @@
    6.13    if( t1 == Type::BOTTOM || t2 == Type::BOTTOM )
    6.14      return bottom_type();
    6.15  
    6.16 +  return NULL;
    6.17 +}
    6.18 +
    6.19 +const Type* SubNode::Value(PhaseTransform *phase) const {
    6.20 +  const Type* t = Value_common(phase);
    6.21 +  if (t != NULL) {
    6.22 +    return t;
    6.23 +  }
    6.24 +  const Type* t1 = phase->type(in(1));
    6.25 +  const Type* t2 = phase->type(in(2));
    6.26    return sub(t1,t2);            // Local flavor of type subtraction
    6.27  
    6.28  }
    6.29 @@ -570,6 +580,81 @@
    6.30    return TypeInt::CC;                   // else use worst case results
    6.31  }
    6.32  
    6.33 +const Type* CmpUNode::Value(PhaseTransform *phase) const {
    6.34 +  const Type* t = SubNode::Value_common(phase);
    6.35 +  if (t != NULL) {
    6.36 +    return t;
    6.37 +  }
    6.38 +  const Node* in1 = in(1);
    6.39 +  const Node* in2 = in(2);
    6.40 +  const Type* t1 = phase->type(in1);
    6.41 +  const Type* t2 = phase->type(in2);
    6.42 +  assert(t1->isa_int(), "CmpU has only Int type inputs");
    6.43 +  if (t2 == TypeInt::INT) { // Compare to bottom?
    6.44 +    return bottom_type();
    6.45 +  }
    6.46 +  uint in1_op = in1->Opcode();
    6.47 +  if (in1_op == Op_AddI || in1_op == Op_SubI) {
    6.48 +    // The problem rise when result of AddI(SubI) may overflow
    6.49 +    // signed integer value. Let say the input type is
    6.50 +    // [256, maxint] then +128 will create 2 ranges due to
    6.51 +    // overflow: [minint, minint+127] and [384, maxint].
    6.52 +    // But C2 type system keep only 1 type range and as result
    6.53 +    // it use general [minint, maxint] for this case which we
    6.54 +    // can't optimize.
    6.55 +    //
    6.56 +    // Make 2 separate type ranges based on types of AddI(SubI) inputs
    6.57 +    // and compare results of their compare. If results are the same
    6.58 +    // CmpU node can be optimized.
    6.59 +    const Node* in11 = in1->in(1);
    6.60 +    const Node* in12 = in1->in(2);
    6.61 +    const Type* t11 = (in11 == in1) ? Type::TOP : phase->type(in11);
    6.62 +    const Type* t12 = (in12 == in1) ? Type::TOP : phase->type(in12);
    6.63 +    // Skip cases when input types are top or bottom.
    6.64 +    if ((t11 != Type::TOP) && (t11 != TypeInt::INT) &&
    6.65 +        (t12 != Type::TOP) && (t12 != TypeInt::INT)) {
    6.66 +      const TypeInt *r0 = t11->is_int();
    6.67 +      const TypeInt *r1 = t12->is_int();
    6.68 +      jlong lo_r0 = r0->_lo;
    6.69 +      jlong hi_r0 = r0->_hi;
    6.70 +      jlong lo_r1 = r1->_lo;
    6.71 +      jlong hi_r1 = r1->_hi;
    6.72 +      if (in1_op == Op_SubI) {
    6.73 +        jlong tmp = hi_r1;
    6.74 +        hi_r1 = -lo_r1;
    6.75 +        lo_r1 = -tmp;
    6.76 +        // Note, for substructing [minint,x] type range
    6.77 +        // long arithmetic provides correct overflow answer.
    6.78 +        // The confusion come from the fact that in 32-bit
    6.79 +        // -minint == minint but in 64-bit -minint == maxint+1.
    6.80 +      }
    6.81 +      jlong lo_long = lo_r0 + lo_r1;
    6.82 +      jlong hi_long = hi_r0 + hi_r1;
    6.83 +      int lo_tr1 = min_jint;
    6.84 +      int hi_tr1 = (int)hi_long;
    6.85 +      int lo_tr2 = (int)lo_long;
    6.86 +      int hi_tr2 = max_jint;
    6.87 +      bool underflow = lo_long != (jlong)lo_tr2;
    6.88 +      bool overflow  = hi_long != (jlong)hi_tr1;
    6.89 +      // Use sub(t1, t2) when there is no overflow (one type range)
    6.90 +      // or when both overflow and underflow (too complex).
    6.91 +      if ((underflow != overflow) && (hi_tr1 < lo_tr2)) {
    6.92 +        // Overflow only on one boundary, compare 2 separate type ranges.
    6.93 +        int w = MAX2(r0->_widen, r1->_widen); // _widen does not matter here
    6.94 +        const TypeInt* tr1 = TypeInt::make(lo_tr1, hi_tr1, w);
    6.95 +        const TypeInt* tr2 = TypeInt::make(lo_tr2, hi_tr2, w);
    6.96 +        const Type* cmp1 = sub(tr1, t2);
    6.97 +        const Type* cmp2 = sub(tr2, t2);
    6.98 +        if (cmp1 == cmp2) {
    6.99 +          return cmp1; // Hit!
   6.100 +        }
   6.101 +      }
   6.102 +    }
   6.103 +  }
   6.104 +
   6.105 +  return sub(t1, t2);            // Local flavor of type subtraction
   6.106 +}
   6.107 +
   6.108  bool CmpUNode::is_index_range_check() const {
   6.109    // Check for the "(X ModI Y) CmpU Y" shape
   6.110    return (in(1)->Opcode() == Op_ModI &&
     7.1 --- a/src/share/vm/opto/subnode.hpp	Thu May 22 15:52:41 2014 -0400
     7.2 +++ b/src/share/vm/opto/subnode.hpp	Thu May 22 13:05:24 2014 -0700
     7.3 @@ -50,6 +50,7 @@
     7.4    // Compute a new Type for this node.  Basically we just do the pre-check,
     7.5    // then call the virtual add() to set the type.
     7.6    virtual const Type *Value( PhaseTransform *phase ) const;
     7.7 +  const Type* Value_common( PhaseTransform *phase ) const;
     7.8  
     7.9    // Supplied function returns the subtractend of the inputs.
    7.10    // This also type-checks the inputs for sanity.  Guaranteed never to
    7.11 @@ -158,6 +159,7 @@
    7.12    CmpUNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {}
    7.13    virtual int Opcode() const;
    7.14    virtual const Type *sub( const Type *, const Type * ) const;
    7.15 +  const Type *Value( PhaseTransform *phase ) const;
    7.16    bool is_index_range_check() const;
    7.17  };
    7.18  

mercurial