http://semipublic.comp-arch.net/wiki/Stew
The [[stew]] is a form of history used by certain branch predictors.
See, for example, US patent 7143273,
Method and apparatus for dynamic branch prediction utilizing multiple stew algorithms for indexing a global history,
Mile, Slade, and Jourdan,
filed March 31, 2003,
assignee Intel.
A simple [[branch predictor history]] might be a simple [[TNT]] history,
with 0s corresponding to non-taken and 1s corresponding to taken.
Such a simple TNT history cannot distinguish some convergeing paths,
and indirect branches.
US7143273
describes one embodiment of a stew as
stew = ((stew << 1)|new_bit ^ ip)
A stew formed in this way can distinguish converging paths such as ("if true" means a condition that evaluates as true, not an unconditional branch):
L1: if true got L2
L2: if true goto L99
L10: if true goto L11
L11: if true goto L
L: if ?? goto L99
However, it does not distinguish multiple branch targets and paths out of an indirect branch, such as
L1: Reg:= IL1; if true goto L2
L2: if true goto L99
L10: Reg:=IL2; if true goto L11
L11: if true goto L
L: if ?? goto [Reg]
IL1: ...
IL2: ...
It can be seen that mixing in arc information as well as node information remedies this situation,
and distinguishes different paths so long as the hashes do not collide:
stew <<= number_of_bits_to_discard
stew = hash( stew, from_IP, to_IP, taken/not_taken, ...)
Issue: how many bits to use? Which may vary as a function of the type of branch: e.g. a direct conditional branch
may not need as many to_ip bits to be hashed in
as a completely random indirect branch.
Similarly, indirect calls and returns may be handled separately.
(TBD-IP)
No comments:
Post a Comment