<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Oct 21, 2019 at 5:12 PM Michael Kruse <<a href="mailto:llvm-commits@meinersbur.de">llvm-commits@meinersbur.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Am Mo., 21. Okt. 2019 um 16:01 Uhr schrieb Jordan Rupprecht via<br>
cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="cremed">cfe-commits@lists.llvm.org</a>>:<br>
> There's also a curious failure caused by this patch (confirmed passing @r374287, failing @r374288):<br>
<br>
It's a warning, not a failure.<br></blockquote><div>True. We build with -Werror.</div><div><br></div><div>At any rate, it sounds like this is not a codegen bug at all, but just an over-eager warning? If so, I'll double check the IR of the internal repro isn't affected by this patch when -Wno-pass-failed, and use that as a temporary measure until the eager warning can be removed.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
<br>
> $ cat /tmp/vectorize.cc<br>
> void a() {<br>
> #pragma clang loop vectorize(disable)<br>
>   for (;;)<br>
>     ;<br>
> }<br>
><br>
> $ clang++ -Werror -O3 -c /tmp/vectorize.cc<br>
> /tmp/vectorize.cc:1:6: error: loop not interleaved: the optimizer was unable to perform the requested transformation; the transformation might be disabled or specified as part of an unsupported transformation ordering [-Werror,-Wpass-failed=transform-warning]<br>
> void a() {<br>
><br>
> I don't understand this warning -- there is no requested transformation; in fact, we've explicitly specified that vectorization *should* be disabled.<br>
<br>
<a href="https://reviews.llvm.org/D66290" rel="noreferrer" target="_blank" class="cremed">https://reviews.llvm.org/D66290</a><br>
<br>
generates the following metadata for #pragma clang loop vectorize(disable):<br>
<br>
!3 = distinct !{!3, !4, !5}<br>
!4 = !{!"llvm.loop.vectorize.enable", i1 true}<br>
!5 = !{!"llvm.loop.vectorize.width", i32 1}<br>
<br>
which is interpreted as "enable LoopVectorize, but only the interleave<br>
part" by LoopVectorize and WarnMissedTransformations.<br>
<br>
The tests in D66290 missed that because the regex may matche multiple MDNodes:<br>
<br>
// CHECK: ![[LOOP_5]] = distinct !{![[LOOP_5]],<br>
![[UNROLL_DISABLE:.*]], ![[DISTRIBUTE_DISABLE:.*]], ![[WIDTH_1:.*]]}<br>
<br>
The additional "llvm.loop.vectorize.enable" is generated by:<br>
<br>
  if (Attrs.VectorizeWidth > 0) {<br>
    // This implies vectorize.enable = true, but only add it when it is not<br>
    // already enabled.<br>
    if (Attrs.VectorizeEnable != LoopAttributes::Enable)<br>
<br>
Attr.VectorizeWidth is set by the vectorize(disable) LoopHint:<br>
<br>
    case LoopHintAttr::Disable:<br>
      switch (Option) {<br>
      case LoopHintAttr::Vectorize:<br>
        // Disable vectorization by specifying a width of 1.<br>
        setVectorizeWidth(1);<br></blockquote><div>Might setVectorizeWidth(0) (or -1, or llvm::Optional<int>) be a better signal of "vectorization is disabled" than 1 (which could later be interpreted as "we failed to vectorize when requested")?</div><div><br></div><div>(No familiarity with this code, not sure if this suggestion makes sense)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
<br>
<br>
Michael<br>
</blockquote></div></div>