changeset 9228:ce42ae95d4d6 jdk8u242-b01

8134739: compiler/loopopts/superword/TestVectorizationWithInvariant crashes in loop opts Summary: Bail out of superword optimization if loop was removed (i.e., if zero-trip Opaque1Node was removed). Reviewed-by: kvn, roland
author thartmann
date Tue, 08 Oct 2019 15:38:35 +0200
parents 9b865b281711
children ed8892ef0a8d bf6ea7319424
files src/share/vm/opto/loopnode.hpp src/share/vm/opto/superword.cpp
diffstat 2 files changed, 16 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/opto/loopnode.hpp	Fri Feb 27 11:41:42 2015 +0300
+++ b/src/share/vm/opto/loopnode.hpp	Tue Oct 08 15:38:35 2019 +0200
@@ -279,6 +279,7 @@
     if (iv_phi == NULL) {
       return NULL;
     }
+    assert(iv_phi->is_Phi(), "should be PhiNode");
     Node *ln = iv_phi->in(0);
     if (ln->is_CountedLoop() && ln->as_CountedLoop()->loopexit() == this) {
       return (CountedLoopNode*)ln;
--- a/src/share/vm/opto/superword.cpp	Fri Feb 27 11:41:42 2015 +0300
+++ b/src/share/vm/opto/superword.cpp	Tue Oct 08 15:38:35 2019 +0200
@@ -2208,15 +2208,25 @@
 
 //----------------------------get_pre_loop_end---------------------------
 // Find pre loop end from main loop.  Returns null if none.
-CountedLoopEndNode* SuperWord::get_pre_loop_end(CountedLoopNode *cl) {
-  Node *ctrl = cl->in(LoopNode::EntryControl);
+CountedLoopEndNode* SuperWord::get_pre_loop_end(CountedLoopNode* cl) {
+  Node* ctrl = cl->in(LoopNode::EntryControl);
   if (!ctrl->is_IfTrue() && !ctrl->is_IfFalse()) return NULL;
-  Node *iffm = ctrl->in(0);
+  Node* iffm = ctrl->in(0);
   if (!iffm->is_If()) return NULL;
-  Node *p_f = iffm->in(0);
+  Node* bolzm = iffm->in(1);
+  if (!bolzm->is_Bool()) return NULL;
+  Node* cmpzm = bolzm->in(1);
+  if (!cmpzm->is_Cmp()) return NULL;
+  Node* opqzm = cmpzm->in(2);
+  // Can not optimize a loop if zero-trip Opaque1 node is optimized
+  // away and then another round of loop opts attempted.
+  if (opqzm->Opcode() != Op_Opaque1) {
+    return NULL;
+  }
+  Node* p_f = iffm->in(0);
   if (!p_f->is_IfFalse()) return NULL;
   if (!p_f->in(0)->is_CountedLoopEnd()) return NULL;
-  CountedLoopEndNode *pre_end = p_f->in(0)->as_CountedLoopEnd();
+  CountedLoopEndNode* pre_end = p_f->in(0)->as_CountedLoopEnd();
   CountedLoopNode* loop_node = pre_end->loopnode();
   if (loop_node == NULL || !loop_node->is_pre_loop()) return NULL;
   return pre_end;