开发者

Does GCC C++ compiler take into account __restrict - statements?

开发者 https://www.devze.com 2023-01-12 12:19 出处:网络
I\'ve have investigating the effect of __restricting certain pointers in a C++-code, when compiling it via the GCC-compiler.

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, 开发者_Python百科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?


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 using restrict simply enables them in situations when the compiler previously had to use a "safer" (non-optimizing) code generation. In other contexts restrict 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消