inorder: branch predictor update
authorKorey Sewell <ksewell@umich.edu>
Mon, 20 Jun 2011 01:43:37 +0000 (21:43 -0400)
committerKorey Sewell <ksewell@umich.edu>
Mon, 20 Jun 2011 01:43:37 +0000 (21:43 -0400)
only update BTB on a taken branch and update branch predictor w/pcstate from instruction
---
only pay attention to branch predictor updates if the the inst. is in fact a branch

src/cpu/inorder/cpu.cc
src/cpu/inorder/pipeline_stage.cc
src/cpu/inorder/resources/bpred_unit.cc
src/cpu/inorder/resources/branch_predictor.cc
src/cpu/inorder/resources/fetch_seq_unit.cc

index 03c44ea86aa5fbf6940304e6b96144ffbe9b3a8c..75e9e06d93d4749b5297e96bb0169f248b2fb181 100644 (file)
@@ -506,6 +506,9 @@ InOrderCPU::createBackEndSked(DynInstPtr inst)
         W.needs(RegManager, UseDefUnit::WriteDestReg, idx);
     }
 
+    if (inst->isControl())
+        W.needs(BPred, BranchPredictor::UpdatePredictor);
+
     // Insert Back Schedule into our cache of
     // resource schedules
     addToSkedCache(inst, res_sked);
index e739fd2e66c39055a23b47b132c18c41780bc59b..2637207003117c9e1ec610fb306ee0a077af307c 100644 (file)
@@ -420,7 +420,7 @@ PipelineStage::squash(InstSeqNum squash_seq_num, ThreadID tid)
     while (cur_it != end_it) {
         if ((*cur_it)->seqNum <= squash_seq_num) {
             DPRINTF(InOrderStage, "[tid:%i]: Cannot remove skidBuffer "
-                    "instructions (starting w/[sn:%i]) before delay slot "
+                    "instructions (starting w/[sn:%i]) before "
                     "[sn:%i]. %i insts left.\n", tid, 
                     (*cur_it)->seqNum, squash_seq_num,
                     skidBuffer[tid].size());
index 25b8b165a6477c592aabe4c3e46e86d4eeb0b1a7..778366532f9359d89ca9e6750ece159b313bf155 100644 (file)
@@ -250,7 +250,7 @@ BPredUnit::predict(DynInstPtr &inst, TheISA::PCState &predPC, ThreadID tid)
                         tid, asid, inst->pcState(), target);
             } else {
                 DPRINTF(InOrderBPred, "[tid:%i]: BTB doesn't have a "
-                        "valid entry.\n",tid);
+                        "valid entry, predicting false.\n",tid);
                 pred_taken = false;
             }
         }
@@ -369,7 +369,9 @@ BPredUnit::squash(const InstSeqNum &squashed_sn,
         BPUpdate((*hist_it).pc.instAddr(), actually_taken,
                  pred_hist.front().bpHistory);
 
-        BTB.update((*hist_it).pc.instAddr(), corrTarget, asid);
+        // only update BTB on branch taken right???
+        if (actually_taken)
+            BTB.update((*hist_it).pc.instAddr(), corrTarget, asid);
 
         DPRINTF(InOrderBPred, "[tid:%i]: Removing history for [sn:%i] "
                 "PC %s.\n", tid, (*hist_it).seqNum, (*hist_it).pc);
index 3132770d43caa1db00b9ba6d1a0e8653b15a958f..3dea92cfbc1ea37cc44fa1fb31c73b282a277404 100644 (file)
@@ -152,10 +152,14 @@ BranchPredictor::squash(DynInstPtr inst, int squash_stage,
     DPRINTF(InOrderBPred, "[tid:%i][sn:%i] Squashing...\n", tid,
             bpred_squash_num);
 
+    // update due to branch resolution
     if (squash_stage >= ThePipeline::BackEndStartStage) {
-        bool taken = inst->predTaken();
-        branchPred.squash(bpred_squash_num, inst->readPredTarg(), taken, tid);
+        branchPred.squash(bpred_squash_num,
+                          inst->pcState(),
+                          inst->pcState().branching(),
+                          tid);
     } else {
+    // update due to predicted taken branch
         branchPred.squash(bpred_squash_num, tid);
     }
 }
index 072ecb76f6c12d8604ca76d4a1231c97846f218e..8a55822a60b3989dad6697ca24e7274fdae2e1da 100644 (file)
@@ -79,13 +79,13 @@ FetchSeqUnit::execute(int slot_num)
     ThreadID tid = inst->readTid();
     int stage_num = fs_req->getStageNum();
 
-    DPRINTF(InOrderFetchSeq, "[tid:%i]: Current PC is %s\n", tid,
-            pc[tid]);
-
     switch (fs_req->cmd)
     {
       case AssignNextPC:
         {
+            DPRINTF(InOrderFetchSeq, "[tid:%i]: Current PC is %s\n", tid,
+                    pc[tid]);
+
             if (pcValid[tid]) {
                 inst->pcState(pc[tid]);
                 inst->setMemAddr(pc[tid].instAddr());