Intel® C++ Compiler Classic Developer Guide and Reference

ID 767249
Date 12/16/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

GAP Message (Diagnostic ID 30534)

Message

Add %s option for better type-based disambiguation analysis by the compiler if appropriate (the option will apply for the entire compilation). This will improve optimizations for the loop at line %d.

Advice

Use option [Q]ansi-alias for the specified file. This option will help the compiler to optimize the loop at the specified line. You must verify that the ANSI rules are followed for the entire file. gcc assumes this property by default in default setting O2; the Intel compiler does not. This option is particularly useful for C++ programs since it enables type-based disambiguation between pointers and other elemental datatypes (that in turn enables optimizations such as vectorization and parallelization).

Option [Q]ansi-alias enables or disables use of ANSI aliasing rules optimizations, and assert that the program adheres to these rules.

ANSI-aliasing rules are described in the Standards documentation:

  • C: ISO/IEC 9899, chapter 6.5 paragraph 7

  • C++: ISO/IEC 14882, chapter 3.10, paragraph 15

Example

Consider the following:

#include <stddef.h>
 
template<typename T> 
class blocked_range {
    T my_begin;
    T my_end; 
public:
    blocked_range();
    T begin() const {return my_begin;}
    T end() const {return my_end;} 
};
 
class ApplyMatAdd {
    double *const A, *const B, *const C;
    const size_t size; 
public:
    ApplyMatAdd(double *A_, double *B_, double *C_, size_t size_) : A(A_), B(B_), C(C_), size(size_) {}
    void operator()( const blocked_range<size_t>& range ) const; 
};
 
void ApplyMatAdd::operator()( const blocked_range<size_t>& range ) const {
    for (size_t i=range.begin(); i<range.end(); ++i) {
        for (size_t j=0; j<size; ++j) {
            C[i*size + j] = A[i*size + j] + B[i*size + j];
        }
    } 
}

In this case, the compiler is unable to vectorize the innermost loop at setting O2, the default.

If you determine it is safe to do so, you can compile the above example with the [Q]ansi-alias option, which enables vectorization of the innermost loop.

Verify

Make sure that the semantics of this option are obeyed for the entire compilation.