6667580: Optimize CmpP for allocations

CmpP could be optimized out if it compares new allocated objects.

Reviewed-by: jrose, never, rasbold
This commit is contained in:
Vladimir Kozlov 2008-02-29 09:57:18 -08:00
parent 9a4ccf8a06
commit c223fed084
5 changed files with 19 additions and 6 deletions

View file

@ -614,6 +614,13 @@ const Type *CmpPNode::sub( const Type *t1, const Type *t2 ) const {
const TypeOopPtr* p0 = r0->isa_oopptr();
const TypeOopPtr* p1 = r1->isa_oopptr();
if (p0 && p1) {
Node* in1 = in(1)->uncast();
Node* in2 = in(2)->uncast();
AllocateNode* alloc1 = AllocateNode::Ideal_allocation(in1, NULL);
AllocateNode* alloc2 = AllocateNode::Ideal_allocation(in2, NULL);
if (MemNode::detect_ptr_independence(in1, alloc1, in2, alloc2, NULL)) {
return TypeInt::CC_GT; // different pointers
}
ciKlass* klass0 = p0->klass();
bool xklass0 = p0->klass_is_exact();
ciKlass* klass1 = p1->klass();