GAP Message - remark #30536: (LOOP) Add -Qno-alias-args option for better type-based disambiguation analysis ...

Message

Add -Qno-alias-args option for better type-based disambiguation analysis by the compiler, if appropriate (the option will apply for the entire compilation). This will improve optimizations such as vectorization for the loop at line 9. [VERIFY] Make sure that the semantics of this option is obeyed for the entire compilation. [ALTERNATIVE] Another way to get the same effect is to add the "restrict" keyword to each pointer-typed formal parameter of the routine "foo". This allows optimizations such as vectorization to be applied to the loop at line 9. [VERIFY] Make sure that semantics of the "restrict" pointer qualifier is satisfied: in the routine, all data accessed through the pointer must not be accessed through any other pointer.
bucket-level 4

Description

Use option -fnoargument-alias (Linux* OS and Mac OS* X) or /Qno-alias-args (Windows* OS) for the specified file. This option will help the compiler to optimize the loop at the specified line. The user has to verify that there is no argument-aliasing for routines in this file before applying this option for the current file. This option is particularly useful for C++ programs since it enables type-based disambiguation between pointers that are passed in as arguments, which in turn enables optimizations such as vectorization and parallelization.
Option -fargument-alias (Linux* OS and Mac OS* X) and /Qalias-args (Windows* OS) enable or disable the C/C++ rule that function arguments may be aliased. When disabling the rule, you assert that this is safe.

Help description from the Intel Compiler on /Qalias-args option:

/Qalias-args[-]
          enable(DEFAULT)/disable C/C++ rule that function arguments may be
          aliased; when disabling the rule, the user asserts that this is safe

How the rules can be violated:

An example that demonstrates a violation of -Qno-alias-args:

void f(double *p, double *q, double *r) {
  int i;
  for (i = 0; i < n; i++)
    p[i] = q[i] + r[i];
}

int n, m;
double A[100], B[100];
...
f(&A[n], &A[m], &B[0]);

Since both pointers p and q will be pointing to the same array A, there may be overlap depending on the values of n and m.

It is also wrong to use retrict keyword for parameters p and q in the function f for this test-case.

The user has to analyze all the callers of the function f and make sure that such overlap does not exist before applying the -Qno-alias-args (or the restrict qualifier). Such call-sites may occur in other files (other than the current file that contains the definition of f) as well.

Example

void matrix_mul_matrix(int  N, float * C,  float  *A,  float  *B) {
  int  i,j,k;

  for (i=0; i<N; i++) {
    for (j=0; j<N; j++) {
      C[i*N+j]=0;
      for(k=0;k<N;k++)
      {
        C[i*N+j]+=A[i*N+k] * B[k*N+j];
      }
    }
  }
}

For this example, the compiler is unable to apply loop optimizations such as loop-interchange and vectorization at -O2. Adding the -Qguide=4 option produces the following message:

t1.c(9): remark #30536: (LOOP) Add -Qno-alias-args option for better type-based disambiguation analysis by the compiler, if appropriate (the option will apply for the entire compilation). This will improve optimizations such as vectorization for the loop at line 9. [VERIFY] Make sure that the semantics of this option is obeyed for the entire compilation. [ALTERNATIVE] Another way to get the same effect is to add the "restrict" keyword to each pointer-typed formal parameter of the routine "matrix_mul_matrix". This allows optimizations such as vectorization to be applied to the loop at line 9. [VERIFY] Make sure that semantics of the "restrict" pointer qualifier is satisfied: in the routine, all data accessed through the pointer must not be accessed through any other pointer.

Compiling this example with -Qno-alias-args option added (if the user decides it is safe to do so) enables loop-interchange (for better data locality) followed by vectorization of the innermost loop.

Optimization Notice in English

Tags:
For more complete information about compiler optimizations, see our Optimization Notice.