11 ms·
> Does the processor predict that the string copy loop will never terminate, and keep buffering string copy instructions until the buffers are full? Pretty muc
by kevinnk 11y ago
> Does the processor predict that the string copy loop will never terminate, and keep buffering string copy instructions until the buffers are full?
Pretty much. "Textbook" branch prediction isn't really dependent on the actual data, but on the global and local branch history. If it sees a loop is taken 9/10 times and there's no particular pattern, guessing "taken" is a pretty good idea.
> Which buffers?
If you're assuming the strings are not cached, probably the load-store unit (LSU), which keeps track of outstanding loads and stores.
> Does it stop speculating at some maximum number of branches?
Not that I'm aware of. With out-of-order execution you'd use something like Tomasulo's algorithm, which won't stop speculating until the reorder buffer (ROB) is full. In this case, the ROB is usually much larger than the LSU, so I'd think that would be the limiting factor.