< prev index next >

src/share/vm/opto/superword.cpp

Print this page




 282         while (have_side_effects) {
 283           Node* pointer_node = nstack.node();
 284           for (uint j = 0; j < lpt()->_body.size(); j++) {
 285             Node* cur_node = lpt()->_body.at(j);
 286             if (cur_node == pointer_node) {
 287               ignored_loop_nodes[j] = cur_node->_idx;
 288               break;
 289             }
 290           }
 291           nstack.pop();
 292           have_side_effects = nstack.is_nonempty();
 293         }
 294       }
 295     }
 296   }
 297 
 298   if (is_slp) {
 299     // Now we try to find the maximum supported consistent vector which the machine
 300     // description can use
 301     bool small_basic_type = false;

 302     for (uint i = 0; i < lpt()->_body.size(); i++) {
 303       if (ignored_loop_nodes[i] != -1) continue;
 304 
 305       BasicType bt;
 306       Node* n = lpt()->_body.at(i);
 307       if (n->is_Mem()) {
 308         bt = n->as_Mem()->memory_type();
 309       } else {
 310         bt = n->bottom_type()->basic_type();
 311       }
 312 
 313       if (post_loop_allowed) {
 314         if (!small_basic_type) {
 315           switch (bt) {
 316           case T_CHAR:
 317           case T_BYTE:
 318           case T_SHORT:
 319             small_basic_type = true;
 320             break;
 321 


 328           }
 329         }
 330       }
 331 
 332       if (is_java_primitive(bt) == false) continue;
 333 
 334       int cur_max_vector = Matcher::max_vector_size(bt);
 335 
 336       // If a max vector exists which is not larger than _local_loop_unroll_factor
 337       // stop looking, we already have the max vector to map to.
 338       if (cur_max_vector < local_loop_unroll_factor) {
 339         is_slp = false;
 340         if (TraceSuperWordLoopUnrollAnalysis) {
 341           tty->print_cr("slp analysis fails: unroll limit greater than max vector\n");
 342         }
 343         break;
 344       }
 345 
 346       // Map the maximal common vector
 347       if (VectorNode::implemented(n->Opcode(), cur_max_vector, bt)) {
 348         if (cur_max_vector < max_vector) {
 349           max_vector = cur_max_vector;



























 350         }
 351 
 352         // We only process post loops on predicated targets where we want to
 353         // mask map the loop to a single iteration
 354         if (post_loop_allowed) {
 355           _post_block.at_put_grow(rpo_idx++, n);
 356         }
 357       }
 358     }
 359     if (is_slp) {
 360       local_loop_unroll_factor = max_vector;
 361       cl->mark_passed_slp();
 362     }
 363     cl->mark_was_slp();
 364     if (cl->is_main_loop()) {
 365       cl->set_slp_max_unroll(local_loop_unroll_factor);
 366     } else if (post_loop_allowed) {
 367       if (!small_basic_type) {
 368         // avoid replication context for small basic types in programmable masked loops
 369         cl->set_slp_max_unroll(local_loop_unroll_factor);
 370       }
 371     }




 282         while (have_side_effects) {
 283           Node* pointer_node = nstack.node();
 284           for (uint j = 0; j < lpt()->_body.size(); j++) {
 285             Node* cur_node = lpt()->_body.at(j);
 286             if (cur_node == pointer_node) {
 287               ignored_loop_nodes[j] = cur_node->_idx;
 288               break;
 289             }
 290           }
 291           nstack.pop();
 292           have_side_effects = nstack.is_nonempty();
 293         }
 294       }
 295     }
 296   }
 297 
 298   if (is_slp) {
 299     // Now we try to find the maximum supported consistent vector which the machine
 300     // description can use
 301     bool small_basic_type = false;
 302     bool flag_small_bt = false;
 303     for (uint i = 0; i < lpt()->_body.size(); i++) {
 304       if (ignored_loop_nodes[i] != -1) continue;
 305 
 306       BasicType bt;
 307       Node* n = lpt()->_body.at(i);
 308       if (n->is_Mem()) {
 309         bt = n->as_Mem()->memory_type();
 310       } else {
 311         bt = n->bottom_type()->basic_type();
 312       }
 313 
 314       if (post_loop_allowed) {
 315         if (!small_basic_type) {
 316           switch (bt) {
 317           case T_CHAR:
 318           case T_BYTE:
 319           case T_SHORT:
 320             small_basic_type = true;
 321             break;
 322 


 329           }
 330         }
 331       }
 332 
 333       if (is_java_primitive(bt) == false) continue;
 334 
 335          int cur_max_vector = Matcher::max_vector_size(bt);
 336 
 337       // If a max vector exists which is not larger than _local_loop_unroll_factor
 338       // stop looking, we already have the max vector to map to.
 339       if (cur_max_vector < local_loop_unroll_factor) {
 340         is_slp = false;
 341         if (TraceSuperWordLoopUnrollAnalysis) {
 342           tty->print_cr("slp analysis fails: unroll limit greater than max vector\n");
 343         }
 344         break;
 345       }
 346 
 347       // Map the maximal common vector
 348       if (VectorNode::implemented(n->Opcode(), cur_max_vector, bt)) {
 349         if (cur_max_vector < max_vector && !flag_small_bt) {
 350           max_vector = cur_max_vector;
 351         } else if (cur_max_vector > max_vector && UseSubwordForMaxVector) {
 352           // Analyse subword in the loop to set maximum vector size to take advantage of full vector width for subword types.
 353           // Here we analyze if narrowing is likely to happen and if it is we set vector size more aggressively.
 354           // We check for possibility of narrowing by looking through chain operations using subword types.   
 355           if (is_subword_type(bt)) {
 356             uint start, end;
 357             VectorNode::vector_operands(n, &start, &end);
 358 
 359             for (uint j = start; j < end; j++) {
 360               Node* in = n->in(j);
 361               // Don't propagate through a memory
 362               if (!in->is_Mem() && in_bb(in) && in->bottom_type()->basic_type() == T_INT) {
 363                 bool same_type = true;
 364                 for (DUIterator_Fast kmax, k = in->fast_outs(kmax); k < kmax; k++) {
 365                   Node *use = in->fast_out(k);
 366                   if (!in_bb(use) && use->bottom_type()->basic_type() != bt) {
 367                     same_type = false;
 368                     break;
 369                   }
 370                 }
 371                 if (same_type) {
 372                   max_vector = cur_max_vector;
 373                   flag_small_bt = true;
 374                 }
 375               }
 376             }
 377           }
 378         }

 379         // We only process post loops on predicated targets where we want to
 380         // mask map the loop to a single iteration
 381         if (post_loop_allowed) {
 382           _post_block.at_put_grow(rpo_idx++, n);
 383         }
 384       }
 385     }
 386     if (is_slp) {
 387       local_loop_unroll_factor = max_vector;
 388       cl->mark_passed_slp();
 389     }
 390     cl->mark_was_slp();
 391     if (cl->is_main_loop()) {
 392       cl->set_slp_max_unroll(local_loop_unroll_factor);
 393     } else if (post_loop_allowed) {
 394       if (!small_basic_type) {
 395         // avoid replication context for small basic types in programmable masked loops
 396         cl->set_slp_max_unroll(local_loop_unroll_factor);
 397       }
 398     }


< prev index next >