好吧,所以我知道,如果特定的条件分支有一个需要时间来计算的条件(例如内存访问),CPU 会假定一个条件结果并沿着该路径推测执行。但是,如果沿着该路径弹出另一个缓慢的条件分支(当然,假设第一个条件尚未解决并且 CPU 无法提交更改),会发生什么情况?难道CPU只是在猜测里面猜测吗?如果最后一个条件预测错误但第一个条件没有预测会发生什么?难道只是一路回滚吗?
我正在谈论这样的事情:
if (value_in_memory == y){
// computations
if (another_val_memory == x){
//computations
}
}
Run Code Online (Sandbox Code Playgroud) cpu-architecture nested-if speculative-execution branch-prediction