GCC C++ 吗?编译器考虑 __restrict - 语句吗?
我已经研究了在通过 GCC 编译器编译 C++ 代码时 __restricting 某些指针的影响。
事实证明,不仅运行时保持完全相同,而且可执行文件似乎也没有改变,字节大小与以前完全相同。
我的 GCC 版本是
gcc version 4.3.2 [gcc-4_3-branch revision 141291] (SUSE Linux)
,虽然它在解析时接受这个 C++ 扩展,但在汇编代码时似乎没有考虑它。因此,要么是编译器不知道如何使用此语义信息,要么是完全禁用了处理此信息。
该代码执行大量数字运算,希望将其启用以用于测试目的。你能帮忙吗?
I've have investigating the effect of __restricting certain pointers in a C++-code, when compiling it via the GCC-compiler.
It turned that not only the run-time remains quite the same, but the executable doesn't seem to have changed, the size in bytes is exactly the same as before.
My GCC-version is
gcc version 4.3.2 [gcc-4_3-branch revision 141291] (SUSE Linux)
and although it accepts this C++-extension when parsing, it does not seem to regard it when assembling the code. So there is either a reason, the compiler doesn't know how to use this semantic information, or processing this information is completly disabled.
The code performs a lot of number crunching, it would like to have it enabled for testing purposes. Can you help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
restrict
限定符基本上是用户帮助编译器执行某些与别名相关的优化的一种方法。仅当这些优化机会已经存在于代码中时它们才会产生影响,因此使用restrict
只是在编译器之前必须使用“更安全”(非优化)代码生成的情况下启用它们。在其他情况下,restrict
根本没有任何效果。因此,您在代码中添加了一些
restrict
限定符。但是它们中的任何一个是否在它们真正重要的上下文中使用,即它们实际上给了编译器更多的自由来优化代码?如果没有,您就不应期望代码发生更改。restrict
qualifiers are basically a way for the user to help the compiler to perform certain aliasing-related optimizations. They will only have an effect if these optimization opportunities are already present in the code, so usingrestrict
simply enables them in situations when the compiler previously had to use a "safer" (non-optimizing) code generation. In other contextsrestrict
will have no effect at all.So, you added some
restrict
qualifiers to your code. But was any of them used in the context where they actually matter, i.e. where they actually give the compiler more freedom to optimize the code? If not, you are not supposed to expect your code to change.