[llvm-bugs] [Bug 41672] New: [X86] Different codegen icmp_eq(and(x, maskbit), maskbit) vs icmp_ne(and(x, maskbit), 0)

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Apr 30 07:41:23 PDT 2019


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

            Bug ID: 41672
           Summary: [X86] Different codegen
                    icmp_eq(and(x,maskbit),maskbit) vs
                    icmp_ne(and(x,maskbit),0)
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: llvm-dev at redking.me.uk
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, spatel+llvm at rotateright.com

As mentioned on https://reviews.llvm.org/D61189

when performing bit tests:

  icmp_eq(and(x,maskbit),maskbit)

gives different results to:

  icmp_ne(and(x,maskbit),0):

https://godbolt.org/z/78ko0B

define i32 @test(<4 x i32> %a0) {
    %1  = icmp slt <4 x i32> %a0, zeroinitializer
    %2  = bitcast <4 x i1> %1 to i4
    %3  = zext i4 %2 to i32
    %4  = and i32 %3, 1
    %5  = and i32 %3, 2
    %6  = icmp eq i32 %4, 1
    %7  = icmp eq i32 %5, 2
    %8  = zext i1 %6 to i32
    %9  = zext i1 %7 to i32
    %10 = and i32 %8, %9
    ret i32 %10
}

define i32 @cmp0(<4 x i32> %a0) {
    %1  = icmp slt <4 x i32> %a0, zeroinitializer
    %2  = bitcast <4 x i1> %1 to i4
    %3  = zext i4 %2 to i32
    %4  = and i32 %3, 1
    %5  = and i32 %3, 2
    %6  = icmp ne i32 %4, 0
    %7  = icmp ne i32 %5, 0
    %8  = zext i1 %6 to i32
    %9  = zext i1 %7 to i32
    %10 = and i32 %8, %9
    ret i32 %10
}


test:
  vmovmskps %xmm0, %ecx
  xorl %eax, %eax
  notl %ecx
  testb $3, %cl
  sete %al
  retq

cmp0:
  vmovmskps %xmm0, %ecx
  movl %ecx, %eax
  andl $2, %eax
  shrl %eax
  andl %ecx, %eax
  retq

-- 
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/20190430/227e37fe/attachment.html>


More information about the llvm-bugs mailing list