RFR(M): 8212610: Fix handling of memory in PhaseIdealLoop::clone_loop_predicates()

Roland Westrelin rwestrel at redhat.com
Tue Oct 23 15:49:44 UTC 2018


We found a bug in that code so here is an updated webrev:

http://cr.openjdk.java.net/~roland/8212610/webrev.01/

> In what case we will not have memory Phi when there is region for cloned predicate? I thought it was always created. And 
> your new created Phi has the same input (mem) on all branches - would not it be optimized out later?

With this before cloning:

Predicate 1
..
Predicate n

profile predicate 1
..
write barrier
...
profile predicate n

loop head

There are 2 uncommon trap calls (one for predicates, one for profile
predicates), each one is dominated by a region. In the example above,
the region for predicates has no phi because there's no memory producing
nodes that's control dependent on one of the predicates. The region for
profile predicates has a phi to merge memory state before and after the
write barrier. Then:

Predicate 1
..
Predicate n

profile predicate 1
..
write barrier
...
profile predicate n

cloned predicate

cloned profile predicate

the region for predicates still has no phi but the cloned predicates is
dominated by a write barrier so the control edge that's coming into the
region for predicates from the cloned predicate has different memory
state and a memory phi is needed.

One of the inputs of the newly created phi is updated by:

364         igvn->replace_input_of(phi, r->req()-1, dom_use->in(dom_r->find_edge(other_dom_proj)));

so the phi doesn't have identical inputs.

> Why you removed is_Proj() from assert() in second part of changes?

PhaseIdealLoop::clone_predicate() returns a ProjNode so the is_Proj() is
useless.

Roland.


More information about the hotspot-compiler-dev mailing list