```rev 3898 : 8005031: Some cleanup in c2 to prepare for incremental inlining support
 ``` `````` 172 progress = this; 173 add2 = a12; 174 } 175 } 176 177 // Convert "x+(y+1)" into "(x+y)+1". Push constants down the expression tree. 178 int add2_op = add2->Opcode(); 179 if( add2_op == this_op && !con_left ) { 180 Node *a22 = add2->in(2); 181 const Type *t22 = phase->type( a22 ); 182 if( t22->singleton() && t22 != Type::TOP && (add2 != add2->in(1)) && 183 !(add2->in(1)->is_Phi() && add2->in(1)->as_Phi()->is_tripcount()) ) { 184 assert(add2->in(1) != this, "dead loop in AddNode::Ideal"); 185 Node *addx = add2->clone(); 186 addx->set_req(1, in(1)); 187 addx->set_req(2, add2->in(1)); 188 addx = phase->transform(addx); 189 set_req(1, addx); 190 set_req(2, a22); 191 progress = this; 192 } 193 } 194 195 return progress; 196 } 197 198 //------------------------------Value----------------------------------------- 199 // An add node sums it's two _in. If one input is an RSD, we must mixin 200 // the other input's symbols. 201 const Type *AddNode::Value( PhaseTransform *phase ) const { 202 // Either input is TOP ==> the result is TOP 203 const Type *t1 = phase->type( in(1) ); 204 const Type *t2 = phase->type( in(2) ); 205 if( t1 == Type::TOP ) return Type::TOP; 206 if( t2 == Type::TOP ) return Type::TOP; 207 208 // Either input is BOTTOM ==> the result is the local BOTTOM 209 const Type *bot = bottom_type(); 210 if( (t1 == bot) || (t2 == bot) || 211 (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) ) `````` 607 608 // Raw pointers? 609 if( in(Base)->bottom_type() == Type::TOP ) { 610 // If this is a NULL+long form (from unsafe accesses), switch to a rawptr. 611 if (phase->type(in(Address)) == TypePtr::NULL_PTR) { 612 Node* offset = in(Offset); 613 return new (phase->C) CastX2PNode(offset); 614 } 615 } 616 617 // If the right is an add of a constant, push the offset down. 618 // Convert: (ptr + (offset+con)) into (ptr+offset)+con. 619 // The idea is to merge array_base+scaled_index groups together, 620 // and only have different constant offsets from the same base. 621 const Node *add = in(Offset); 622 if( add->Opcode() == Op_AddX && add->in(1) != add ) { 623 const Type *t22 = phase->type( add->in(2) ); 624 if( t22->singleton() && (t22 != Type::TOP) ) { // Right input is an add of a constant? 625 set_req(Address, phase->transform(new (phase->C) AddPNode(in(Base),in(Address),add->in(1)))); 626 set_req(Offset, add->in(2)); 627 return this; // Made progress 628 } 629 } 630 631 return NULL; // No progress 632 } 633 634 //------------------------------bottom_type------------------------------------ 635 // Bottom-type is the pointer-type with unknown offset. 636 const Type *AddPNode::bottom_type() const { 637 if (in(Address) == NULL) return TypePtr::BOTTOM; 638 const TypePtr *tp = in(Address)->bottom_type()->isa_ptr(); 639 if( !tp ) return Type::TOP; // TOP input means TOP output 640 assert( in(Offset)->Opcode() != Op_ConP, "" ); 641 const Type *t = in(Offset)->bottom_type(); 642 if( t == Type::TOP ) 643 return tp->add_offset(Type::OffsetTop); 644 const TypeX *tx = t->is_intptr_t(); 645 intptr_t txoffset = Type::OffsetBot; 646 if (tx->is_con()) { // Left input is an add of a constant? ``` ``` `````` 172 progress = this; 173 add2 = a12; 174 } 175 } 176 177 // Convert "x+(y+1)" into "(x+y)+1". Push constants down the expression tree. 178 int add2_op = add2->Opcode(); 179 if( add2_op == this_op && !con_left ) { 180 Node *a22 = add2->in(2); 181 const Type *t22 = phase->type( a22 ); 182 if( t22->singleton() && t22 != Type::TOP && (add2 != add2->in(1)) && 183 !(add2->in(1)->is_Phi() && add2->in(1)->as_Phi()->is_tripcount()) ) { 184 assert(add2->in(1) != this, "dead loop in AddNode::Ideal"); 185 Node *addx = add2->clone(); 186 addx->set_req(1, in(1)); 187 addx->set_req(2, add2->in(1)); 188 addx = phase->transform(addx); 189 set_req(1, addx); 190 set_req(2, a22); 191 progress = this; 192 PhaseIterGVN *igvn = phase->is_IterGVN(); 193 if (add2->outcnt() == 0 && igvn) { 194 // add disconnected. 195 igvn->_worklist.push(add2); 196 } 197 } 198 } 199 200 return progress; 201 } 202 203 //------------------------------Value----------------------------------------- 204 // An add node sums it's two _in. If one input is an RSD, we must mixin 205 // the other input's symbols. 206 const Type *AddNode::Value( PhaseTransform *phase ) const { 207 // Either input is TOP ==> the result is TOP 208 const Type *t1 = phase->type( in(1) ); 209 const Type *t2 = phase->type( in(2) ); 210 if( t1 == Type::TOP ) return Type::TOP; 211 if( t2 == Type::TOP ) return Type::TOP; 212 213 // Either input is BOTTOM ==> the result is the local BOTTOM 214 const Type *bot = bottom_type(); 215 if( (t1 == bot) || (t2 == bot) || 216 (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) ) `````` 612 613 // Raw pointers? 614 if( in(Base)->bottom_type() == Type::TOP ) { 615 // If this is a NULL+long form (from unsafe accesses), switch to a rawptr. 616 if (phase->type(in(Address)) == TypePtr::NULL_PTR) { 617 Node* offset = in(Offset); 618 return new (phase->C) CastX2PNode(offset); 619 } 620 } 621 622 // If the right is an add of a constant, push the offset down. 623 // Convert: (ptr + (offset+con)) into (ptr+offset)+con. 624 // The idea is to merge array_base+scaled_index groups together, 625 // and only have different constant offsets from the same base. 626 const Node *add = in(Offset); 627 if( add->Opcode() == Op_AddX && add->in(1) != add ) { 628 const Type *t22 = phase->type( add->in(2) ); 629 if( t22->singleton() && (t22 != Type::TOP) ) { // Right input is an add of a constant? 630 set_req(Address, phase->transform(new (phase->C) AddPNode(in(Base),in(Address),add->in(1)))); 631 set_req(Offset, add->in(2)); 632 PhaseIterGVN *igvn = phase->is_IterGVN(); 633 if (add->outcnt() == 0 && igvn) { 634 // add disconnected. 635 igvn->_worklist.push((Node*)add); 636 } 637 return this; // Made progress 638 } 639 } 640 641 return NULL; // No progress 642 } 643 644 //------------------------------bottom_type------------------------------------ 645 // Bottom-type is the pointer-type with unknown offset. 646 const Type *AddPNode::bottom_type() const { 647 if (in(Address) == NULL) return TypePtr::BOTTOM; 648 const TypePtr *tp = in(Address)->bottom_type()->isa_ptr(); 649 if( !tp ) return Type::TOP; // TOP input means TOP output 650 assert( in(Offset)->Opcode() != Op_ConP, "" ); 651 const Type *t = in(Offset)->bottom_type(); 652 if( t == Type::TOP ) 653 return tp->add_offset(Type::OffsetTop); 654 const TypeX *tx = t->is_intptr_t(); 655 intptr_t txoffset = Type::OffsetBot; 656 if (tx->is_con()) { // Left input is an add of a constant? ```