From 497cc2d373d1559aaae0263635b88f670fd239cd Mon Sep 17 00:00:00 2001 From: Arthur Perais Date: Wed, 21 Dec 2016 15:07:16 -0600 Subject: cpu: disallow speculative update of branch predictor tables (o3) The Minor and o3 cpu models share the branch prediction code. Minor relies on the BPredUnit::squash() function to update the branch predictor tables on a branch mispre- diction. This is fine because Minor executes in-order, so the update is on the correct path. However, this causes the branch predictor to be updated on out-of-order branch mispredictions when using the o3 model, which should not be the case. This patch guards against speculative update of the branch prediction tables. On a branch misprediction, BPredUnit::squash() calls BpredUnit::update(..., squashed = true). The underlying branch predictor tests against the value of squashed. If it is true, it restores any speculatively updated internal state it might have (e.g., global/local branch history), then returns. If false, it updates its prediction tables. Previously, exist- ing predictors did not test against the "squashed" parameter. To accomodate for this change, the Minor model must now call BPredUnit::squash() then BPredUnit::update(..., squashed = false) on branch mispredictions. Before, calling BpredUnit::squash() performed the prediction tables update. The effect is a slight MPKI improvement when using the o3 model. A further patch should perform the same modifications for the indirect target predictor and BTB (less critical). Signed-off-by: Jason Lowe-Power --- src/cpu/pred/bpred_unit.hh | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'src/cpu/pred/bpred_unit.hh') diff --git a/src/cpu/pred/bpred_unit.hh b/src/cpu/pred/bpred_unit.hh index 3f9cbc057..b890dc332 100644 --- a/src/cpu/pred/bpred_unit.hh +++ b/src/cpu/pred/bpred_unit.hh @@ -179,14 +179,6 @@ class BPredUnit : public SimObject */ virtual void update(ThreadID tid, Addr instPC, bool taken, void *bp_history, bool squashed) = 0; - /** - * Deletes the associated history with a branch, performs no predictor - * updates. Used for branches that mispredict and update tables but - * are still speculative and later retire. - * @param bp_history History to delete associated with this predictor - */ - virtual void retireSquashed(ThreadID tid, void *bp_history) = 0; - /** * Updates the BTB with the target of a branch. * @param inst_PC The branch's PC that will be updated. @@ -211,7 +203,7 @@ class BPredUnit : public SimObject ThreadID _tid) : seqNum(seq_num), pc(instPC), bpHistory(bp_history), RASTarget(0), RASIndex(0), tid(_tid), predTaken(pred_taken), usedRAS(0), pushedRAS(0), - wasCall(0), wasReturn(0), wasSquashed(0), wasIndirect(0) + wasCall(0), wasReturn(0), wasIndirect(0) {} bool operator==(const PredictorHistory &entry) const { @@ -254,9 +246,6 @@ class BPredUnit : public SimObject /** Whether or not the instruction was a return. */ bool wasReturn; - /** Whether this instruction has already mispredicted/updated bp */ - bool wasSquashed; - /** Wether this instruction was an indirect branch */ bool wasIndirect; }; -- cgit v1.2.3