<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 - SLP: missed vectorization due to cost model (benchmark from SPECFP 2006)"
   href="https://bugs.llvm.org/show_bug.cgi?id=52126">52126</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>SLP: missed vectorization due to cost model (benchmark from SPECFP 2006)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>david.bolvansky@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>433.milc

typedef struct {
    double real;
    double imag;
} complex;
typedef struct {
    complex e[3][3];
} su3_matrix;

#define CSUM(a, b)            \
    {                         \
        (a).real += (b).real; \
        (a).imag += (b).imag; \
    }
#define CMUL(a, b, c)                                         \
    {                                                         \
        (c).real = (a).real * (b).real - (a).imag * (b).imag; \
        (c).imag = (a).real * (b).imag + (a).imag * (b).real; \
    }

void mult_su3_nn2(su3_matrix *a, su3_matrix *b, su3_matrix *c) {
    int i, j, k;
    complex x, y;
    for (i = 0; i < 3; i++)
        for (j = 0; j < 3; j++) {
            x.real = x.imag = 0.0;
            for (k = 0; k < 3; k++) {
                CMUL(a->e[i][k], b->e[k][j], y);
                CSUM(x, y);
            }
            c->e[i][j] = x;
        }
}

Flags: -Ofast -mavx
<a href="https://godbolt.org/z/b6nq5sKaW">https://godbolt.org/z/b6nq5sKaW</a>

example.cpp:10:5: remark: the cost-model indicates that vectorization is not
beneficial [-Rpass-missed=loop-vectorize]
    for(i=0;i<3;i++)
    ^
example.cpp:10:5: remark: the cost-model indicates that interleaving is not
beneficial [-Rpass-missed=loop-vectorize]

GCC/ICC vectorizes mult_su3_nn_unrolled. LLVM does not vectorize it with
AVX/AVX, only with -AVX512 (but does not use vaddsubpd as GCC and ICC do; GCC
recently added pattern detection for addsub to SLP vectorizer)</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>