< prev index next >

src/share/vm/opto/superword.cpp

Print this page

        

@@ -297,10 +297,11 @@
 
   if (is_slp) {
     // Now we try to find the maximum supported consistent vector which the machine
     // description can use
     bool small_basic_type = false;
+    bool flag_small_bt = false;
     for (uint i = 0; i < lpt()->_body.size(); i++) {
       if (ignored_loop_nodes[i] != -1) continue;
 
       BasicType bt;
       Node* n = lpt()->_body.at(i);

@@ -343,14 +344,40 @@
         break;
       }
 
       // Map the maximal common vector
       if (VectorNode::implemented(n->Opcode(), cur_max_vector, bt)) {
-        if (cur_max_vector < max_vector) {
+        if (cur_max_vector < max_vector && !flag_small_bt) {
           max_vector = cur_max_vector;
+        } else if (cur_max_vector > max_vector && UseSubwordForMaxVector) {
+          // Analyse subword in the loop to set maximum vector size to take advantage of full vector width for subword types.
+          // Here we analyze if narrowing is likely to happen and if it is we set vector size more aggressively.
+          // We check for possibility of narrowing by looking through chain operations using subword types.   
+          if (is_subword_type(bt)) {
+            uint start, end;
+            VectorNode::vector_operands(n, &start, &end);
+
+            for (uint j = start; j < end; j++) {
+              Node* in = n->in(j);
+              // Don't propagate through a memory
+              if (!in->is_Mem() && in_bb(in) && in->bottom_type()->basic_type() == T_INT) {
+                bool same_type = true;
+                for (DUIterator_Fast kmax, k = in->fast_outs(kmax); k < kmax; k++) {
+                  Node *use = in->fast_out(k);
+                  if (!in_bb(use) && use->bottom_type()->basic_type() != bt) {
+                    same_type = false;
+                    break;
+                  }
+                }
+                if (same_type) {
+                  max_vector = cur_max_vector;
+                  flag_small_bt = true;
+                }
+              }
+            }
+          }
         }
-
         // We only process post loops on predicated targets where we want to
         // mask map the loop to a single iteration
         if (post_loop_allowed) {
           _post_block.at_put_grow(rpo_idx++, n);
         }
< prev index next >