0

If CPU is already in the path of a branch A speculatively, will it continue to speculatively execute the next branch B? or wait until branch A retire?

if (A) {
   /* body of branch A */
   if(B) {
       /* body of branch B */
   }
} else {
    ...
}
Changbin Du
  • 501
  • 5
  • 11
  • I highly doubt that there's a single answer to this that applies to *all* CPUs. Different CPUs have different levels of sophistication around speculative execution. Do you have a *specific* CPU line you want to narrow this to? – Damien_The_Unbeliever Mar 30 '23 at 08:00
  • x86 or arm for example. Is it general on modern CPUs? – Changbin Du Mar 30 '23 at 13:16
  • All instructions are treated as speculative by out-of-order CPUs, since any load or store could fault. Although for branches with fast-recovery, the limiting factor may be the size of the branch-order buffer, if that fills up before the ROB. e.g. 48 entries on Skylake: [What exactly happens when a skylake CPU mispredicts a branch?](https://stackoverflow.com/q/50984007) – Peter Cordes Mar 30 '23 at 16:52

0 Answers0