503 if( t12->is_con() ) { // Left input is an add of a constant? |
503 if( t12->is_con() ) { // Left input is an add of a constant? |
504 // If the right input is a constant, combine constants |
504 // If the right input is a constant, combine constants |
505 const Type *temp_t2 = phase->type( in(Offset) ); |
505 const Type *temp_t2 = phase->type( in(Offset) ); |
506 if( temp_t2 == Type::TOP ) return NULL; |
506 if( temp_t2 == Type::TOP ) return NULL; |
507 const TypeX *t2 = temp_t2->is_intptr_t(); |
507 const TypeX *t2 = temp_t2->is_intptr_t(); |
|
508 Node* address; |
|
509 Node* offset; |
508 if( t2->is_con() ) { |
510 if( t2->is_con() ) { |
509 // The Add of the flattened expression |
511 // The Add of the flattened expression |
510 set_req(Address, addp->in(Address)); |
512 address = addp->in(Address); |
511 set_req(Offset , phase->MakeConX(t2->get_con() + t12->get_con())); |
513 offset = phase->MakeConX(t2->get_con() + t12->get_con()); |
512 return this; // Made progress |
514 } else { |
|
515 // Else move the constant to the right. ((A+con)+B) into ((A+B)+con) |
|
516 address = phase->transform(new (phase->C, 4) AddPNode(in(Base),addp->in(Address),in(Offset))); |
|
517 offset = addp->in(Offset); |
513 } |
518 } |
514 // Else move the constant to the right. ((A+con)+B) into ((A+B)+con) |
519 PhaseIterGVN *igvn = phase->is_IterGVN(); |
515 set_req(Address, phase->transform(new (phase->C, 4) AddPNode(in(Base),addp->in(Address),in(Offset)))); |
520 if( igvn ) { |
516 set_req(Offset , addp->in(Offset)); |
521 set_req_X(Address,address,igvn); |
|
522 set_req_X(Offset,offset,igvn); |
|
523 } else { |
|
524 set_req(Address,address); |
|
525 set_req(Offset,offset); |
|
526 } |
517 return this; |
527 return this; |
518 } |
528 } |
519 } |
529 } |
520 |
530 |
521 // Raw pointers? |
531 // Raw pointers? |
604 } |
614 } |
605 } |
615 } |
606 } |
616 } |
607 offset = Type::OffsetBot; |
617 offset = Type::OffsetBot; |
608 return NULL; |
618 return NULL; |
|
619 } |
|
620 |
|
621 //------------------------------unpack_offsets---------------------------------- |
|
622 // Collect the AddP offset values into the elements array, giving up |
|
623 // if there are more than length. |
|
624 int AddPNode::unpack_offsets(Node* elements[], int length) { |
|
625 int count = 0; |
|
626 Node* addr = this; |
|
627 Node* base = addr->in(AddPNode::Base); |
|
628 while (addr->is_AddP()) { |
|
629 if (addr->in(AddPNode::Base) != base) { |
|
630 // give up |
|
631 return -1; |
|
632 } |
|
633 elements[count++] = addr->in(AddPNode::Offset); |
|
634 if (count == length) { |
|
635 // give up |
|
636 return -1; |
|
637 } |
|
638 addr = addr->in(AddPNode::Address); |
|
639 } |
|
640 return count; |
609 } |
641 } |
610 |
642 |
611 //------------------------------match_edge------------------------------------- |
643 //------------------------------match_edge------------------------------------- |
612 // Do we Match on this edge index or not? Do not match base pointer edge |
644 // Do we Match on this edge index or not? Do not match base pointer edge |
613 uint AddPNode::match_edge(uint idx) const { |
645 uint AddPNode::match_edge(uint idx) const { |