[libre-riscv-dev] [Bug 206] Implement branch prediction

bugzilla-daemon at libre-riscv.org bugzilla-daemon at libre-riscv.org
Mon Mar 2 22:01:41 GMT 2020


http://bugs.libre-riscv.org/show_bug.cgi?id=206

--- Comment #3 from Jacob Lifshay <programmerjake at gmail.com> ---
(In reply to Luke Kenneth Casson Leighton from comment #2)
> (In reply to Jacob Lifshay from comment #0)
> 
> > To avoid spectre-style data leaks where feasible, we should only send
> > taken/not-taken data back to the branch predictor once all preceding
> > branches are no longer speculative (tracked by dependency matrix).
> 
> that's going to be interesting.  all *preceding* branches.  do they
> mean branches that are in play whilst *other* branches are still in play?
> double-shadowing, in other words?

I meant where there could be a branch or trap before the current branch. Once
the current branch is known to be executed, only then can it send
taken/not-taken info back to the branch predictor. Before then, the branch
predictor has to assume that the branch was predicted correctly.

Basically, it all boils down to the branch predictor can't get information from
data that was calculated speculatively by the out-of-order engine until it's
not speculative anymore.

Alternatively, as is done in BOOM, the branch predictor must revert all visible
state to what it was before the first mispredicted branch or trap.

Note that that is different from getting info from instruction fetch (such as:
is an instruction a branch or something else), since those are assumed to not
change without an icache flush.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the libre-riscv-dev mailing list