--- a/hotspot/src/share/vm/opto/lcm.cpp Mon Mar 04 13:15:01 2013 -0800
+++ b/hotspot/src/share/vm/opto/lcm.cpp Tue Mar 05 04:24:50 2013 -0800
@@ -421,6 +421,7 @@
uint latency = 0; // Bigger is scheduled first
uint score = 0; // Bigger is better
int idx = -1; // Index in worklist
+ int cand_cnt = 0; // Candidate count
for( uint i=0; i<cnt; i++ ) { // Inspect entire worklist
// Order in worklist is used to break ties.
@@ -503,11 +504,14 @@
uint n_score = n->req(); // Many inputs get high score to break ties
// Keep best latency found
- if( choice < n_choice ||
- ( choice == n_choice &&
- ( latency < n_latency ||
- ( latency == n_latency &&
- ( score < n_score ))))) {
+ cand_cnt++;
+ if (choice < n_choice ||
+ (choice == n_choice &&
+ ((StressLCM && Compile::randomized_select(cand_cnt)) ||
+ (!StressLCM &&
+ (latency < n_latency ||
+ (latency == n_latency &&
+ (score < n_score))))))) {
choice = n_choice;
latency = n_latency;
score = n_score;