8271341: Opcode() != Op_If && Opcode() != Op_RangeCheck) || outcnt() == 2 assert failure with Test7179138_1.java

Reviewed-by: kvn, thartmann
This commit is contained in:
Roland Westrelin 2021-09-07 15:13:12 +00:00
parent 041ae20b10
commit 99fb12c798
2 changed files with 18 additions and 2 deletions

View File

@ -277,6 +277,20 @@ void StringConcat::eliminate_unneeded_control() {
C->gvn_replace_by(n, n->in(0)->in(0));
// get rid of the other projection
C->gvn_replace_by(n->in(0)->as_If()->proj_out(false), C->top());
} else if (n->is_Region()) {
Node* iff = n->in(1)->in(0);
assert(n->req() == 3 && n->in(2)->in(0) == iff, "not a diamond");
assert(iff->is_If(), "no if for the diamond");
Node* bol = iff->in(1);
assert(bol->is_Bool(), "unexpected if shape");
Node* cmp = bol->in(1);
assert(cmp->is_Cmp(), "unexpected if shape");
if (cmp->in(1)->is_top() || cmp->in(2)->is_top()) {
// This region should lose its Phis and be optimized out by igvn but there's a chance the if folds to top first
// which then causes a reachable part of the graph to become dead.
Compile* C = _stringopts->C;
C->gvn_replace_by(n, iff->in(0));
}
}
}
}
@ -1003,6 +1017,7 @@ bool StringConcat::validate_control_flow() {
// The IGVN will make this simple diamond go away when it
// transforms the Region. Make sure it sees it.
Compile::current()->record_for_igvn(ptr);
_control.push(ptr);
ptr = ptr->in(1)->in(0)->in(0);
continue;
}

View File

@ -23,11 +23,13 @@
/*
* @test
* @bug 7179138
* @bug 7179138 8271341
* @summary Incorrect result with String concatenation optimization
*
* @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation
* compiler.c2.Test7179138_1
* @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation
* -XX:+UnlockDiagnosticVMOptions -XX:+StressIGVN -XX:RepeatCompilation=100 compiler.c2.Test7179138_1
*
* @author Skip Balk
*/
@ -67,4 +69,3 @@ public class Test7179138_1 {
}
}
}