[cfe-dev] Why doesn't pragma vectorize warn by default on failure
Tyler Nowicki
tnowicki at apple.com
Wed Jul 22 14:48:54 PDT 2015
Hi Gonzalo,
Warnings are currently generated when a loop is illegal to vectorize and vectorize(enable) or interleave(enable) is specified. For example,
#pragma clang loop vectorize(enable)
for(int i = 0; i < N; i++) {
if(array[i] > 0) break;
else array[i] = 0;
}
>clang -O3 code.c
warning: loop not vectorized: failed explicitly specified loop vectorization [-Wpass-failed]
See http://blog.llvm.org/2014/11/loop-vectorization-diagnostics-and.html <http://blog.llvm.org/2014/11/loop-vectorization-diagnostics-and.html> for more info.
Its possible there is a bug in the code for generating the warning or we missed generating it somewhere. Could you provide the loop body?
When the loop is not beneficial to vectorize and vectorize(enable) is specified it will vectorize anyway with a width of 2.
Actually I’m a little worried that this could be resulting in inefficient code because people are specifying vectorize(enable) when in-fact they just want the fastest code according to the cost-model. Perhaps we should let the user specify vectorize without an option ‘#pragma loop vectorize’ to say ‘warn me if the structure of the loop cannot be vectorized otherwise select the fastest code according to the cost-model’.
Tyler
> On Jul 22, 2015, at 9:39 AM, Hal Finkel <hfinkel at anl.gov> wrote:
>
> ----- Original Message -----
>> From: "Gonzalo BG" <gonzalobg88 at gmail.com>
>> To: "cfe-dev at cs.uiuc.edu Developers" <cfe-dev at cs.uiuc.edu>
>> Sent: Wednesday, July 22, 2015 11:29:28 AM
>> Subject: [cfe-dev] Why doesn't pragma vectorize warn by default on failure
>>
>>
>>
>> Right now when writing code like:
>>
>> #pragma clang loop vectorize(enable) interleave(enable)
>> while(...) {
>> ...
>> }
>>
>> one has to:
>>
>>
>> 1) pass the compiler the flags "-Rpass-missed=loop-vectorize
>> -Rpass-analysis=loop-vectorize" to get a warning on all loops where
>> vectorization failed.
>> 2) grep that output (which might be huge in a moderately sized
>> project) for that particular loop.
>> 3) Check if vectorization worked.
>> 4) Remove the compiler flags and recompile to keep working on
>> something else.
>>
>> This is really bad.
>>
>>
>> A user specified that a loop has to be vectorized. When I do this, it
>> is my intent that the loop gets vectorized. However, the current
>> workflow discourages users from actually checking that vectorization
>> worked. Furthermore, if months later something on that loop changes
>> that breaks vectorization, this happens silently.
>>
>> Why are things this way? Can something be done about this?
>
> I agree, this seems like a nice idea. For loops that have the pragma, we should enable the pass "missed" informational messages from the vectorizer (unroller, etc.) by default. Patches are obviously welcome -- and/or, please file a bug report at https://llvm.org/bugs/
>
> -Hal
>
>>
>> Could we get these warnings on by default for those loops explicitly
>> marked with the vectorize pragma?
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>
>
> --
> Hal Finkel
> Assistant Computational Scientist
> Leadership Computing Facility
> Argonne National Laboratory
> _______________________________________________
> 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/20150722/8c6723cb/attachment.html>
More information about the cfe-dev
mailing list