8179882: C2: Stale control info after cast node elimination during loop optimization pass
authorvlivanov
Tue, 30 May 2017 21:35:21 +0300
changeset 45425 c454d65f0370
parent 45327 ec60e7df88cd
child 45426 77c950d7840a
child 45429 e41531cfe73e
8179882: C2: Stale control info after cast node elimination during loop optimization pass Reviewed-by: kvn, roland
hotspot/src/share/vm/opto/loopnode.cpp
hotspot/src/share/vm/opto/loopopts.cpp
--- a/hotspot/src/share/vm/opto/loopnode.cpp	Mon May 29 10:32:37 2017 +0200
+++ b/hotspot/src/share/vm/opto/loopnode.cpp	Tue May 30 21:35:21 2017 +0300
@@ -1860,6 +1860,9 @@
   if (_required_safept != NULL && _required_safept->size() > 0) {
     tty->print(" req={"); _required_safept->dump_simple(); tty->print(" }");
   }
+  if (Verbose) {
+    tty->print(" body={"); _body.dump_simple(); tty->print(" }");
+  }
   tty->cr();
 }
 
--- a/hotspot/src/share/vm/opto/loopopts.cpp	Mon May 29 10:32:37 2017 +0200
+++ b/hotspot/src/share/vm/opto/loopopts.cpp	Tue May 30 21:35:21 2017 +0300
@@ -913,7 +913,11 @@
 
   if (n->is_ConstraintCast()) {
     Node* dom_cast = n->as_ConstraintCast()->dominating_cast(this);
-    if (dom_cast != NULL) {
+    // ConstraintCastNode::dominating_cast() uses node control input to determine domination.
+    // Node control inputs don't necessarily agree with loop control info (due to
+    // transformations happened in between), thus additional dominance check is needed
+    // to keep loop info valid.
+    if (dom_cast != NULL && is_dominator(get_ctrl(dom_cast), get_ctrl(n))) {
       _igvn.replace_node(n, dom_cast);
       return dom_cast;
     }