[llvm-bugs] [Bug 30309] New: [KNL] Wrong instruction generated in while-condition

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Sep 7 05:13:55 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=30309

            Bug ID: 30309
           Summary: [KNL] Wrong instruction generated in while-condition
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ilia.taraban at intel.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

==============test.c=================
#include "stdio.h"

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

>>>clang -v
clang version 4.0.0 (cfe/trunk 280679)
...

>>>clang test.c
>>>./a.out
no output

>>>clang -march=knl test.c
>>>sde -knl -- ./a.out
>>>4
>>>4
>>>4
....

=======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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160907/3f444344/attachment-0001.html>


More information about the llvm-bugs mailing list