<div dir="ltr">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.<div>
<br></div><div>-- Sean Silva</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Dec 6, 2013 at 8:35 AM, Renato Golin <span dir="ltr"><<a href="mailto:renato.golin@linaro.org" target="_blank">renato.golin@linaro.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Clang folks,<br>
<br>
I'm introducing a new pragma "vectorize" to Clang to enable the loop<br>
info metadata in IR that LLVM already understands.<br>
<br>
The syntax is:<br>
<br>
#pragma vectorize enable<br>
<br>
Forces aggressive vectorization of the following loop, at any optimization level<br>
Adds metadata to the loop {"llvm.vectorize.enable", i1 1}<br>
<br>
#pragma vectorize disable<br>
<br>
Disable vectorization of the following loop, at any optimization level<br>
Adds metadata to the loop {"llvm.vectorize.enable", i1 0}<br>
<br>
#pragma vectorize width(N)<br>
<br>
Forces specified vector width for the following loop<br>
Adds metadata to the loop {"llvm.vectorize.width", i32 N}<br>
<br>
#pragma vectorize unroll(N)<br>
<br>
Forces specified unroll factor for the following loop<br>
Adds metadata to the loop {"llvm.vectorize.unroll", i32 N}<br>
<br>
None of these pragmas forces vectorization if the transformation is<br>
illegal (type/memory/instruction-wise), but "enable" will make -Oz/s<br>
bloated, as it'll force the aggressive vectorization to run. I'll add<br>
documentation to Clang and LLVM once this is finished.<br>
<br>
I don't know Clang parser's code that well, but I started on the<br>
obvious ParsePragma.cpp, and added some logic to recognise the<br>
pragma's syntax. Now I need to attach this information to the AST, and<br>
later on to the IR as metadata.<br>
<br>
Attached is my naive implementation of PragmaVectorizeHandler, but<br>
I'll need some pointers on how to convert this into AST annotation and<br>
later into metadata.<br>
<br>
Thanks!<br>
<span class="HOEnZb"><font color="#888888">--renato<br>
</font></span><br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>