保留执行管道 [英] Preserving the Execution pipeline
问题描述
常常检查返回类型的错误。但是,将继续执行的代码可以以不同的方式指定。
if(!ret)
{
doNoErrorCode();
}
exit(1);
或
if(ret)
{
exit(1);
}
doNoErrorCode();
单向重量级CPU可以使用简单的统计数据推测近邻/用于分支推测(-2,-1,0,+ 1,+ 2)的4位机制,其中零是未知的,2将被认为是真正的分支。
考虑到上面的简单技术,我的问题是关于如何构造代码。我假设在主要编译器和主要架构之间必须有一个约定。这是我的两个问题
- 当代码不是经常访问的循环时,布尔值在管道填充时?
- 关于分支的猜测必须以true或false或零开头(管道必须填充某些东西)。
- When the code isn't an often-visited loop which boolean value is biased for when the pipeline is being filled ?
- Speculation about branching must begin at either true or false or zero ( the pipeline must be filled with something). Which is it likely to be ?
这种行为在不同的CPU之间是不同的,编译器经常重新排序指令。
您可以在这些手册中找到所需的所有信息: http://agner.org/optimize/ 。
在我看来,发现的唯一方法是读取编译器生成的汇编代码。
Return types are frequently checked for errors. But, the code that will continue to execute may be specified in different ways.
if(!ret)
{
doNoErrorCode();
}
exit(1);
or
if(ret)
{
exit(1);
}
doNoErrorCode();
One way heavyweight CPU's can speculate about the branches taken in near proximity/locality using simple statistics - I studied a 4-bit mechanism for branch speculation (-2,-1,0,+1,+2) where zero is unknown and 2 will be considered a true branch.
Considering the simple technique above, my questions are about how to structure code. I assume that there must be a convention among major compilers and major architectures. These are my two questions
The behavior varies among CPUs, and the compiler often reorders instructions. You will find all the information you need in these manuals: http://agner.org/optimize/.
In my opinion the only way to know what happens is to read the assembly code generated by the compiler.
这篇关于保留执行管道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!