summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPau Cabre <pau.cabre@metempsy.com>2018-11-07 23:32:55 +0100
committerPau Cabre <pau.cabre@metempsy.com>2018-11-13 22:37:56 +0000
commitf3016e6846980038a50a66055cd2619df6926207 (patch)
treed6f9f03fd75ebea867350e1a61b05366e159c53a
parent2f52a9b65ee37ba8f34ac3d46f96dca9afc02c7c (diff)
downloadgem5-f3016e6846980038a50a66055cd2619df6926207.tar.xz
cpu: Fixed PC shifting on LTAGE branch predictor
The PC needs to be shifted according to the instShiftAmt parameter Change-Id: I272619c093695b56cf7f8ff7163e3b5d23205d16 Signed-off-by: Pau Cabre <pau.cabre@metempsy.com> Reviewed-on: https://gem5-review.googlesource.com/c/14035 Reviewed-by: Sudhanshu Jha <sudhanshu.jha@arm.com> Reviewed-by: Ilias Vougioukas <ilias.vougioukas@arm.com> Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
-rw-r--r--src/cpu/pred/ltage.cc17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/cpu/pred/ltage.cc b/src/cpu/pred/ltage.cc
index 251fb2e7f..86b9e9993 100644
--- a/src/cpu/pred/ltage.cc
+++ b/src/cpu/pred/ltage.cc
@@ -138,13 +138,14 @@ LTAGE::LTAGE(const LTAGEParams *params)
int
LTAGE::bindex(Addr pc_in) const
{
- return ((pc_in) & ((ULL(1) << (logSizeBiMP)) - 1));
+ return ((pc_in >> instShiftAmt) & ((ULL(1) << (logSizeBiMP)) - 1));
}
int
LTAGE::lindex(Addr pc_in) const
{
- return (((pc_in) & ((ULL(1) << (logSizeLoopPred - 2)) - 1)) << 2);
+ return (((pc_in >> instShiftAmt) &
+ ((ULL(1) << (logSizeLoopPred - 2)) - 1)) << 2);
}
int
@@ -171,7 +172,8 @@ LTAGE::gindex(ThreadID tid, Addr pc, int bank) const
int index;
int hlen = (histLengths[bank] > 16) ? 16 : histLengths[bank];
index =
- (pc) ^ ((pc) >> ((int) abs(tagTableSizes[bank] - bank) + 1)) ^
+ (pc >> instShiftAmt) ^
+ ((pc >> instShiftAmt) >> ((int) abs(tagTableSizes[bank] - bank) + 1)) ^
threadHistory[tid].computeIndices[bank].comp ^
F(threadHistory[tid].pathHist, hlen, bank);
@@ -183,8 +185,9 @@ LTAGE::gindex(ThreadID tid, Addr pc, int bank) const
uint16_t
LTAGE::gtag(ThreadID tid, Addr pc, int bank) const
{
- int tag = (pc) ^ threadHistory[tid].computeTags[0][bank].comp
- ^ (threadHistory[tid].computeTags[1][bank].comp << 1);
+ int tag = (pc >> instShiftAmt) ^
+ threadHistory[tid].computeTags[0][bank].comp ^
+ (threadHistory[tid].computeTags[1][bank].comp << 1);
return (tag & ((ULL(1) << tagWidths[bank]) - 1));
}
@@ -239,7 +242,7 @@ LTAGE::getLoop(Addr pc, BranchInfo* bi) const
bi->loopHit = -1;
bi->loopPredValid = false;
bi->loopIndex = lindex(pc);
- bi->loopTag = ((pc) >> (logSizeLoopPred - 2));
+ bi->loopTag = ((pc) >> (instShiftAmt + logSizeLoopPred - 2));
for (int i = 0; i < 4; i++) {
if (ltable[bi->loopIndex + i].tag == bi->loopTag) {
@@ -630,7 +633,7 @@ LTAGE::updateHistories(ThreadID tid, Addr branch_pc, bool taken, void* b)
BranchInfo* bi = (BranchInfo*)(b);
ThreadHistory& tHist = threadHistory[tid];
// UPDATE HISTORIES
- bool pathbit = ((branch_pc) & 1);
+ bool pathbit = ((branch_pc >> instShiftAmt) & 1);
//on a squash, return pointers to this and recompute indices.
//update user history
updateGHist(tHist.gHist, taken, tHist.globalHistory, tHist.ptGhist);