<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: invalid code generation for scalar code when AVX512 is enabled"
   href="https://llvm.org/bugs/show_bug.cgi?id=28849">28849</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>AVX512: invalid code generation for scalar code when AVX512 is enabled
          </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>When AVX512 is enabled, Clang produces incorrect code for very basic scalar
programs which don't involve any vector/intrinsic code at all. This only occurs
at the lowest optimization level.

Consider the following snippet:

#include <assert.h>
int main(int argc, char *argv[]) {
    float a = 1;
    float b = 1;
    assert(a == b);
    return 0;
}

Example usage (Clang HEAD):

$ clang test.cpp -o test -mavx512f -fomit-frame-pointer
$ ./test
./Assertion failed: (a == b), function main, file test.cpp, line 6.


Looking at the assembly, there are some weird sequences of moves from
traditional registers to AVX512-style mask registers and back. Probably
something is wrong there.

_main:                                  ## @main
    .cfi_startproc
## BB#0:
    subq    $40, %rsp
Ltmp0:
    .cfi_def_cfa_offset 48
    movb    $1, %al
    movl    $0, 36(%rsp)
    movl    %edi, 32(%rsp)
    movq    %rsi, 24(%rsp)
    movl    $1065353216, 20(%rsp)   ## imm = 0x3F800000
    movl    $1065353216, 16(%rsp)   ## imm = 0x3F800000
    vmovss    20(%rsp), %xmm0         ## xmm0 = mem[0],zero,zero,zero
    vmovss    LCPI0_0(%rip), %xmm1    ## xmm1 = mem[0],zero,zero,zero
    vucomiss    %xmm1, %xmm0
    setnp    %cl
    sete    %dl
    setne    %r8b
    setp    %r9b
    andb    %cl, %dl
    andb    $1, %dl
    movb    %dl, %r10b
    kmovw    %r10d, %k0
    orb    %r9b, %r8b
    andb    $1, %r8b
    movb    %r8b, %r10b
    kmovw    %r10d, %k1
    testb    $1, %k1
    movb    %al, 15(%rsp)           ## 1-byte Spill
    kmovw    %k0, 12(%rsp)           ## 2-byte Spill
    jne    LBB0_1
    jmp    LBB0_2
LBB0_1:
    leaq    L___func__.main(%rip), %rdi
    leaq    L_.str(%rip), %rsi
    movl    $6, %edx
    leaq    L_.str.1(%rip), %rcx
    callq    ___assert_rtn
LBB0_2:
    jmp    LBB0_3
LBB0_3:
    xorl    %eax, %eax
    addq    $40, %rsp
    retq
    .cfi_endproc</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>