[llvm-bugs] [Bug 52093] New: [x86] parity op gets transformed to popcount
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Oct 6 10:06:56 PDT 2021
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: unassignedbugs at nondot.org
Reporter: spatel+llvm at rotateright.com
CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
llvm-dev at redking.me.uk, pengfei.wang at intel.com,
spatel+llvm at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211006/10cc23c8/attachment.html>
More information about the llvm-bugs
mailing list