How to disable vector snapping when using GCC?

I am compiling my code using the following command:

gcc -O3 -ftree-vectorizer-verbose=6 -msse4.1 -ffast-math 

In this case, all optimizations are included.

But I want to disable vectorization while maintaining other optimizations.

+6
source share
3 answers

Most GCC switches can be used with the no prefix to disable their behavior. Try -fno-tree-vectorize (after -O3 on the command line).

+8
source

you can also selectively enable and disable vectorization using attributes of the optimization function or pragmas

http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html

http://gcc.gnu.org/onlinedocs/gcc/Function-Specific-Option-Pragmas.html

eg.

 __attribute__((optimize("no-tree-vectorize"))) void f(double * restrict a, double * restrict b) { for (int i = 0; i < 256; i++) a[i] += b[i]; } 
+5
source

Great, now that gcc has become more aggressive with vectorization, for example.

 extern "C" __attribute__((optimize("no-tree-vectorize"))) /* Subroutine */ int s111_ (integer * ntimes, integer * ld, integer * n, real * ctime, real * dtime, real * __restrict a, real * b, real * c__, real * d__, real * e, real * aa, real * bb, real * cc) { .... for (i__ = 2; i__ <= i__2; i__ += 2) a[i__] = a[i__ - 1] + b[i__]; .... 

In the above case, the removal of restrict used to complete the task, but now g ++ 6.0 cannot be stopped from vectorization by removing __restrict .

0
source

Source: https://habr.com/ru/post/899360/


All Articles