[cfe-dev] Adding Pragma Vectorize

Sean Silva silvas at purdue.edu
Fri Dec 6 10:54:41 PST 2013


Would it make sense to provide a diagnostic explaining why a loop *wasn't*
vectorized (or not as requested) if it is marked with a pragma that
explicitly asks for vectorization? It sounds like users would be interested
in knowing that, and they really have no other way to access that
information.

-- Sean Silva


On Fri, Dec 6, 2013 at 8:35 AM, Renato Golin <renato.golin at linaro.org>wrote:

> Hi Clang folks,
>
> I'm introducing a new pragma "vectorize" to Clang to enable the loop
> info metadata in IR that LLVM already understands.
>
> The syntax is:
>
> #pragma vectorize enable
>
> Forces aggressive vectorization of the following loop, at any optimization
> level
> Adds metadata to the loop {"llvm.vectorize.enable", i1 1}
>
> #pragma vectorize disable
>
> Disable vectorization of the following loop, at any optimization level
> Adds metadata to the loop {"llvm.vectorize.enable", i1 0}
>
> #pragma vectorize width(N)
>
> Forces specified vector width for the following loop
> Adds metadata to the loop {"llvm.vectorize.width", i32 N}
>
> #pragma vectorize unroll(N)
>
> Forces specified unroll factor for the following loop
> Adds metadata to the loop {"llvm.vectorize.unroll", i32 N}
>
> None of these pragmas forces vectorization if the transformation is
> illegal (type/memory/instruction-wise), but "enable" will make -Oz/s
> bloated, as it'll force the aggressive vectorization to run. I'll add
> documentation to Clang and LLVM once this is finished.
>
> I don't know Clang parser's code that well, but I started on the
> obvious ParsePragma.cpp, and added some logic to recognise the
> pragma's syntax. Now I need to attach this information to the AST, and
> later on to the IR as metadata.
>
> Attached is my naive implementation of PragmaVectorizeHandler, but
> I'll need some pointers on how to convert this into AST annotation and
> later into metadata.
>
> Thanks!
> --renato
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131206/4b06a990/attachment.html>


More information about the cfe-dev mailing list