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

            Bug ID: 41638
           Summary: [X86] Avoid XOR $0, %al in parity generation
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]

As mentioned in https://reviews.llvm.org/D61230, the parity codegen in bool
vector xor reduction is generating "xor $0, $al" but it would be better to use
"test %al, %al" or "or %al, %al" or "and %al, %al" which gives a shorter
encoding since there would be no immediate.

define i1 @trunc_v2i64_v2i1(<2 x i64>) {
; SSE-LABEL: trunc_v2i64_v2i1:
; SSE:       # %bb.0:
; SSE-NEXT:    psllq $63, %xmm0
; SSE-NEXT:    movmskpd %xmm0, %eax
; SSE-NEXT:    xorb $0, %al
; SSE-NEXT:    setnp %al
; SSE-NEXT:    retq
;
; AVX-LABEL: trunc_v2i64_v2i1:
; AVX:       # %bb.0:
; AVX-NEXT:    vpsllq $63, %xmm0, %xmm0
; AVX-NEXT:    vmovmskpd %xmm0, %eax
; AVX-NEXT:    xorb $0, %al
; AVX-NEXT:    setnp %al
; AVX-NEXT:    retq
;
; AVX512BW-LABEL: trunc_v2i64_v2i1:
; AVX512BW:       # %bb.0:
; AVX512BW-NEXT:    vpsllq $63, %xmm0, %xmm0
; AVX512BW-NEXT:    vptestmq %zmm0, %zmm0, %k0
; AVX512BW-NEXT:    kmovd %k0, %eax
; AVX512BW-NEXT:    andl $3, %eax
; AVX512BW-NEXT:    xorb $0, %al
; AVX512BW-NEXT:    setnp %al
; AVX512BW-NEXT:    vzeroupper
; AVX512BW-NEXT:    retq
;
; AVX512VL-LABEL: trunc_v2i64_v2i1:
; AVX512VL:       # %bb.0:
; AVX512VL-NEXT:    vpsllq $63, %xmm0, %xmm0
; AVX512VL-NEXT:    vptestmq %xmm0, %xmm0, %k0
; AVX512VL-NEXT:    kmovd %k0, %eax
; AVX512VL-NEXT:    andl $3, %eax
; AVX512VL-NEXT:    xorb $0, %al
; AVX512VL-NEXT:    setnp %al
; AVX512VL-NEXT:    retq
  %a = trunc <2 x i64> %0 to <2 x i1>
  %b = call i1 @llvm.experimental.vector.reduce.xor.v2i1(<2 x i1> %a)
  ret i1 %b
}
declare i1 @llvm.experimental.vector.reduce.xor.v2i1(<2 x i1>)

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

Reply via email to