Mercurial > hg > truffle
comparison src/share/vm/opto/cfgnode.cpp @ 7473:d092d1b31229
8005071: Incremental inlining for JSR 292
Summary: post parse inlining driven by number of live nodes.
Reviewed-by: twisti, kvn, jrose
author | roland |
---|---|
date | Sun, 23 Dec 2012 17:08:22 +0100 |
parents | ad5dd04754ee |
children | 886d1fd67dc3 |
comparison
equal
deleted
inserted
replaced
7445:cd962e15c08e | 7473:d092d1b31229 |
---|---|
361 } | 361 } |
362 | 362 |
363 return true; // The Region node is unreachable - it is dead. | 363 return true; // The Region node is unreachable - it is dead. |
364 } | 364 } |
365 | 365 |
366 bool RegionNode::try_clean_mem_phi(PhaseGVN *phase) { | |
367 // Incremental inlining + PhaseStringOpts sometimes produce: | |
368 // | |
369 // cmpP with 1 top input | |
370 // | | |
371 // If | |
372 // / \ | |
373 // IfFalse IfTrue /- Some Node | |
374 // \ / / / | |
375 // Region / /-MergeMem | |
376 // \---Phi | |
377 // | |
378 // | |
379 // It's expected by PhaseStringOpts that the Region goes away and is | |
380 // replaced by If's control input but because there's still a Phi, | |
381 // the Region stays in the graph. The top input from the cmpP is | |
382 // propagated forward and a subgraph that is useful goes away. The | |
383 // code below replaces the Phi with the MergeMem so that the Region | |
384 // is simplified. | |
385 | |
386 PhiNode* phi = has_unique_phi(); | |
387 if (phi && phi->type() == Type::MEMORY && req() == 3 && phi->is_diamond_phi(true)) { | |
388 MergeMemNode* m = NULL; | |
389 assert(phi->req() == 3, "same as region"); | |
390 for (uint i = 1; i < 3; ++i) { | |
391 Node *mem = phi->in(i); | |
392 if (mem && mem->is_MergeMem() && in(i)->outcnt() == 1) { | |
393 // Nothing is control-dependent on path #i except the region itself. | |
394 m = mem->as_MergeMem(); | |
395 uint j = 3 - i; | |
396 Node* other = phi->in(j); | |
397 if (other && other == m->base_memory()) { | |
398 // m is a successor memory to other, and is not pinned inside the diamond, so push it out. | |
399 // This will allow the diamond to collapse completely. | |
400 phase->is_IterGVN()->replace_node(phi, m); | |
401 return true; | |
402 } | |
403 } | |
404 } | |
405 } | |
406 return false; | |
407 } | |
408 | |
366 //------------------------------Ideal------------------------------------------ | 409 //------------------------------Ideal------------------------------------------ |
367 // Return a node which is more "ideal" than the current node. Must preserve | 410 // Return a node which is more "ideal" than the current node. Must preserve |
368 // the CFG, but we can still strip out dead paths. | 411 // the CFG, but we can still strip out dead paths. |
369 Node *RegionNode::Ideal(PhaseGVN *phase, bool can_reshape) { | 412 Node *RegionNode::Ideal(PhaseGVN *phase, bool can_reshape) { |
370 if( !can_reshape && !in(0) ) return NULL; // Already degraded to a Copy | 413 if( !can_reshape && !in(0) ) return NULL; // Already degraded to a Copy |
373 // Check for RegionNode with no Phi users and both inputs come from either | 416 // Check for RegionNode with no Phi users and both inputs come from either |
374 // arm of the same IF. If found, then the control-flow split is useless. | 417 // arm of the same IF. If found, then the control-flow split is useless. |
375 bool has_phis = false; | 418 bool has_phis = false; |
376 if (can_reshape) { // Need DU info to check for Phi users | 419 if (can_reshape) { // Need DU info to check for Phi users |
377 has_phis = (has_phi() != NULL); // Cache result | 420 has_phis = (has_phi() != NULL); // Cache result |
421 if (has_phis && try_clean_mem_phi(phase)) { | |
422 has_phis = false; | |
423 } | |
424 | |
378 if (!has_phis) { // No Phi users? Nothing merging? | 425 if (!has_phis) { // No Phi users? Nothing merging? |
379 for (uint i = 1; i < req()-1; i++) { | 426 for (uint i = 1; i < req()-1; i++) { |
380 Node *if1 = in(i); | 427 Node *if1 = in(i); |
381 if( !if1 ) continue; | 428 if( !if1 ) continue; |
382 Node *iff = if1->in(0); | 429 Node *iff = if1->in(0); |
1003 | 1050 |
1004 | 1051 |
1005 //------------------------------is_diamond_phi--------------------------------- | 1052 //------------------------------is_diamond_phi--------------------------------- |
1006 // Does this Phi represent a simple well-shaped diamond merge? Return the | 1053 // Does this Phi represent a simple well-shaped diamond merge? Return the |
1007 // index of the true path or 0 otherwise. | 1054 // index of the true path or 0 otherwise. |
1008 int PhiNode::is_diamond_phi() const { | 1055 // If check_control_only is true, do not inspect the If node at the |
1056 // top, and return -1 (not an edge number) on success. | |
1057 int PhiNode::is_diamond_phi(bool check_control_only) const { | |
1009 // Check for a 2-path merge | 1058 // Check for a 2-path merge |
1010 Node *region = in(0); | 1059 Node *region = in(0); |
1011 if( !region ) return 0; | 1060 if( !region ) return 0; |
1012 if( region->req() != 3 ) return 0; | 1061 if( region->req() != 3 ) return 0; |
1013 if( req() != 3 ) return 0; | 1062 if( req() != 3 ) return 0; |
1016 Node *ifp2 = region->in(2); | 1065 Node *ifp2 = region->in(2); |
1017 if( !ifp1 || !ifp2 ) return 0; | 1066 if( !ifp1 || !ifp2 ) return 0; |
1018 Node *iff = ifp1->in(0); | 1067 Node *iff = ifp1->in(0); |
1019 if( !iff || !iff->is_If() ) return 0; | 1068 if( !iff || !iff->is_If() ) return 0; |
1020 if( iff != ifp2->in(0) ) return 0; | 1069 if( iff != ifp2->in(0) ) return 0; |
1070 if (check_control_only) return -1; | |
1021 // Check for a proper bool/cmp | 1071 // Check for a proper bool/cmp |
1022 const Node *b = iff->in(1); | 1072 const Node *b = iff->in(1); |
1023 if( !b->is_Bool() ) return 0; | 1073 if( !b->is_Bool() ) return 0; |
1024 const Node *cmp = b->in(1); | 1074 const Node *cmp = b->in(1); |
1025 if( !cmp->is_Cmp() ) return 0; | 1075 if( !cmp->is_Cmp() ) return 0; |