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

Don't use std::popcount (workaround) #8098

Merged
merged 1 commit into from Apr 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/PPUTranslator.cpp
Expand Up @@ -236,7 +236,7 @@ Type* PPUTranslator::ScaleType(Type* type, s32 pow2)

uint scaled = type->getScalarSizeInBits();

verify(HERE), std::popcount(scaled) == 1;
verify(HERE), (scaled & (scaled - 1)) == 0;

if (pow2 > 0)
{
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Memory/vm.cpp
Expand Up @@ -1182,7 +1182,7 @@ namespace vm
if (is_write)
std::swap(src, dst);

if (size <= 16 && std::popcount(size) == 1 && (addr & (size - 1)) == 0)
if (size <= 16 && (size & (size - 1)) == 0 && (addr & (size - 1)) == 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (size <= 16 && (size & (size - 1)) == 0 && (addr & (size - 1)) == 0)
if (size <= 16 && ((size | addr) & (size - 1)) == 0)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is little point to optimize it by hand (the outcome is the same), it only hurts readability due to mixing two different checks.

{
if (is_write)
{
Expand Down