Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top