preserving执行管线 [英] Preserving the Execution pipeline

查看:133
本文介绍了preserving执行管线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

返回类型经常检查是否存在错误。但是,在code,将继续执行可以以不同的方式来指定。

 如果(!RET)
{
   doNoError code();
}
出口(1);

 如果(RET)
{
   出口(1);
}
doNoError code();

单向重量级的CPU可以推测使用简单的统计靠近接近/地区所采取的分支 - 我研究了分支预测的4位机制(-2,-1,0,+ 1,+ 2)其中零为未知和2将被认为是一个真正的分支。

考虑到上述简单的技术,我的问题是关于如何构造code。我认为必须有重大的编译器和重大架构之间的约定。这是我的两个问题。


  1. 当code不是它的布尔值偏向当管道被填充为经常访问的循环?

  2. 猜测分支必须在真或假或零(管道必须填写的东西)开头。这是它可能是?


解决方案

行为的CPU的不同而不同,编译器经常重新排序的说明。
你会发现你在这些手册需要的所有信息。 http://agner.org/optimize/

在我看来就知道发生什么事的唯一途径是阅读由编译器生成的汇编code。

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

  1. When the code isn't an often-visited loop which boolean value is biased for when the pipeline is being filled ?
  2. 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 ?

解决方案

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.

这篇关于preserving执行管线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