[cfe-dev] clang auto-vectorization feedback is confusing

Adam Nemet via cfe-dev cfe-dev at lists.llvm.org
Thu Jun 30 16:55:47 PDT 2016


> On Jun 30, 2016, at 1:13 PM, Sean McBride <sean at rogue-research.com> wrote:
> 
> On Thu, 30 Jun 2016 09:53:41 -0700, Adam Nemet said:
> 
>>> It helpfully says it vectorized the inner loop, but says *nothing*
>> about the outer loop.
>> 
>> Currently the vectorizer does not visit outer loops and the diagnostics
>> is emitted in the vectorizer so we don’t get a chance to report
>> anything.  Can you please file a bug?
> 
> Done, see:
> <https://llvm.org/bugs/show_bug.cgi?id=28374> 
> <https://llvm.org/bugs/show_bug.cgi?id=28377>
> 
>>> If I comment out the printf(), then it outputs nothing whatsoever. 
>> Is this because earlier optimizer passes are basically destroying/
>> transforming away the loop before the vectorizer sees it?
>> 
>> Sort of, it’s because the loops are removed.  I am not sure what the
>> expected behavior should be in this case...
> 
> Well, difficulties aside, from my perspective, it'd be nice if, for every loop in a compiled file, if clang could tell me:
> - this loop _was_ vectorized
> - this loop was _not_ vectorized because xyz
> - this loop was removed/optimized away/transformed/whatever
> 
> As it stands, one is left guessing in the last case.

I think that’s fair.  Can you please file a bug with the loop removal as well?  Loop removal could check for these pragmas and issue diagnostics.

> 
>> I am not sure there is anything beyond what you’re doing right now.  You
>> could look at the internal debug dumps with a debug version of clang but
>> probably the best thing to do is to file PRs on anything that does not
>> make sense to you.
> 
> Thanks for the suggestion.  Relatedly, when faced with a diagnostic like "Loop not vectorized: unsafe dependent memory operations in loop", is there any reference that can help a layman understand what this is telling me exactly?  I STFW without many results.

On trunk we now emit:

"unsafe dependent memory operations in loop. Use #pragma loop distribute(enable) to allow loop distribution to attempt to isolate the offending operations into a separate loop”

And then the pragma is documented with an example under http://clang.llvm.org/docs/LanguageExtensions.html#loop-distribution

That said, it still does not really explain what unsafe dependences mean.  Feel free to file another bug for this.

Thanks,
Adam

> 
>> Thanks for reporting.
> 
> Also filed these:
> 
> Poor -Rpass-analysis=loop-vectorize diagnostic message for (acceptable) failure to vectorize Objective-C fast enumeration loops 
> <https://llvm.org/bugs/show_bug.cgi?id=28375>
> <rdar://27112452>>
> 
> -Rpass-missed=loop-vectorize says to use -Rpass-analysis=loop-vectorize even if I already am
> <https://llvm.org/bugs/show_bug.cgi?id=28376>
> 
> Cheers,
> 
> Sean




More information about the cfe-dev mailing list