r374288 - Recommit "[Clang] Pragma vectorize_width() implies vectorize(enable)"

Michael Kruse via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 21 17:11:30 PDT 2019


Am Mo., 21. Okt. 2019 um 16:01 Uhr schrieb Jordan Rupprecht via
cfe-commits <cfe-commits at lists.llvm.org>:
> There's also a curious failure caused by this patch (confirmed passing @r374287, failing @r374288):

It's a warning, not a failure.


> $ cat /tmp/vectorize.cc
> void a() {
> #pragma clang loop vectorize(disable)
>   for (;;)
>     ;
> }
>
> $ clang++ -Werror -O3 -c /tmp/vectorize.cc
> /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]
> void a() {
>
> I don't understand this warning -- there is no requested transformation; in fact, we've explicitly specified that vectorization *should* be disabled.

https://reviews.llvm.org/D66290

generates the following metadata for #pragma clang loop vectorize(disable):

!3 = distinct !{!3, !4, !5}
!4 = !{!"llvm.loop.vectorize.enable", i1 true}
!5 = !{!"llvm.loop.vectorize.width", i32 1}

which is interpreted as "enable LoopVectorize, but only the interleave
part" by LoopVectorize and WarnMissedTransformations.

The tests in D66290 missed that because the regex may matche multiple MDNodes:

// CHECK: ![[LOOP_5]] = distinct !{![[LOOP_5]],
![[UNROLL_DISABLE:.*]], ![[DISTRIBUTE_DISABLE:.*]], ![[WIDTH_1:.*]]}

The additional "llvm.loop.vectorize.enable" is generated by:

  if (Attrs.VectorizeWidth > 0) {
    // This implies vectorize.enable = true, but only add it when it is not
    // already enabled.
    if (Attrs.VectorizeEnable != LoopAttributes::Enable)

Attr.VectorizeWidth is set by the vectorize(disable) LoopHint:

    case LoopHintAttr::Disable:
      switch (Option) {
      case LoopHintAttr::Vectorize:
        // Disable vectorization by specifying a width of 1.
        setVectorizeWidth(1);



Michael


More information about the cfe-commits mailing list