[llvm-bugs] [Bug 41638] New: [X86] Avoid XOR $0, %al in parity generation

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Apr 28 03:40:56 PDT 2019


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: 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 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190428/6beb58ec/attachment.html>


More information about the llvm-bugs mailing list