src/hotspot/share/opto/split_if.cpp
changeset 47820 1bc021ddeae0
parent 47216 71c04702a3d5
child 48131 235a18d659fc
--- a/src/hotspot/share/opto/split_if.cpp	Wed Oct 25 10:05:17 2017 +0200
+++ b/src/hotspot/share/opto/split_if.cpp	Thu Nov 09 12:43:13 2017 -0800
@@ -116,9 +116,23 @@
         assert( bol->is_Bool(), "" );
         if (bol->outcnt() == 1) {
           Node* use = bol->unique_out();
-          Node *use_c = use->is_If() ? use->in(0) : get_ctrl(use);
-          if (use_c == blk1 || use_c == blk2) {
-            continue;
+          if (use->Opcode() == Op_Opaque4) {
+            if (use->outcnt() == 1) {
+              Node* iff = use->unique_out();
+              assert(iff->is_If(), "unexpected node type");
+              Node *use_c = iff->in(0);
+              if (use_c == blk1 || use_c == blk2) {
+                continue;
+              }
+            }
+          } else {
+            // We might see an Opaque1 from a loop limit check here
+            assert(use->is_If() || use->is_CMove() || use->Opcode() == Op_Opaque1, "unexpected node type");
+            Node *use_c = use->is_If() ? use->in(0) : get_ctrl(use);
+            if (use_c == blk1 || use_c == blk2) {
+              assert(use->is_CMove(), "unexpected node type");
+              continue;
+            }
           }
         }
         if (get_ctrl(bol) == blk1 || get_ctrl(bol) == blk2) {
@@ -129,17 +143,40 @@
             bol->dump();
           }
 #endif
-          for (DUIterator_Last jmin, j = bol->last_outs(jmin); j >= jmin; --j) {
-            // Uses are either IfNodes or CMoves
-            Node* iff = bol->last_out(j);
-            assert( iff->in(1) == bol, "" );
-            // Get control block of either the CMove or the If input
-            Node *iff_ctrl = iff->is_If() ? iff->in(0) : get_ctrl(iff);
-            Node *x = bol->clone();
-            register_new_node(x, iff_ctrl);
-            _igvn.replace_input_of(iff, 1, x);
+          for (DUIterator j = bol->outs(); bol->has_out(j); j++) {
+            Node* u = bol->out(j);
+            // Uses are either IfNodes, CMoves or Opaque4
+            if (u->Opcode() == Op_Opaque4) {
+              assert(u->in(1) == bol, "bad input");
+              for (DUIterator_Last kmin, k = u->last_outs(kmin); k >= kmin; --k) {
+                Node* iff = u->last_out(k);
+                assert(iff->is_If() || iff->is_CMove(), "unexpected node type");
+                assert( iff->in(1) == u, "" );
+                // Get control block of either the CMove or the If input
+                Node *iff_ctrl = iff->is_If() ? iff->in(0) : get_ctrl(iff);
+                Node *x1 = bol->clone();
+                Node *x2 = u->clone();
+                register_new_node(x1, iff_ctrl);
+                register_new_node(x2, iff_ctrl);
+                _igvn.replace_input_of(x2, 1, x1);
+                _igvn.replace_input_of(iff, 1, x2);
+              }
+              _igvn.remove_dead_node(u);
+              --j;
+            } else {
+              // We might see an Opaque1 from a loop limit check here
+              assert(u->is_If() || u->is_CMove() || u->Opcode() == Op_Opaque1, "unexpected node type");
+              assert(u->in(1) == bol, "");
+              // Get control block of either the CMove or the If input
+              Node *u_ctrl = u->is_If() ? u->in(0) : get_ctrl(u);
+              assert(u_ctrl != blk1 && u_ctrl != blk2, "won't converge");
+              Node *x = bol->clone();
+              register_new_node(x, u_ctrl);
+              _igvn.replace_input_of(u, 1, x);
+              --j;
+            }
           }
-          _igvn.remove_dead_node( bol );
+          _igvn.remove_dead_node(bol);
           --i;
         }
       }