<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - omp simd reduction "loop not vectorized" warning for a simple loop that even seems vectorized"
   href="https://bugs.llvm.org/show_bug.cgi?id=40546">40546</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>omp simd reduction "loop not vectorized" warning for a simple loop that even seems vectorized
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>8.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>tomas.kalibera@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=21411" name="attach_21411" title="compile with -fopenmp -O2">attachment 21411</a> <a href="attachment.cgi?id=21411&action=edit" title="compile with -fopenmp -O2">[details]</a></span>
compile with -fopenmp -O2

clang8 emits warning

"loop not vectorized: the optimizer was unable to perform the requested
transformation; the transformation might be disabled or specified as part of an
unsupported transformation ordering [-Wpass-failed=transform-warning]"

for the following example, when compiled with "-fopenmp -O2". The generated
code is, however, vectorized and is almost identical to the code generated by
clang7, which does not emit the warning. The same problem as in clang8 is in
the current clang9 (and the emitted code is identical). clang6 produces similar
code, vectorizes the loop, and does not emit the warning, either.

The warning is generated twice when compiling the example, with identical texts
and code locations, and counted as "2 warnings". 

int maybeNotFinite(double *x, unsigned n)
{
    double s = 0;

    #pragma omp simd reduction(+:s)
    for (unsigned i = 0; i < n; i++)
        s += x[i];
    return !finite(s);
}

tested on Ubuntu 18.04.1 with clang from apt.llvm.org
clang version 8.0.0-svn352547-1~exp1~20190130015936.13 (branches/release_80)
clang version 7.0.1-svn348686-1~exp1~20190113235231.54 (branches/release_70)
clang version 9.0.0-svn352666-1~exp1+0~20190130204444.773~1.gbp5cc800 (trunk)

and on clang from Ubuntu 18.04.1
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>