diff --git a/.jenkins/build_test_run.sh b/.jenkins/build_test_run.sh index 52b3a7bdab..22e48655c9 100644 --- a/.jenkins/build_test_run.sh +++ b/.jenkins/build_test_run.sh @@ -71,7 +71,7 @@ run () { cat run echo "" compare_outputs "$(grep "retired:" run | rev | cut -d ' ' -f1 | rev)" "6724" "retired instructions" - compare_outputs "$(grep "cycles:" run | rev | cut -d ' ' -f1 | rev)" "8677" "simulated cycles" + compare_outputs "$(grep "cycles:" run | rev | cut -d ' ' -f1 | rev)" "8612" "simulated cycles" echo "" } diff --git a/src/include/simeng/Instruction.hh b/src/include/simeng/Instruction.hh index 9a126460de..0fbaa932d5 100644 --- a/src/include/simeng/Instruction.hh +++ b/src/include/simeng/Instruction.hh @@ -157,7 +157,7 @@ class Instruction { // Flag as mispredicted if taken state was wrongly predicted, or taken and // predicted target is wrong return (branchTaken_ != prediction_.taken || - (prediction_.target != branchAddress_)); + (branchTaken_ && (prediction_.target != branchAddress_))); } /** Check whether an exception has been encountered while processing this diff --git a/src/lib/pipeline/FetchUnit.cc b/src/lib/pipeline/FetchUnit.cc index 553c8198f4..7bc59051e9 100644 --- a/src/lib/pipeline/FetchUnit.cc +++ b/src/lib/pipeline/FetchUnit.cc @@ -176,8 +176,17 @@ void FetchUnit::tick() { } } else if (loopBufferState_ == LoopBufferState::WAITING && pc_ == loopBoundaryAddress_) { - // Once set loopBoundaryAddress_ is fetched, start to fill loop buffer - loopBufferState_ = LoopBufferState::FILLING; + // loopBoundaryAddress_ has been fetched whilst loop buffer is waiting, + // start filling Loop Buffer if the branch predictor tells us to + // reenter the detected loop + if (macroOp[0]->isBranch() && !macroOp[0]->getBranchPrediction().taken) { + // If branch is not taken then we aren't re-entering the detected + // loop, therefore Loop Buffer stays idle + loopBufferState_ = LoopBufferState::IDLE; + } else { + // Otherwise, start to fill Loop Buffer + loopBufferState_ = LoopBufferState::FILLING; + } } assert(bytesRead <= bufferedBytes_ &&