I was reading A guide to vectorization with Intel C++ compilers: https://software.intel.com/sites/default/files/8c/a9/CompilerAutovectori...
I am referring to Single Entry and Single Exit Criteria Page No 8. I have specified two options a) Break b) Continue
A) Break
void no_vec(float a[], float b[], float c[])
{
int i = 0;
while(i < 100)
{
a[i] = b[i] * c[i];
if(a[i] < 0.0)
break;
++i;
}
}
===========================================================================
Begin optimization report for: no_vec(float *, float *, float *)
Report from: Vector optimizations [vec]
LOOP BEGIN at breaktest.c(6,2)
remark #15520: loop was not vectorized: loop with early exits cannot be vectorized unless it meets search loop idiom criteria
LOOP END
===========================================================================
B) Continue
void no_vec(float a[], float b[], float c[])
{
int i = 0;
while(i < 100)
{
a[i] = b[i] * c[i];
if(a[i] < 0.0)
continue;
++i;
}
}
===========================================================================
Begin optimization report for: no_vec(float *, float *, float *)
Report from: Vector optimizations [vec]
Non-optimizable loops:
LOOP BEGIN at continuetest.c(6,2)
remark #15523: loop was not vectorized: cannot compute loop iteration count before executing the loop.
LOOP END
===========================================================================
My Questions :
1) What difference continue and break makes for the optimizers to change the remark in optrpt
2) Is there any way to vectorize the loop, although it is necessary for loop to have data-dependent continue condition.