Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[x86] parity op gets transformed to popcount #51435

Closed
rotateright opened this issue Oct 6, 2021 · 6 comments
Closed

[x86] parity op gets transformed to popcount #51435

rotateright opened this issue Oct 6, 2021 · 6 comments
Assignees
Labels
backend:X86 bugzilla Issues migrated from bugzilla

Comments

@rotateright
Copy link
Contributor

Bugzilla Link 52093
Resolution FIXED
Resolved on Oct 06, 2021 14:41
Version trunk
OS All
CC @topperc,@RKSimon,@phoebewang,@rotateright
Fixed by commit(s) 58b68e7

Extended Description

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.

@rotateright
Copy link
Contributor Author

assigned to @topperc

@rotateright
Copy link
Contributor Author

This example is derived from the post-commit discussion in:
https://reviews.llvm.org/D110170

@topperc
Copy link
Collaborator

topperc commented Oct 6, 2021

Can I take this?

@rotateright
Copy link
Contributor Author

Can I take this?

Sure!

@topperc
Copy link
Collaborator

topperc commented Oct 6, 2021

Candidate patch https://reviews.llvm.org/D111249

@topperc
Copy link
Collaborator

topperc commented Oct 6, 2021

Should be fixed after 58b68e7

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:X86 bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

2 participants