What are the exact rules for handling pointer antialiasing in C ++?

There is a keyword in C restrictthat tells the compiler that there is no smoothing between the arguments of the function pointer, thus allowing it to perform some optimizations that would otherwise not be allowed. For instance:

void add(int* restrict ptrA,
         int* restrict ptrB,
         int* restrict val)
{
    *ptrA += *val;
    *ptrB += *val;
}

Now the instructions in the body of the function can be executed in parallel, because there is no smoothing between valand some arguments ptr. In C ++, the keyword is restrictmissing.

  • What are the exact rules for handling pointer antialiasing in C ++ defined by the standard?
  • What are popular compiler extensions that provide semantics similar restrictin C? For example, for MSVC , g ++ , clang ++ and the Intel C ++ compiler .
  • Are there any plans for restrictkeyword standardization in future C ++ standards?
+4
source share

Source: https://habr.com/ru/post/1659179/


All Articles