Diagnostic 15019: loop was not vectorized: subscript too complex

Cause:

An array subscript may be too complicated for the compiler to decipher the memory access pattern.


typedef int TTT[64];
TTT *a[4];

int foo(void) {
  TTT *ref;
  int x=0,y=0;
  
  for (int k = 0; k < 64; k++) {
    ref = a[k];
    x += (*ref)[0];
  }
  return x;
}

>icl -c -Qvec-report2 t.cpp

Intel® C++ Compiler for applications running on Intel® 64, Version 12.0.0.063 Build 20100721
Copyright (C) 1985-2010 Intel Corporation.  All rights reserved.

t.cpp
t.cpp(10) (col. 12): remark: loop was not vectorized: subscript too complex.


Resolution:

Try to write the subscripts as an explicit function of the main loop counter:


typedef int TTT[64];
TTT *a[4];

int foo(void) {
  TTT *ref;
  int x=0,y=0;
    
  ref = a[0];  
  for (int k = 0; k < 64; k++) {
    x += (*ref)[k];
  }
  return x;
}

>icl -c -Qvec-report2 t2.cpp

Intel® C++ Compiler for applications running on Intel® 64, Version 12.0.0.063 Build 20100721
Copyright (C) 1985-2010 Intel Corporation.  All rights reserved.

t2.cpp
t2.cpp(9) (col. 3): remark: LOOP WAS VECTORIZED.



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