< prev index next >

src/hotspot/share/opto/cfgnode.cpp

Print this page

2378               new_ii = new EncodePNode(ii, narrow_t);
2379             } else {
2380               new_ii = new EncodePKlassNode(ii, narrow_t);
2381             }
2382             igvn->register_new_node_with_optimizer(new_ii);
2383           }
2384         }
2385         new_phi->set_req(i, new_ii);
2386       }
2387       igvn->register_new_node_with_optimizer(new_phi, this);
2388       if (is_decodeN) {
2389         progress = new DecodeNNode(new_phi, bottom_type());
2390       } else {
2391         progress = new DecodeNKlassNode(new_phi, bottom_type());
2392       }
2393     }
2394   }
2395 #endif
2396 
2397   // Phi (VB ... VB) => VB (Phi ...) (Phi ...)
2398   if (EnableVectorReboxing && can_reshape && progress == NULL) {
2399     PhaseIterGVN* igvn = phase->is_IterGVN();
2400 
2401     bool all_inputs_are_equiv_vboxes = true;
2402     for (uint i = 1; i < req(); ++i) {
2403       Node* n = in(i);
2404       if (in(i)->Opcode() != Op_VectorBox) {
2405         all_inputs_are_equiv_vboxes = false;
2406         break;
2407       }
2408       // Check that vector type of vboxes is equivalent
2409       if (i != 1) {
2410         if (Type::cmp(in(i-0)->in(VectorBoxNode::Value)->bottom_type(),
2411                       in(i-1)->in(VectorBoxNode::Value)->bottom_type()) != 0) {
2412           all_inputs_are_equiv_vboxes = false;
2413           break;
2414         }
2415         if (Type::cmp(in(i-0)->in(VectorBoxNode::Box)->bottom_type(),
2416                       in(i-1)->in(VectorBoxNode::Box)->bottom_type()) != 0) {
2417           all_inputs_are_equiv_vboxes = false;
2418           break;











2419         }









2420       }




2421     }



2422 
2423     if (all_inputs_are_equiv_vboxes) {
2424       VectorBoxNode* vbox = static_cast<VectorBoxNode*>(in(1));
2425       PhiNode* new_vbox_phi = new PhiNode(r, vbox->box_type());
2426       PhiNode* new_vect_phi = new PhiNode(r, vbox->vec_type());
2427       for (uint i = 1; i < req(); ++i) {
2428         VectorBoxNode* old_vbox = static_cast<VectorBoxNode*>(in(i));
2429         new_vbox_phi->set_req(i, old_vbox->in(VectorBoxNode::Box));
2430         new_vect_phi->set_req(i, old_vbox->in(VectorBoxNode::Value));


























2431       }
2432       igvn->register_new_node_with_optimizer(new_vbox_phi, this);
2433       igvn->register_new_node_with_optimizer(new_vect_phi, this);
2434       progress = new VectorBoxNode(igvn->C, new_vbox_phi, new_vect_phi, vbox->box_type(), vbox->vec_type());
2435     }
2436   }
2437 
2438   return progress;              // Return any progress




