简体   繁体   中英

Is `-ftree-slp-vectorize` not enabled by `-O2` in GCC?

From https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

It says "-ftree-slp-vectorize: Perform basic block vectorization on trees. This flag is enabled by default at -O2 and by -ftree-vectorize, -fprofile-use, and -fauto-profile."

However it seems I have to pass a flag explicitly to turn on SIMD. Did I mis undertand something here? It is enabled at -O3 though.

https://www.godbolt.org/z/1ffzdqMoT

Is -ftree-slp-vectorize not enabled by -O2 in GCC?

Yes and no. It depends on the version of the compiler.

From https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

You have linked to the latest version of documentation. It applies to the version that is currently under development, which at the moment is version 12.

However it seems I have to pass a flag explicitly to turn on SIMD.

https://www.godbolt.org/z/1ffzdqMoT

Your example uses GCC version 11.

Did I mis undertand something here?

You read the wrong version of documentation, or used wrong version of compiler and hence your assumption didn't hold.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM