A tool for detecting problems with pointer aliases in C / C ++

Is there a tool that can analyze pseudonyms in a program and tells you where gcc / g ++ should generate suboptimal sequences of commands due to potential pointer smoothing?

+3
source share
2 answers

I don’t know anything about what "100%" coverage gives, but for vectorizing code (which is often overlapped by an alias) I use a parameter -ftree-vectorizer-verbose=nwhere n is an integer from 1 to 6. This prints some information why the loop cannot be vectorized .

For example, with g ++ 4.1 code

//#define RSTR __restrict__
#define RSTR

void addvec(float* RSTR a, float* b, int n)
{
  for (int i = 0; i < n; i++)
    a[i] = a[i] + b[i];
}

leads to

$ g++ -ftree-vectorizer-verbose=1 -ftree-vectorize -O3 -c aliastest.cpp

aliastest.cpp:6: note: vectorized 0 loops in function.

RSTR,

$ g++ -ftree-vectorizer-verbose=1 -ftree-vectorize -O3 -c aliastest.cpp

aliastest.cpp:6: note: LOOP VECTORIZED.
aliastest.cpp:6: note: vectorized 1 loops in function.

, g++ 4.4, :

$ g++44 -ftree-vectorizer-verbose=1 -O3 -c aliastest.cpp

aliastest.cpp:6: note: created 1 versioning for alias checks.

aliastest.cpp:6: note: LOOP VECTORIZED.
aliastest.cpp:4: note: vectorized 1 loops in function.

RSTR.

+4

. , - - , , . , , , , , , "restict" ( , ).

, - , .

, , .

+1

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


All Articles