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

            Bug ID: 46448
           Summary: Codegen difference for anyof idioms
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedb...@nondot.org
          Reporter: listm...@philipreames.com
                CC: craig.top...@gmail.com, llvm-bugs@lists.llvm.org,
                    llvm-...@redking.me.uk, spatel+l...@rotateright.com

The following examples return true if at least one of the two 64 bit values are
zero.  This was derived from an example performing null checks on pointers, but
the pointer bits don't appear to be relevant.  

At the moment, we generate different code for these two examples, and do not
canonicalize one to the other at IR.  I don't know which of the two outputs is
better, but we clearly should be generating one output for both examples.

;; EITHER is zero
define i1 @test_v1(<2 x i64>* %p) {
   %int.vec = load <2 x i64>, <2 x i64>* %p
   %cmp = icmp eq <2 x i64> %int.vec, zeroinitializer
   %cmp.cast = bitcast <2 x i1> %cmp to i2
   %cmp2 = icmp ne i2 %cmp.cast, 0
   ret i1 %cmp2
}

;; EITHER is zero
define i1 @test_v2(<2 x i64>* %p) {
   %int.vec = load <2 x i64>, <2 x i64>* %p
   %reduce = call i64 @llvm.experimental.vector.reduce.and.v2i64(<2 x i64>
%int.vec)
   %cmp = icmp ne i64 %reduce, 0
   ret i1 %cmp
}

llc -O3 < input.ll -mcpu=skylake

test_v1:                                # @test_v1
        vpxor   %xmm0, %xmm0, %xmm0
        vpcmpeqq        (%rdi), %xmm0, %xmm0
        vmovmskpd       %xmm0, %eax
        testb   %al, %al
        setne   %al
        retq
test_v2:                                # @test_v2
        vpbroadcastq    8(%rdi), %xmm0
        vpand   (%rdi), %xmm0, %xmm0
        vmovq   %xmm0, %rax
        testq   %rax, %rax
        setne   %al
        retq

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to