8219517: assert(false) failed: infinite loop in PhaseIterGVN::optimize
Reviewed-by: kvn, thartmann
--- a/src/hotspot/share/opto/memnode.cpp Wed Mar 13 07:16:57 2019 -0700
+++ b/src/hotspot/share/opto/memnode.cpp Wed Mar 13 15:22:28 2019 +0100
@@ -1394,6 +1394,14 @@
Node* in = mem->in(i);
Node* m = optimize_memory_chain(in, t_oop, this, phase);
if (m == mem) {
+ if (i == 1) {
+ // if the first edge was a loop, check second edge too.
+ // If both are replaceable - we are in an infinite loop
+ Node *n = optimize_memory_chain(mem->in(2), t_oop, this, phase);
+ if (n == mem) {
+ break;
+ }
+ }
set_req(Memory, mem->in(cnt - i));
return this; // made change
}