tournament.cc (8843:7d3ac6813147) | tournament.cc (9327:07a22ace275d) |
---|---|
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 --- 153 unchanged lines hidden (view full) --- 162void 163TournamentBP::BTBUpdate(Addr &branch_addr, void * &bp_history) 164{ 165 unsigned local_history_idx = calcLocHistIdx(branch_addr); 166 //Update Global History to Not Taken 167 globalHistory = globalHistory & (globalHistoryMask - 1); 168 //Update Local History to Not Taken 169 localHistoryTable[local_history_idx] = | 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 --- 153 unchanged lines hidden (view full) --- 162void 163TournamentBP::BTBUpdate(Addr &branch_addr, void * &bp_history) 164{ 165 unsigned local_history_idx = calcLocHistIdx(branch_addr); 166 //Update Global History to Not Taken 167 globalHistory = globalHistory & (globalHistoryMask - 1); 168 //Update Local History to Not Taken 169 localHistoryTable[local_history_idx] = |
170 localHistoryTable[local_history_idx] & (localPredictorMask - 1); | 170 localHistoryTable[local_history_idx] & (localPredictorMask & ~ULL(1)); |
171} 172 173bool 174TournamentBP::lookup(Addr &branch_addr, void * &bp_history) 175{ 176 bool local_prediction; 177 unsigned local_history_idx; 178 unsigned local_predictor_idx; --- 79 unchanged lines hidden (view full) --- 258 local_predictor_hist = localHistoryTable[local_history_idx]; 259 local_predictor_idx = local_predictor_hist & localPredictorMask; 260 261 if (bp_history) { 262 BPHistory *history = static_cast<BPHistory *>(bp_history); 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; | 171} 172 173bool 174TournamentBP::lookup(Addr &branch_addr, void * &bp_history) 175{ 176 bool local_prediction; 177 unsigned local_history_idx; 178 unsigned local_predictor_idx; --- 79 unchanged lines hidden (view full) --- 258 local_predictor_hist = localHistoryTable[local_history_idx]; 259 local_predictor_idx = local_predictor_hist & localPredictorMask; 260 261 if (bp_history) { 262 BPHistory *history = static_cast<BPHistory *>(bp_history); 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; |
266 unsigned old_local_pred_index = history->localHistory 267 & localPredictorMask; | 266 unsigned old_local_pred_index = history->localHistory & 267 localPredictorMask; 268 269 bool old_local_pred_valid = history->localHistory != 270 invalidPredictorIndex; 271 272 assert(old_local_pred_index < localPredictorSize); 273 |
268 if (history->globalUsed) { 269 historyPred = history->globalPredTaken; 270 } else { 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. --- 10 unchanged lines hidden (view full) --- 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(); | 274 if (history->globalUsed) { 275 historyPred = history->globalPredTaken; 276 } else { 277 historyPred = history->localPredTaken; 278 } 279 if (historyPred != taken || !squashed) { 280 // Update the choice predictor to tell it which one was correct if 281 // there was a prediction. --- 10 unchanged lines hidden (view full) --- 292 } 293 294 // Update the counters and local history with the proper 295 // resolution of the branch. Global history is updated 296 // speculatively and restored upon squash() calls, so it does not 297 // need to be updated. 298 if (taken) { 299 globalCtrs[history->globalHistory].increment(); |
294 if (old_local_pred_index != invalidPredictorIndex) { | 300 if (old_local_pred_valid) { |
295 localCtrs[old_local_pred_index].increment(); 296 } 297 } else { 298 globalCtrs[history->globalHistory].decrement(); | 301 localCtrs[old_local_pred_index].increment(); 302 } 303 } else { 304 globalCtrs[history->globalHistory].decrement(); |
299 if (old_local_pred_index != invalidPredictorIndex) { | 305 if (old_local_pred_valid) { |
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; | 306 localCtrs[old_local_pred_index].decrement(); 307 } 308 } 309 } 310 if (squashed) { 311 if (taken) { 312 globalHistory = (history->globalHistory << 1) | 1; 313 globalHistory = globalHistory & globalHistoryMask; |
308 if (old_local_pred_index != invalidPredictorIndex) { 309 localHistoryTable[old_local_pred_index] = | 314 if (old_local_pred_valid) { 315 localHistoryTable[local_history_idx] = |
310 (history->localHistory << 1) | 1; 311 } 312 } else { 313 globalHistory = (history->globalHistory << 1); 314 globalHistory = globalHistory & globalHistoryMask; | 316 (history->localHistory << 1) | 1; 317 } 318 } else { 319 globalHistory = (history->globalHistory << 1); 320 globalHistory = globalHistory & globalHistoryMask; |
315 if (old_local_pred_index != invalidPredictorIndex) { 316 localHistoryTable[old_local_pred_index] = | 321 if (old_local_pred_valid) { 322 localHistoryTable[local_history_idx] = |
317 history->localHistory << 1; 318 } 319 } 320 321 } 322 // We're done with this history, now delete it. 323 delete history; 324 --- 25 unchanged lines hidden --- | 323 history->localHistory << 1; 324 } 325 } 326 327 } 328 // We're done with this history, now delete it. 329 delete history; 330 --- 25 unchanged lines hidden --- |