On Mar 26, 2011, at 4:48 PM, Korey Sewell wrote:

> I'm bumping the below e-mail from the users lists to dev. I believe it
> is a legit problem with decode not actually passing back the correct
> value for taken/not taken to the branch predictor when it detects a
> pc-relative, unconditional control branch in decode.
> 
> The relevant line in decode_impl.hh is this:
> toFetch->decodeInfo[tid].branchTaken = inst->pcState().branching();

Since it's just resolving unconditional branches (and actually just when there 
is a mis-predict), doesn't that mean branchTaken should = true?


> 
> However, the branch isnt technically "resolved" at that point so you
> wont get the right "resolution" back to BpHistory.
> 
> I'm thinking the fix might be to:
> 1. Call execute on the branch in decode so that the PC/NPC/NNPC values
> can be updated.
> 2. Call squash in decode
> 3. Bypass execution of the unconditonal, pc-relative branch in IEW...
> (this may be trickier than it sounds, but I'm not fond of the idea of
> just executing the branch 2x)
> 
> Any thoughts?


The actual instruction isn't sent back, it's just the PC and take/not-taken so 
I don't think other things need to change. In the case of a successful branch, 
the bp is updated when that branch commits (in commit).

Ali


> 
> 
> ---------- Forwarded message ----------
> From: reena panda <reena.pa...@gmail.com>
> Date: Sat, Mar 26, 2011 at 4:17 PM
> Subject: [m5-users] Help with Branch Misprediction recovery in m5.
> To: M5 users mailing list <m5-us...@m5sim.org>
> 
> 
> Hi,
> 
> I am using m5 in ALPHA FS mode, with O3 CPU model. I was going through
> the fetch/decode stage implementation in m5. But I can't understand
> properly, the way branch misprediction is handled in the decode/fetch
> stage of pipeline. Please correct me if I am wrong, but the way it is
> currently implemented in m5 is as follows:-
> 
> Suppose an unconditional branch(PC = x, say) is fetched in the fetch
> cycle, its branch prediction history is immediately updated as a
> "taken branch". Now lets say, its actual target is "Y". But suppose
> the entry corresponding to the branch PC (x) is not found in the BTB,
> then the next PC and nextNPC are still updated to x+4, x+8
> respectively. Since unconditional branches can be resolved in the
> decode stage, the following check is correctly performed in
> decodeInsts function (in decode_impl.hh):-
> 
>     if (inst->branchTarget() != inst->readPredPC()) {
>                 ++decodeBranchMispred;
>                 squash(inst, inst->threadNumber);
>     }
> 
> But what is odd is that in squash function, the following information
> is sent back to fetch stage:-
> 
>     toFetch->decodeInfo[tid].nextPC      = inst->branchTarget();
>     toFetch->decodeInfo[tid].nextNPC     = inst->branchTarget() +
> sizeof(TheISA::MachInst);
>     toFetch->decodeInfo[tid].branchTaken     = inst->readNextPC() !=
> (inst->readPC() + sizeof(TheISA::MachInst));
> 
> The third statement is odd because it compares nextPC with PC( i.e,
> x+4 with x+4) yields branch direction as "not-taken", Which is wrong
> and would update the branch predictors incorrectly. Branch is actually
> an "unconditional taken branch" in the example. Then, should not the
> last line be something like this:-
>     toFetch->decodeInfo[tid].branchTaken     =  inst->branchTarget()
> != (inst->readPC() + sizeof(TheISA::MachInst));
> 
> Please point if I am missing something here? I can't understand the
> working correctly. Also, can some one give me pointers on how to infer
> total branch misprediction statistics from the stats.txt file, the
> stats seem to be scattered across the different pipeline stages. Are
> they all disjoint/or is there any degree of overlap between them?
> 
> Thanks,
> Reena
> 
> _______________________________________________
> m5-users mailing list
> m5-us...@m5sim.org
> http://m5sim.org/cgi-bin/mailman/listinfo/m5-users
> 
> 
> 
> -- 
> - Korey
> _______________________________________________
> m5-dev mailing list
> m5-dev@m5sim.org
> http://m5sim.org/mailman/listinfo/m5-dev
> 

_______________________________________________
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to