Diagnostic message:"Simd loop was not vectorized: exception handling for a call prevents vectorization"
This diagnostic message is emitted starting from Intel® C++ Compiler 16.0 Update 1 version
Cause:
This diagnostic message is emitted because the compiler automatically generates a try block for the program block (i.e. code inside {}) when it sees any local object or array created in that block, as those objects/arrays need to be de-allocated in case an exception is thrown.
Example: In the example below, the function main contains an array allocation so the try block is created.
%cat main.cpp __attribute__((vector)) void f1(double);int main() { int n = 10000; double a[n]; #pragma simd for(int i = 0 ; i < n ; i++) f1(a[i]);}
% icpc -V
Intel(R) C++ Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 15.0.5.232 Build 20150805
% icpc -O3 -qopenmp -qopt-report-file=stdout -c main.cpp
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.
....
….
Report from: Interprocedural optimizations [ipo]
…
INLINE REPORT: (main()) [1] main.cpp(3,12)
main.cpp(7): (col. 3) warning #13379: loop was not vectorized with "simd"
Report from: Loop nest, Vector & Auto-parallelization optimizations [loop, vec, par]
…..
.....
LOOP BEGIN at main.cpp(7,3)
remark #15333: simd loop was not vectorized: exception handling for a call prevents vectorization [ main.cpp(8,7) ]
remark #13379: loop was not vectorized with "simd"
LOOP END
Workaround: If the called routine is marked as nothrow() the loop will be vectorized:
__attribute__((vector, nothrow)) void SimdEnabledFunction(double);
% icpc -O3 -qopenmp -qopt-report-file=stdout -c main.cpp
.......
........
LOOP BEGIN at main.cpp(7,3)
remark #15301: SIMD LOOP WAS VECTORIZED
LOOP END
======================================
NOTE:
With 15.X.X version of the compiler the diagnostic issued was different:
LOOP BEGIN at main.cpp(7,3)
remark #15520: simd loop was not vectorized: loop with early exits cannot be vectorized unless it meets search loop idiom criteria
....
==========================================