RFR: JDK-8275854: C2: assert(stride_con != 0) failed: missed some peephole opt [v3]
王超
duke at openjdk.java.net
Fri Oct 29 08:50:10 UTC 2021
On Thu, 28 Oct 2021 08:42:25 GMT, Roland Westrelin <roland at openjdk.org> wrote:
> The optimization is valid AFAIU, so I don't think blocking it is the right fix. What about something like this:
>
> ```
> diff --git a/src/hotspot/share/opto/ifnode.cpp b/src/hotspot/share/opto/ifnode.cpp
> index 38b40a68b1f..b28a382ebe7 100644
> --- a/src/hotspot/share/opto/ifnode.cpp
> +++ b/src/hotspot/share/opto/ifnode.cpp
> @@ -1721,6 +1721,14 @@ Node* IfProjNode::Identity(PhaseGVN* phase) {
> // will cause this node to be reprocessed once the dead branch is killed.
> in(0)->outcnt() == 1))) {
> // IfNode control
> + if (in(0)->is_BaseCountedLoopEnd()) {
> + Node* head = unique_ctrl_out();
> + if (head != NULL && head->is_BaseCountedLoop() && head->in(LoopNode::LoopBackControl) == this) {
> + Node* new_head = new LoopNode(head->in(LoopNode::EntryControl), this);
> + phase->is_IterGVN()->register_new_node_with_optimizer(new_head);
> + phase->is_IterGVN()->replace_node(head, new_head);
> + }
> + }
> return in(0)->in(0);
> }
> // no progress
> ```
>
> That prevents the crash and gives the loop another chance to be optimized.
Replace the `CountedLoopNode` node with a new `Loop` node is more elegant, and will generate more optimized code as the second proposed version (which exchange the two if node), but your suggested code is more compact. I will change to your suggested version.
-------------
PR: https://git.openjdk.java.net/jdk/pull/6099
More information about the hotspot-compiler-dev
mailing list