diff -r 6c4d8b9cef21 -r 950de34f1bbd src/cpu/pred/tournament.cc --- a/src/cpu/pred/tournament.cc Wed Oct 24 17:21:37 2012 -0400 +++ b/src/cpu/pred/tournament.cc Wed Oct 24 17:21:51 2012 -0400 @@ -167,7 +167,7 @@ globalHistory = globalHistory & (globalHistoryMask - 1); //Update Local History to Not Taken localHistoryTable[local_history_idx] = - localHistoryTable[local_history_idx] & (localPredictorMask - 1); + localHistoryTable[local_history_idx] & (localPredictorMask & ~ULL(1)); } bool @@ -263,8 +263,14 @@ // Update may also be called if the Branch target is incorrect even if // the prediction is correct. In that case do not update the counters. bool historyPred = false; - unsigned old_local_pred_index = history->localHistory - & localPredictorMask; + unsigned old_local_pred_index = history->localHistory & + localPredictorMask; + + bool old_local_pred_valid = history->localHistory != + invalidPredictorIndex; + + assert(old_local_pred_index < localPredictorSize); + if (history->globalUsed) { historyPred = history->globalPredTaken; } else { @@ -291,12 +297,12 @@ // need to be updated. if (taken) { globalCtrs[history->globalHistory].increment(); - if (old_local_pred_index != invalidPredictorIndex) { + if (old_local_pred_valid) { localCtrs[old_local_pred_index].increment(); } } else { globalCtrs[history->globalHistory].decrement(); - if (old_local_pred_index != invalidPredictorIndex) { + if (old_local_pred_valid) { localCtrs[old_local_pred_index].decrement(); } } @@ -305,15 +311,15 @@ if (taken) { globalHistory = (history->globalHistory << 1) | 1; globalHistory = globalHistory & globalHistoryMask; - if (old_local_pred_index != invalidPredictorIndex) { - localHistoryTable[old_local_pred_index] = + if (old_local_pred_valid) { + localHistoryTable[local_history_idx] = (history->localHistory << 1) | 1; } } else { globalHistory = (history->globalHistory << 1); globalHistory = globalHistory & globalHistoryMask; - if (old_local_pred_index != invalidPredictorIndex) { - localHistoryTable[old_local_pred_index] = + if (old_local_pred_valid) { + localHistoryTable[local_history_idx] = history->localHistory << 1; } }