<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 --- - [KNL] Wrong instruction generated in while-condition"
   href="https://llvm.org/bugs/show_bug.cgi?id=30309">30309</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[KNL] Wrong instruction generated in while-condition
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </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>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>ilia.taraban@intel.com
          </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>==============test.c=================
#include "stdio.h"

int main(){
        int k = 0, x = 1;
        while((k > 0) && (x > 0))
        {
                printf("4\n");
        }
        return 0;
}
======================================

<span class="quote">>>>clang -v</span >
clang version 4.0.0 (cfe/trunk 280679)
...

<span class="quote">>>>clang test.c
>>>./a.out</span >
no output

<span class="quote">>>>clang -march=knl test.c
>>>sde -knl -- ./a.out
>>>4
>>>4
>>>4</span >
....

=======generated-while-assembler========
  40051d:    31 c0                    xor    %eax,%eax
  40051f:    88 c1                    mov    %al,%cl              <- moving
zero to cl
  400521:    83 7d f8 00              cmpl   $0x0,-0x8(%rbp)
  400525:    c5 f8 92 c1              kmovw  %ecx,%k0             <- coping
full cx to k0, not only zero
  400529:    c5 f8 91 45 f2           kmovw  %k0,-0xe(%rbp)
  40052e:    0f 8e 16 00 00 00        jle    40054a <main+0x4a>
  400534:    8b 45 f4                 mov    -0xc(%rbp),%eax
  400537:    85 c0                    test   %eax,%eax
  400539:    0f 9f c1                 setg   %cl
  40053c:    88 c8                    mov    %cl,%al
  40053e:    83 e0 01                 and    $0x1,%eax
  400541:    c5 f8 92 c0              kmovw  %eax,%k0
  400545:    c5 f8 91 45 f2           kmovw  %k0,-0xe(%rbp)
  40054a:    c5 f8 90 45 f2           kmovw  -0xe(%rbp),%k0
  40054f:    c5 f8 98 c0              kortestw %k0,%k0             <- as
result, no zero in k0
  400553:    0f 85 05 00 00 00        jne    40055e <main+0x5e>
  400559:    e9 19 00 00 00           jmpq   400577 <main+0x77>
=========================================
------------------------
Intel Software Engineer
Ilia Taraban</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>