<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - AVX512: incorrect code generation for simple piece of code (KNL & CNL backends affected)"
   href="https://llvm.org/bugs/show_bug.cgi?id=30502">30502</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>AVX512: incorrect code generation for simple piece of code (KNL & CNL backends affected)
          </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>All
          </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>Backend: X86
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>wenzel.jakob@epfl.ch
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I've run into issues where the current (trunk) backend for Xeon Phi generates
incorrect code. As with similar issues before, it's got something to do with
LLVM's use of mask registers.

The snippet is given below (I tried to make it as small as possible). It makes
no use of AVX512 features whatsoever.

Try it as follows:

$ clang++ -march=nocona -std=c++11 -stdlib=libc++ -O0 -fno-rtti -fno-exceptions
-o test_works
$ ./test_works
(no crash)

$ clang++ -march=knl -std=c++11 -stdlib=libc++ -O0 -fno-rtti -fno-exceptions -o
test_broken
$ ./test_broken
[2]  91952 segmentation fault (core dumped)   ./test_broken

Looking at the diff of the assembly files generated by the two different
backends, there is only one change which is not equivalent and thus introduces
the failure:

$ diff -u assembly-nocona.s  assembly-knl.s                              [INS]
--- assembly-nocona.s    2016-09-23 11:09:30.000000000 +0200
+++ assembly-knl.s    2016-09-23 11:09:30.000000000 +0200
@@ -66,7 +66,8 @@
     movq    %rax, -24(%rbp)         # 8-byte Spill
     callq    _ZN5ArrayC2Ev
     movb    $1, -1(%rbp)
-    testb    $1, -1(%rbp)
+    movb    -1(%rbp), %cl
+    kortestw    %cl, %cl
     jne    .LBB1_2
 # BB#1:
     movq    -16(%rbp), %rdi         # 8-byte Reload


=========================================
#include <memory>

/* Some dummy data structure */
struct Data { float f; };

/* Stores a 'Data' instance via unique_ptr */
struct Array {
    using Holder = std::unique_ptr<Data[]>;

    Array() : data(new Data[1]) { }
    Array(const Array &) : data(new Data[1]) { }

    static Array Make() { Array result; return result; }

    Array &operator=(Array &value) { data[0] = value.data[0]; return *this; }

    Holder data;
};

int main(int /* argc */, char * /* argv */[]) {
    Array a = Array::Make();

    /* This next line causes a crash (nullptr dereference in __memcpy) */
    Data result = a.data[0];

    /* Quench unused variable warning */
    (void) result;

    return 0;
}
===========================</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>