[llvm-bugs] [Bug 46448] New: Codegen difference for anyof idioms

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 24 20:08:38 PDT 2020


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: unassignedbugs at nondot.org
          Reporter: listmail at philipreames.com
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, spatel+llvm at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200625/4e8e43b7/attachment.html>


More information about the llvm-bugs mailing list