This diagnostic message is emitted from Intel(R) C++ Compiler 15.0 and above
remark #15520: loop was not vectorized: loop with multiple exits cannot be vectorized unless it meets search loop idiom criteria
Cause:
More than one exit point in the loop. In most cases, a loop must have a single entry and a single exit point in order to be auto-vectorized.
Example:
$ icc -c -qopt-report-file=stderr -qopt-report-phase=vec d15520.c
...
LOOP BEGIN at d15520.c(4,9)
remark #15520: loop was not vectorized: loop with multiple exits cannot be vectorized unless it meets search loop idiom criteria [ d15520.c(7,11) ]
LOOP END
===========================================================================
Workarounds:
Simple search loops are recognized by the compiler and can be vectorized if they are written as a "for" loop, e.g.:
$ icc -c -qopt-report-file=stderr -qopt-report-phase=vec d15524.c
...
LOOP BEGIN at d15524.c(3,3)
remark #15300: LOOP WAS VECTORIZED
LOOP END
More complicated loops such as the original example can be vectorized using a "for" loop preceded by an OpenMP SIMD directive along with an early_exit clause:
$ icc -c -qopt-report-file=stderr -qopt-report-phase=vec d15520_b.c
...
LOOP BEGIN at d15520_b.c(5,13)
remark #15301: OpenMP SIMD LOOP WAS VECTORIZED
LOOP END