Add pragma force_vectorize to emit error if loop is not vectorized.
Performance critical applications heavily rely on specific loops being vectorized.
Example:
class Sum { public: __attribute__((noinline)) void sumData(uint64_t * data, size_t size) { /// This loop must be vectorized #pragma clang loop force_vectorize(enable) for (size_t i = 0; i < size; ++i) { sum += data[i]; } } private: uint64_t sum = 0; };
If someone breaks vectorization or new version compiler is unable to vectorize it, error will be emitted.
class Sum { public: __attribute__((noinline)) void sumData(uint64_t * data, size_t size) { /// This loop must be vectorized #pragma clang loop force_vectorize(enable) for (size_t i = 0; i < size; ++i) { sum += data[i]; sum += sum; } } private: uint64_t sum = 0; }; clang-17 -emit-llvm -S -O3 -g test_ir.cpp -o test_ir.ll test_ir.cpp:9:9: error: loop not force vectorized: the optimizer was unable to perform the requested transformation; the transformation might be disabled or specified as part of an unsupported transformation ordering 9 | for (size_t i = 0; i < size; ++i) { | ^ 1 error generated.