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

            Bug ID: 36702
           Summary: llvm.experimental.reduce.{and, any} don't lower
                    properly for boolean vectors
           Product: new-bugs
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedb...@nondot.org
          Reporter: gonzalob...@gmail.com
                CC: chandl...@gmail.com, llvm-bugs@lists.llvm.org

I'd expect a way to be able to lower llvm.experimental.vector.reduce.and to
@llvm.x86.sse2.pmovmskb.128 on x86_64 and similar instructions in other
architectures when the input vectors are boolean vectors, that is, when their
lanes have either all bits cleared, or set. The same applies to
llvm.experimental.vector.reduce.any.

For example (thanks Chandler for coming up with this):

declare i1 @llvm.experimental.vector.reduce.and.i1.v16i1(<16 x i1>)
declare void @llvm.assume(i1)
declare void @a()
declare void @b()
define void @stdsimd_all_8x16(<16 x i8>* noalias nocapture dereferenceable(16)
%ptr) unnamed_addr #0 {
  %v = load <16 x i8>, <16 x i8>* %ptr, align 16
  %t = trunc <16 x i8> %v to <16 x i1>
  %e1 = sext <16 x i1> %t to <16 x i8>
  %e2 = icmp eq <16 x i8> %v, %e1
  %e3 = call i1 @llvm.experimental.vector.reduce.and.i1.v16i1(<16 x i1> %e2)
  call void @llvm.assume(i1 %e3)
  %x = call i1 @llvm.experimental.vector.reduce.and.i1.v16i1(<16 x i1> %t)
  br i1 %x, label %a, label %b
a:
  call void @a()
  ret void
b:
  call void @b()
  ret void
}

should emit:

 push    rbp
 mov     rbp, rsp
 movdqa  xmm0, xmmword, ptr, [rdi]
 pmovmskb eax, xmm0
 cmp     eax, 65535
 sete    al
 pop     rbp
 ret

and replacing "reduce.and" with "reduce.any" should emit:

 push    rbp
 mov     rbp, rsp
 movdqa  xmm0, xmmword, ptr, [rdi]
 pmovmskb eax, xmm0
 test    eax, eax
 setne   al
 pop     rbp
 ret

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

Reply via email to