-fno严格走样性能的影响 [英] Performance impact of -fno-strict-aliasing

查看:104
本文介绍了-fno严格走样性能的影响的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何研究或设定基准的显示性能
降解由于在指定-fno GCC严格走样(或
相当于其他编译器)?

Is there any study or set of benchmarks showing the performance degradation due to specifying -fno-strict-aliasing in GCC (or equivalent in other compilers)?

推荐答案

这也会相差很多因编译器,因为不同的编译器有不同程度的侵略实施。 GCC是相当积极一下吧:启用严格别名将导致它认为的指针是明明相当于人类(如, foo的* A;酒吧* B; B =(富*)一个; )无法别名,它允许一些非常积极的转变,但可以明显地打破非浓墨重彩code。苹果的GCC默认禁用严格别名这个原因。

It will vary a lot from compiler to compiler, as different compilers implement it with different levels of aggression. GCC is fairly aggressive about it: enabling strict aliasing will cause it to think that pointers that are "obviously" equivalent to a human (as in, foo* a; bar * b; b = (foo*)a;) cannot alias, which allows for some very aggressive transformations, but can obviously break non-carefully written code. Apple's GCC disables strict aliasing by default for this reason.

LLVM,相比之下,甚至没有的有无的严格走样,而且,虽然它是计划,开发商都表示,他们计划实现它作为退一步的情况下,当没有别的可以判断等价。在上面的例子中,它仍然会判断a和b相同。这将只使用基于类型的混叠,如果它不能确定它们以任何其他方式的关系

LLVM, by contrast, does not even have strict aliasing, and, while it is planned, the developers have said that they plan to implement it as a fall-back case when nothing else can judge equivalence. In the above example, it would still judge a and b equivalent. It would only use type-based aliasing if it could not determine their relationship in any other way.

在我的经验,严格别名对性能的影响主要有循环不变code的运动,其中的类型信息可以被用来证明,在循环载荷不能别名数组被遍历的事,让它们被拉出循环。情况因人而异。

In my experience, the performance impact of strict aliasing mostly has to do with loop invariant code motion, where type information can be used to prove that in-loop loads can't alias the array being iterated over, allowing them to be pulled out of the loop. YMMV.

这篇关于-fno严格走样性能的影响的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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