tournament.cc (8842:a02932e2e73d) tournament.cc (8843:7d3ac6813147)
1/*
2 * Copyright (c) 2011 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 244 unchanged lines hidden (view full) ---

253 unsigned local_predictor_idx M5_VAR_USED;
254 unsigned local_predictor_hist;
255
256 // Get the local predictor's current prediction
257 local_history_idx = calcLocHistIdx(branch_addr);
258 local_predictor_hist = localHistoryTable[local_history_idx];
259 local_predictor_idx = local_predictor_hist & localPredictorMask;
260
1/*
2 * Copyright (c) 2011 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 244 unchanged lines hidden (view full) ---

253 unsigned local_predictor_idx M5_VAR_USED;
254 unsigned local_predictor_hist;
255
256 // Get the local predictor's current prediction
257 local_history_idx = calcLocHistIdx(branch_addr);
258 local_predictor_hist = localHistoryTable[local_history_idx];
259 local_predictor_idx = local_predictor_hist & localPredictorMask;
260
261 // Update the choice predictor to tell it which one was correct if
262 // there was a prediction.
263 if (bp_history) {
264 BPHistory *history = static_cast<BPHistory *>(bp_history);
261 if (bp_history) {
262 BPHistory *history = static_cast<BPHistory *>(bp_history);
265 if (history->localPredTaken != history->globalPredTaken) {
266 // If the local prediction matches the actual outcome,
267 // decerement the counter. Otherwise increment the
268 // counter.
269 if (history->localPredTaken == taken) {
270 choiceCtrs[history->globalHistory].decrement();
271 } else if (history->globalPredTaken == taken){
272 choiceCtrs[history->globalHistory].increment();
273 }
274
275 }
276
277 // Update the counters and local history with the proper
278 // resolution of the branch. Global history is updated
279 // speculatively and restored upon squash() calls, so it does not
280 // need to be updated.
263 // Update may also be called if the Branch target is incorrect even if
264 // the prediction is correct. In that case do not update the counters.
265 bool historyPred = false;
281 unsigned old_local_pred_index = history->localHistory
266 unsigned old_local_pred_index = history->localHistory
282 & localPredictorMask;
283 if (taken) {
284 globalCtrs[history->globalHistory].increment();
285 if (old_local_pred_index != invalidPredictorIndex) {
286 localCtrs[old_local_pred_index].increment();
287 }
267 & localPredictorMask;
268 if (history->globalUsed) {
269 historyPred = history->globalPredTaken;
288 } else {
270 } else {
289 globalCtrs[history->globalHistory].decrement();
290 if (old_local_pred_index != invalidPredictorIndex) {
291 localCtrs[old_local_pred_index].decrement();
292 }
293 }
271 historyPred = history->localPredTaken;
272 }
273 if (historyPred != taken || !squashed) {
274 // Update the choice predictor to tell it which one was correct if
275 // there was a prediction.
276 if (history->localPredTaken != history->globalPredTaken) {
277 // If the local prediction matches the actual outcome,
278 // decerement the counter. Otherwise increment the
279 // counter.
280 if (history->localPredTaken == taken) {
281 choiceCtrs[history->globalHistory].decrement();
282 } else if (history->globalPredTaken == taken) {
283 choiceCtrs[history->globalHistory].increment();
284 }
294
285
295 if (squashed) {
296 if (taken) {
297 globalHistory = (history->globalHistory << 1) | 1;
298 globalHistory = globalHistory & globalHistoryMask;
299 if (history->localHistory != invalidPredictorIndex)
300 localHistoryTable[local_history_idx] =
286 }
287
288 // Update the counters and local history with the proper
289 // resolution of the branch. Global history is updated
290 // speculatively and restored upon squash() calls, so it does not
291 // need to be updated.
292 if (taken) {
293 globalCtrs[history->globalHistory].increment();
294 if (old_local_pred_index != invalidPredictorIndex) {
295 localCtrs[old_local_pred_index].increment();
296 }
297 } else {
298 globalCtrs[history->globalHistory].decrement();
299 if (old_local_pred_index != invalidPredictorIndex) {
300 localCtrs[old_local_pred_index].decrement();
301 }
302 }
303 }
304 if (squashed) {
305 if (taken) {
306 globalHistory = (history->globalHistory << 1) | 1;
307 globalHistory = globalHistory & globalHistoryMask;
308 if (old_local_pred_index != invalidPredictorIndex) {
309 localHistoryTable[old_local_pred_index] =
301 (history->localHistory << 1) | 1;
310 (history->localHistory << 1) | 1;
302 } else {
303 globalHistory = (history->globalHistory << 1);
304 globalHistory = globalHistory & globalHistoryMask;
305 if (history->localHistory != invalidPredictorIndex) {
306 localHistoryTable[local_history_idx] =
311 }
312 } else {
313 globalHistory = (history->globalHistory << 1);
314 globalHistory = globalHistory & globalHistoryMask;
315 if (old_local_pred_index != invalidPredictorIndex) {
316 localHistoryTable[old_local_pred_index] =
307 history->localHistory << 1;
317 history->localHistory << 1;
308 }
309 }
318 }
319 }
310
311 }
312 // We're done with this history, now delete it.
313 delete history;
320
321 }
322 // We're done with this history, now delete it.
323 delete history;
324
314 }
315
316 assert(globalHistory < globalPredictorSize &&
317 local_history_idx < localHistoryTableSize &&
318 local_predictor_idx < localPredictorSize);
319
320
321}

--- 17 unchanged lines hidden ---
325 }
326
327 assert(globalHistory < globalPredictorSize &&
328 local_history_idx < localHistoryTableSize &&
329 local_predictor_idx < localPredictorSize);
330
331
332}

--- 17 unchanged lines hidden ---