[llvm-dev] LLVM flags for Vectorization

Renato Golin via llvm-dev llvm-dev at lists.llvm.org
Tue Aug 23 04:57:44 PDT 2016

On 20 August 2016 at 09:22, Santanu Das via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> I have been analyzing the LLVM vectorizer by running some benchmarks. For
> vectorization, I have used the following flags:
> -O3
> -ffast-math
> -mavx2
> Am I missing any other flags which will improve vectorizer performance?

Hi Santanu,

These flags should be enough for Clang to vectorise your code based on
AVX2 support.

If that doesn't give you the vectorisation you want, you can try to
force the vector width or unroll factor by either command line options
or pragmas in the code:


If you don't understand why a loop is not being vectorised, you can
try the Clang diagnostics:


And, of course, if you spot a loop or a basic block that could have
been vectorised but wasn't, please open a bug on our bugzilla with the
results of the diagnostics and your experimentation with widths and


Hope that helps.


More information about the llvm-dev mailing list