RFR: 8308504: C2: "malformed control flow" after JDK-8303466

Tobias Hartmann thartmann at openjdk.org
Mon Jul 24 06:05:48 UTC 2023


On Fri, 21 Jul 2023 12:04:12 GMT, Roland Westrelin <roland at openjdk.org> wrote:

> I took that bug over from Emanuel because he's away:
> https://github.com/openjdk/jdk/pull/14331
> 
> I tried adding a `CastII` to narrow the limit of the loop as I
> suggested in a comment on the PR but I found that doesn't work in all
> cases: if the type of the initial value for the loop variable is not
> narrow enough, then the narrower type for the limit doesn't help
> narrow the loop phi type.
> 
> What I propose instead is to add an assert predicate that catches when
> the main loop is unreachable but the zero trip count doesn't constant
> fold. For that to work, the order of predicates must be preserved when
> they are copied or updated. I had to make some small changes to
> guarantee that.

src/hotspot/share/opto/loopPredicate.cpp line 1519:

> 1517:     // init + (current stride - initial stride) is within the loop so narrow its type by leveraging the type of the iv Phi
> 1518:     iv_phi_assertion_predicate_condition(loop->_head->as_CountedLoop(), new_proj, opaque_init, max_value);
> 1519:     new_proj = add_template_assertion_predicate_helper(predicate_proj, reason, new_proj, bol, Op_If);

Shouldn't this use the the `bol` returned by `iv_phi_assertion_predicate_condition`?

src/hotspot/share/opto/loopTransform.cpp line 1345:

> 1343:       predicate = predicate->in(0)->in(0);
> 1344:     }
> 1345:     while(predicates.size() > 0) {

Suggestion:

    while (predicates.size() > 0) {

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/14973#discussion_r1271786307
PR Review Comment: https://git.openjdk.org/jdk/pull/14973#discussion_r1271752307


More information about the hotspot-compiler-dev mailing list