1

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

1
  • 1
    I assume GCC is changing this because of folklore than -O3 is "too aggressive" and/or often not faster. Clang enables auto-vectorization at -O2, so GCC before 12 looked bad by comparison if people benchmark at -O2. Simple loops on modern CPUs benefit significantly from SIMD. Commented Feb 9, 2022 at 4:02

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

ha that's it! I didn't see terms like latest or current in the url so I didn't know the doc is versioned. But thanks to you I looked into it and found https://gcc.gnu.org/onlinedocs/gcc-11.2.0/gcc/Optimize-Options.html is what I am looking for

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.