<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 - Compiler generating unsupported AVX2 instruction for non-AVX2 target after r346784"
   href="https://bugs.llvm.org/show_bug.cgi?id=39733">39733</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Compiler generating unsupported AVX2 instruction for non-AVX2 target after r346784
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </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>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>douglas_yung@playstation.sony.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>After commit r346784, we started to notice that some of our internal tests were
failing with an illegal instruction. Upon inspection, it looks like the
compiler is now generating an AVX2 instruction when the architecture specified
(btver2 in this case) does not support it leading to an exception at runtime.

Here is the trimmed example from our test:

/* repro.cpp */
typedef signed int sint;
typedef sint __attribute__((ext_vector_type(8))) sint8;
typedef short __attribute__((ext_vector_type(8))) short8;

#define convertvector_short8_sint8(__A) (__builtin_convertvector(__A, sint8))

void test55() {
  short8 id11762 =
      (short8){(short)-186357704, (short)-396064952, (short)-792594146,
               (short)1159072119, (short)1939245255, (short)-530257005,
               (short)870979680,  (short)-2063923297}; // vec_type
  sint8 id11761 = convertvector_short8_sint8(id11762);
}

If you compile this with the options "-O0 -march=btver2" and examine the
assembly that is generated for function test55(), you will see the following
instruction being generated:

vpmovsxwd       64(%rsp), %ymm1

If you look at the documentation for the vpmovsxwd instruction, you will see
that the form that accepts ymm registers requires AVX2 support which btver2
does not support.</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>