Cause:
This vectorization diagnostic is emitted starting from Intel(R) C++ Compiler 15.0. There is a limit to compiler's automatic transformation due to the cost modeling. If vectorization is essential, consider using explicitly using if-else or use explicit vector programming such as SIMD directive.
Examples:
void foo(float *A, int *B, int N){ int i; for (i=0;i<N;i++){ switch(B[i]){ case 1: A[i]++; case 2: A[i]+=2; case 3: A[i]+=3; case 4: A[i]+=4; case 5: A[i]+=5; } } }
$ icpc test47.cc -c -O2 -qopt-report2 -qopt-report-phase=vec -qopt-report-file=stderr
Begin optimization report for: foo(float *, int *, int)
Report from: Vector optimizations [vec]
Non-optimizable loops:
LOOP BEGIN at test47.cc(3,3)
remark #15535: loop was not vectorized: loop contains switch statement. Consider using if-else statement. [ test47.cc(4,5) ]
LOOP END