[llvm-bugs] [Bug 36182] New: [X86] KTEST instruction emitted for signed comparisons despite it always clearing S flag

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jan 31 15:08:24 PST 2018


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

            Bug ID: 36182
           Summary: [X86] KTEST instruction emitted for signed comparisons
                    despite it always clearing S flag
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: craig.topper at gmail.com
                CC: llvm-bugs at lists.llvm.org

declare void @foo()

define void @bar(<16 x i32> %x, <16 x i32> %y) {
  %a = icmp eq <16 x i32> %x, zeroinitializer
  %b = icmp eq <16 x i32> %y, zeroinitializer
  %c = and <16 x i1> %a, %b
  %d = bitcast <16 x i1> %c to i16
  %e = icmp slt i16 %d, 0
  br i1 %e, label %end, label %call
call:
  call void @foo()
  br label %end
end:
  ret void
}






This IR

Produces this assembly

bar:                                    # @bar
        .cfi_startproc
# %bb.0:
        pushq   %rax
        .cfi_def_cfa_offset 16
        vporq   %zmm1, %zmm0, %zmm0
        vptestnmd       %zmm0, %zmm0, %k0
        ktestw  %k0, %k0
        js      .LBB0_2
# %bb.1:                                # %call
        vzeroupper
        callq   foo
.LBB0_2:                                # %end
        popq    %rax
        vzeroupper
        retq
.Lfunc_end0:
        .size   bar, .Lfunc_end0-bar
        .cfi_endproc
                                        # -- End function


Which is broken because KTEST always 0s the S flag.

-- 
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/20180131/548749d2/attachment.html>


More information about the llvm-bugs mailing list