-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
__builtin_popcount(~a) & 1 - > __builtin_popcount(a) & 1 #49440
Comments
Hm... If we have this transformation: define i8 @src(i8 %0) { Then int tgt(unsigned int a) is nicely optimised to tgt(unsigned int): # @tgt(unsigned int) @spatel, replace xor with sub, WDYT? |
int A(unsigned int a) int B(unsigned int a) A(unsigned int): # @A(unsigned int) |
We really should have this folding to "not" in IR: ...because a 'not' is better for analysis than a 'sub'. If that causes a regression on the parity pattern, we should add another fold for that. I'll take a look. |
https://reviews.llvm.org/rGe10d7d455d4e Please check if that solves the motivating cases. We probably still want the sub->not transform, but if it is not showing up, it may not be that important - can either keep this open to track that or open another report. |
Thanks. I will close this PR and create new one. |
mentioned in issue llvm/llvm-bugzilla-archive#50104 |
Extended Description
define i32 @src(i32 %0) noread nowrite nofree {
%1:
%2 = xor i32 %0, 4294967295
%3 = ctpop i32 %2
%4 = and i32 %3, 1
ret i32 %4
}
=>
define i32 @tgt(i32 %0) noread nowrite nofree {
%1:
%2 = ctpop i32 %0
%3 = and i32 %2, 1
ret i32 %3
}
Transformation seems to be correct!
https://godbolt.org/z/hGoxxYYd6
The text was updated successfully, but these errors were encountered: