diff src/share/vm/opto/subnode.cpp @ 33:3288958bf319

6667580: Optimize CmpP for allocations Summary: CmpP could be optimized out if it compares new allocated objects. Reviewed-by: jrose, never, rasbold
author kvn
date Fri, 29 Feb 2008 09:57:18 -0800
parents a61af66fc99e
children ba764ed4b6f2
line wrap: on
line diff
--- a/src/share/vm/opto/subnode.cpp	Thu Feb 28 15:40:09 2008 -0800
+++ b/src/share/vm/opto/subnode.cpp	Fri Feb 29 09:57:18 2008 -0800
@@ -614,6 +614,13 @@
   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();