Diagnostic message: XXX was not vectorized: loop with early exits cannot be vectorized unless it meets search loop idiom criteria is only emitted in Intel(R) C++ Compiler 15.0 and the current 16.0 version of the product.
Cause:
This diagnostic message is emitted when the loop in question doesn't meet the vectorization criteria on not having a complete loop execution without a loop exit or branch redirection. In the example below the iteration control variable causes a conditional loop exit preventing vectorization.
Example:
%cat vec.c
void no_vec(float a[], float b[], float c[])
{
int i,j,k;
while (i < 100) {
a[i] = b[i] * c[i];
++i;
if (i==5) break;else continue;
}
}
Using Intel(R) C++ Compiler 16.0:
% icc -c -opt-report-phase=vec -opt-report-file=stdout vec.c
Intel(R) Advisor can now assist with vectorization and show optimization
report messages with your source code.
See "https://software.intel.com/en-us/intel-advisor-xe" for details.
Begin optimization report for: no_vec(float *, float *, float *)
Report from: Vector optimizations [vec]
LOOP BEGIN at vec.c(4,4)
remark #15520: loop was not vectorized: loop with multiple exits cannot be vectorized unless it meets search loop idiom criteria
LOOP END
Recommendation
Try to see if you can redo the loop as below
% cat vec.c
void no_vec(float a[], float b[], float c[])
{
int i,j,k;
while (i < 5 || i > 5) {
a[i] = b[i] * c[i];
++i;
}
}
% icc -c -opt-report-phase=vec -opt-report-file=stdout vec.c
Intel(R) Advisor can now assist with vectorization and show optimization
report messages with your source code.
See "https://software.intel.com/en-us/intel-advisor-xe" for details.
Begin optimization report for: no_vec(float *, float *, float *)
Report from: Vector optimizations [vec]
LOOP BEGIN at vec2.c(4,4)
<Peeled loop for vectorization, Multiversioned v1>
LOOP END
LOOP BEGIN at vec2.c(4,4)
<Multiversioned v1>
remark #15300: LOOP WAS VECTORIZED
LOOP END
LOOP BEGIN at vec2.c(4,4)
<Alternate Alignment Vectorized Loop, Multiversioned v1>
LOOP END
LOOP BEGIN at vec2.c(4,4)
<Remainder loop for vectorization, Multiversioned v1>
remark #15301: REMAINDER LOOP WAS VECTORIZED
LOOP END
LOOP BEGIN at vec2.c(4,4)
<Remainder loop for vectorization, Multiversioned v1>
LOOP END
LOOP BEGIN at vec2.c(4,4)
<Multiversioned v2>
remark #15304: loop was not vectorized: non-vectorizable loop instance from multiversioning
LOOP END
LOOP BEGIN at vec2.c(4,4)
<Remainder, Multiversioned v2>
LOOP END