2439 }
2440 
2441 bool PhiNode::is_data_loop(RegionNode* r, Node* uin, const PhaseGVN* phase) {
2442   // First, take the short cut when we know it is a loop and the EntryControl data path is dead.
2443   // The loop node may only have one input because the entry path was removed in PhaseIdealLoop::Dominators().
2444   // Then, check if there is a data loop when the phi references itself directly or through other data nodes.
2445   assert(!r->is_Loop() || r->req() <= 3, "Loop node should have 3 or less inputs");
2446   const bool is_loop = (r->is_Loop() && r->req() == 3);
2447   const Node* top = phase->C->top();
2448   if (is_loop) {
2449     return !uin->eqv_uncast(in(LoopNode::EntryControl));
2450   } else {
2451     // We have a data loop either with an unsafe data reference or if a region is unreachable.
2452     return is_unsafe_data_reference(uin)
2453            || (r->req() == 3 && (r->in(1) != top && r->in(2) == top && r->is_unreachable_region(phase)));
2454   }
2455 }
2456 
2457 //------------------------------is_tripcount-----------------------------------
2458 bool PhiNode::is_tripcount(BasicType bt) const {

2378               new_ii = new EncodePNode(ii, narrow_t);
2379             } else {
2380               new_ii = new EncodePKlassNode(ii, narrow_t);
2381             }
2382             igvn->register_new_node_with_optimizer(new_ii);
2383           }
2384         }
2385         new_phi->set_req(i, new_ii);
2386       }
2387       igvn->register_new_node_with_optimizer(new_phi, this);
2388       if (is_decodeN) {
2389         progress = new DecodeNNode(new_phi, bottom_type());
2390       } else {
2391         progress = new DecodeNKlassNode(new_phi, bottom_type());
2392       }
2393     }
2394   }
2395 #endif
2396 
2397   // Phi (VB ... VB) => VB (Phi ...) (Phi ...)
2398   if (EnableVectorReboxing && can_reshape && progress == NULL && type()->isa_oopptr()) {
2399     progress = merge_through_phi(this, phase->is_IterGVN());
2400   }
2401 
2402   return progress;              // Return any progress
2403 }
2404 
2405 Node* PhiNode::clone_through_phi(Node* root_phi, const Type* t, uint c, PhaseIterGVN* igvn) {
2406   Node_Stack stack(1);
2407   VectorSet  visited;
2408   Node_List  node_map;
2409 
2410   stack.push(root_phi, 1); // ignore control
2411   visited.set(root_phi->_idx);
2412 
2413   Node* new_phi = new PhiNode(root_phi->in(0), t);
2414   node_map.map(root_phi->_idx, new_phi);
2415 
2416   while (stack.is_nonempty()) {
2417     Node* n   = stack.node();
2418     uint  idx = stack.index();
2419     assert(n->is_Phi(), "not a phi");
2420     if (idx < n->req()) {
2421       stack.set_index(idx + 1);
2422       Node* def = n->in(idx);
2423       if (def == NULL) {
2424         continue; // ignore dead path
2425       } else if (def->is_Phi()) { // inner node
2426         Node* new_phi = node_map[n->_idx];
2427         if (!visited.test_set(def->_idx)) { // not visited yet
2428           node_map.map(def->_idx, new PhiNode(def->in(0), t));
2429           stack.push(def, 1); // ignore control
2430         }
2431         Node* new_in = node_map[def->_idx];
2432         new_phi->set_req(idx, new_in);
2433       } else if (def->Opcode() == Op_VectorBox) { // leaf
2434         assert(n->is_Phi(), "not a phi");
2435         Node* new_phi = node_map[n->_idx];
2436         new_phi->set_req(idx, def->in(c));
2437       } else {
2438         assert(false, "not optimizeable");
2439         return NULL;
2440       }
2441     } else {
2442       Node* new_phi = node_map[n->_idx];
2443       igvn->register_new_node_with_optimizer(new_phi, n);
2444       stack.pop();
2445     }
2446   }
2447   return new_phi;
2448 }
2449 
2450 Node* PhiNode::merge_through_phi(Node* root_phi, PhaseIterGVN* igvn) {
2451   Node_Stack stack(1);
2452   VectorSet  visited;
2453 
2454   stack.push(root_phi, 1); // ignore control
2455   visited.set(root_phi->_idx);
2456 
2457   VectorBoxNode* cached_vbox = NULL;
2458   while (stack.is_nonempty()) {
2459     Node* n   = stack.node();
2460     uint  idx = stack.index();
2461     if (idx < n->req()) {
2462       stack.set_index(idx + 1);
2463       Node* in = n->in(idx);
2464       if (in == NULL) {
2465         continue; // ignore dead path
2466       } else if (in->isa_Phi()) {
2467         if (!visited.test_set(in->_idx)) {
2468           stack.push(in, 1); // ignore control
2469         }
2470       } else if (in->Opcode() == Op_VectorBox) {
2471         VectorBoxNode* vbox = static_cast<VectorBoxNode*>(in);
2472         if (cached_vbox == NULL) {
2473           cached_vbox = vbox;
2474         } else if (vbox->vec_type() != cached_vbox->vec_type()) {
2475           // TODO: vector type mismatch can be handled with additional reinterpret casts
2476           assert(Type::cmp(vbox->vec_type(), cached_vbox->vec_type()) != 0, "inconsistent");
2477           return NULL; // not optimizable: vector type mismatch
2478         } else if (vbox->box_type() != cached_vbox->box_type()) {
2479           assert(Type::cmp(vbox->box_type(), cached_vbox->box_type()) != 0, "inconsistent");
2480           return NULL; // not optimizable: box type mismatch
2481         }
2482       } else {
2483         return NULL; // not optimizable: neither Phi nor VectorBox
2484       }
2485     } else {
2486       stack.pop();

2487     }
2488   }
2489   assert(cached_vbox != NULL, "sanity");
2490   const TypeInstPtr* btype = cached_vbox->box_type();
2491   const TypeVect*    vtype = cached_vbox->vec_type();
2492   Node* new_vbox_phi = clone_through_phi(root_phi, btype, VectorBoxNode::Box,   igvn);
2493   Node* new_vect_phi = clone_through_phi(root_phi, vtype, VectorBoxNode::Value, igvn);
2494   return new VectorBoxNode(igvn->C, new_vbox_phi, new_vect_phi, btype, vtype);
2495 }
2496 
2497 bool PhiNode::is_data_loop(RegionNode* r, Node* uin, const PhaseGVN* phase) {
2498   // First, take the short cut when we know it is a loop and the EntryControl data path is dead.
2499   // The loop node may only have one input because the entry path was removed in PhaseIdealLoop::Dominators().
2500   // Then, check if there is a data loop when the phi references itself directly or through other data nodes.
2501   assert(!r->is_Loop() || r->req() <= 3, "Loop node should have 3 or less inputs");
2502   const bool is_loop = (r->is_Loop() && r->req() == 3);
2503   const Node* top = phase->C->top();
2504   if (is_loop) {
2505     return !uin->eqv_uncast(in(LoopNode::EntryControl));
2506   } else {
2507     // We have a data loop either with an unsafe data reference or if a region is unreachable.
2508     return is_unsafe_data_reference(uin)
2509            || (r->req() == 3 && (r->in(1) != top && r->in(2) == top && r->is_unreachable_region(phase)));
2510   }
2511 }
2512 
2513 //------------------------------is_tripcount-----------------------------------
2514 bool PhiNode::is_tripcount(BasicType bt) const {
< prev index next >