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

            Bug ID: 52093
           Summary: [x86] parity op gets transformed to popcount
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedb...@nondot.org
          Reporter: spatel+l...@rotateright.com
                CC: craig.top...@gmail.com, llvm-bugs@lists.llvm.org,
                    llvm-...@redking.me.uk, pengfei.w...@intel.com,
                    spatel+l...@rotateright.com

define i32 @xor4_popcount(i32 %x) {
  %m = and i32 %x, 15
  %p = tail call i32 @llvm.ctpop.i32(i32 %m)
  %r = and i32 %p, 1
  ret i32 %r
}

declare i32 @llvm.ctpop.i32(i32)

--------------------------------------------------------------------
% llc -o - pop.ll              
        xorl    %eax, %eax
        testb   $15, %dil
        setnp   %al

% llc -o - pop.ll -mattr=popcnt
        andl    $15, %edi
        popcntl %edi, %eax
        andl    $1, %eax

--------------------------------------------------------------------

Debug spew shows that we convert to a parity node either way, but then convert
back to ctpop for a target that supports that instruction.

Test and set likely has better latency/throughput than popcnt + 2 mask
instructions on all recent x86 CPUs.

-- 
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