src/share/vm/opto/addnode.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File
*** old/src/share/vm/opto/addnode.cpp	Thu May 15 17:09:25 2014
--- new/src/share/vm/opto/addnode.cpp	Thu May 15 17:09:25 2014

*** 252,302 **** --- 252,301 ---- } if( op1 == Op_SubI ) { const Type *t_sub1 = phase->type( in1->in(1) ); const Type *t_2 = phase->type( in2 ); if( t_sub1->singleton() && t_2->singleton() && t_sub1 != Type::TOP && t_2 != Type::TOP ) ! return new (phase->C) SubINode(phase->makecon( add_ring( t_sub1, t_2 ) ), in1->in(2) ); ! return new SubINode(phase->makecon( add_ring( t_sub1, t_2 ) ), in1->in(2) ); // Convert "(a-b)+(c-d)" into "(a+c)-(b+d)" if( op2 == Op_SubI ) { // Check for dead cycle: d = (a-b)+(c-d) assert( in1->in(2) != this && in2->in(2) != this, "dead loop in AddINode::Ideal" ); - Node *sub = new (phase->C) SubINode(NULL, NULL); - sub->init_req(1, phase->transform(new (phase->C) AddINode(in1->in(1), in2->in(1) ) )); - sub->init_req(2, phase->transform(new (phase->C) AddINode(in1->in(2), in2->in(2) ) )); return sub; } // Convert "(a-b)+(b+c)" into "(a+c)" if( op2 == Op_AddI && in1->in(2) == in2->in(1) ) { assert(in1->in(1) != this && in2->in(2) != this,"dead loop in AddINode::Ideal"); - return new (phase->C) AddINode(in1->in(1), in2->in(2)); } // Convert "(a-b)+(c+b)" into "(a+c)" if( op2 == Op_AddI && in1->in(2) == in2->in(2) ) { assert(in1->in(1) != this && in2->in(1) != this,"dead loop in AddINode::Ideal"); - return new (phase->C) AddINode(in1->in(1), in2->in(1)); } // Convert "(a-b)+(b-c)" into "(a-c)" if( op2 == Op_SubI && in1->in(2) == in2->in(1) ) { assert(in1->in(1) != this && in2->in(2) != this,"dead loop in AddINode::Ideal"); - return new (phase->C) SubINode(in1->in(1), in2->in(2)); } // Convert "(a-b)+(c-a)" into "(c-b)" if( op2 == Op_SubI && in1->in(1) == in2->in(2) ) { assert(in1->in(2) != this && in2->in(1) != this,"dead loop in AddINode::Ideal"); - return new (phase->C) SubINode(in2->in(1), in1->in(2)); } } // Convert "x+(0-y)" into "(x-y)" if( op2 == Op_SubI && phase->type(in2->in(1)) == TypeInt::ZERO ) - return new (phase->C) SubINode(in1, in2->in(2) ); // Convert "(0-y)+x" into "(x-y)" if( op1 == Op_SubI && phase->type(in1->in(1)) == TypeInt::ZERO ) - return new (phase->C) SubINode( in2, in1->in(2) ); // Convert (x>>>z)+y into (x+(y<<z))>>>z for small constant z and y. // Helps with array allocation math constant folding // See 4790063: // Unrestricted transformation is unsafe for some runtime values of 'x'
*** 313,324 **** --- 312,323 ---- jint y = phase->type( in2 )->is_int()->get_con(); if( z < 5 && -5 < y && y < 0 ) { const Type *t_in11 = phase->type(in1->in(1)); if( t_in11 != Type::TOP && (t_in11->is_int()->_lo >= -(y << z)) ) { - Node *a = phase->transform( new (phase->C) AddINode( in1->in(1), phase->intcon(y<<z) ) ); - return new (phase->C) URShiftINode( a, in1->in(2) ); } } } return AddNode::Ideal(phase, can_reshape);
*** 385,444 **** --- 384,442 ---- // Fold (con1-x)+con2 into (con1+con2)-x if( op1 == Op_SubL ) { const Type *t_sub1 = phase->type( in1->in(1) ); const Type *t_2 = phase->type( in2 ); if( t_sub1->singleton() && t_2->singleton() && t_sub1 != Type::TOP && t_2 != Type::TOP ) ! return new (phase->C) SubLNode(phase->makecon( add_ring( t_sub1, t_2 ) ), in1->in(2) ); ! return new SubLNode(phase->makecon( add_ring( t_sub1, t_2 ) ), in1->in(2) ); // Convert "(a-b)+(c-d)" into "(a+c)-(b+d)" if( op2 == Op_SubL ) { // Check for dead cycle: d = (a-b)+(c-d) assert( in1->in(2) != this && in2->in(2) != this, "dead loop in AddLNode::Ideal" ); - Node *sub = new (phase->C) SubLNode(NULL, NULL); - sub->init_req(1, phase->transform(new (phase->C) AddLNode(in1->in(1), in2->in(1) ) )); - sub->init_req(2, phase->transform(new (phase->C) AddLNode(in1->in(2), in2->in(2) ) )); return sub; } // Convert "(a-b)+(b+c)" into "(a+c)" if( op2 == Op_AddL && in1->in(2) == in2->in(1) ) { assert(in1->in(1) != this && in2->in(2) != this,"dead loop in AddLNode::Ideal"); - return new (phase->C) AddLNode(in1->in(1), in2->in(2)); } // Convert "(a-b)+(c+b)" into "(a+c)" if( op2 == Op_AddL && in1->in(2) == in2->in(2) ) { assert(in1->in(1) != this && in2->in(1) != this,"dead loop in AddLNode::Ideal"); - return new (phase->C) AddLNode(in1->in(1), in2->in(1)); } // Convert "(a-b)+(b-c)" into "(a-c)" if( op2 == Op_SubL && in1->in(2) == in2->in(1) ) { assert(in1->in(1) != this && in2->in(2) != this,"dead loop in AddLNode::Ideal"); - return new (phase->C) SubLNode(in1->in(1), in2->in(2)); } // Convert "(a-b)+(c-a)" into "(c-b)" if( op2 == Op_SubL && in1->in(1) == in1->in(2) ) { assert(in1->in(2) != this && in2->in(1) != this,"dead loop in AddLNode::Ideal"); - return new (phase->C) SubLNode(in2->in(1), in1->in(2)); } } // Convert "x+(0-y)" into "(x-y)" if( op2 == Op_SubL && phase->type(in2->in(1)) == TypeLong::ZERO ) - return new (phase->C) SubLNode( in1, in2->in(2) ); // Convert "(0-y)+x" into "(x-y)" if( op1 == Op_SubL && phase->type(in1->in(1)) == TypeInt::ZERO ) - return new (phase->C) SubLNode( in2, in1->in(2) ); // Convert "X+X+X+X+X...+X+Y" into "k*X+Y" or really convert "X+(X+Y)" // into "(X<<1)+Y" and let shift-folding happen. if( op2 == Op_AddL && in2->in(1) == in1 && op1 != Op_ConL && 0 ) { - Node *shift = phase->transform(new (phase->C) LShiftLNode(in1,phase->intcon(1))); - return new (phase->C) AddLNode(shift,in2->in(2)); } return AddNode::Ideal(phase, can_reshape); }
*** 594,604 **** --- 592,602 ---- // The Add of the flattened expression address = addp->in(Address); offset = phase->MakeConX(t2->get_con() + t12->get_con()); } else { // Else move the constant to the right. ((A+con)+B) into ((A+B)+con) - address = phase->transform(new (phase->C) AddPNode(in(Base),addp->in(Address),in(Offset))); offset = addp->in(Offset); } PhaseIterGVN *igvn = phase->is_IterGVN(); if( igvn ) { set_req_X(Address,address,igvn);
*** 614,624 **** --- 612,622 ---- // Raw pointers? if( in(Base)->bottom_type() == Type::TOP ) { // If this is a NULL+long form (from unsafe accesses), switch to a rawptr. if (phase->type(in(Address)) == TypePtr::NULL_PTR) { Node* offset = in(Offset); - return new (phase->C) CastX2PNode(offset); } } // If the right is an add of a constant, push the offset down. // Convert: (ptr + (offset+con)) into (ptr+offset)+con.
*** 626,636 **** --- 624,634 ---- // and only have different constant offsets from the same base. const Node *add = in(Offset); if( add->Opcode() == Op_AddX && add->in(1) != add ) { const Type *t22 = phase->type( add->in(2) ); if( t22->singleton() && (t22 != Type::TOP) ) { // Right input is an add of a constant? - set_req(Address, phase->transform(new (phase->C) AddPNode(in(Base),in(Address),add->in(1)))); set_req(Offset, add->in(2)); PhaseIterGVN *igvn = phase->is_IterGVN(); if (add->outcnt() == 0 && igvn) { // add disconnected. igvn->_worklist.push((Node*)add);
*** 856,866 **** --- 854,864 ---- Node *r = in(2); // Transform MinI1( MinI2(a,b), c) into MinI1( a, MinI2(b,c) ) // to force a right-spline graph for the rest of MinINode::Ideal(). if( l->Opcode() == Op_MinI ) { assert( l != l->in(1), "dead loop in MinINode::Ideal" ); - r = phase->transform(new (phase->C) MinINode(l->in(2),r)); l = l->in(1); set_req(1, l); set_req(2, r); return this; }
*** 904,925 **** --- 902,923 ---- y_off = t->is_int()->get_con(); y = y->in(1); } if( x->_idx > y->_idx ) ! return new (phase->C) MinINode(r->in(1),phase->transform(new (phase->C) MinINode(l,r->in(2)))); // See if covers: MIN2(x+c0,MIN2(y+c1,z)) if( !phase->eqv(x,y) ) return NULL; // If (y == x) transform MIN2(x+c0, MIN2(x+c1,z)) into // MIN2(x+c0 or x+c1 which less, z). ! return new (phase->C) MinINode(phase->transform(new (phase->C) AddINode(x,phase->intcon(MIN2(x_off,y_off)))),r->in(2)); } else { // See if covers: MIN2(x+c0,y+c1) if( !phase->eqv(x,y) ) return NULL; // If (y == x) transform MIN2(x+c0,x+c1) into x+c0 or x+c1 which less. - return new (phase->C) AddINode(x,phase->intcon(MIN2(x_off,y_off))); } } //------------------------------add_ring---------------------------------------

src/share/vm/opto/addnode.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File