all repos — mgba @ 9abe700d37c5453eb735548d0a19bbfce9545279

mGBA Game Boy Advance Emulator

Use GCC popcount intrinsic for popcount
Jeffrey Pfau jeffrey@endrift.com
Tue, 21 Oct 2014 22:51:39 -0700
commit

9abe700d37c5453eb735548d0a19bbfce9545279

parent

537480b940f5a030344b3e0ccd77752fb519a326

1 files changed, 2 insertions(+), 10 deletions(-)

jump to
M src/gba/gba-memory.csrc/gba/gba-memory.c

@@ -571,11 +571,7 @@ int offset = 4;

int popcount = 0; if (direction & LSM_D) { offset = -4; - for (i = 0; i < 16; ++i) { - if (mask & (1 << i)) { - ++popcount; - } - } + popcount = __builtin_popcount(mask); address -= (popcount << 2) - 4; }

@@ -678,11 +674,7 @@ int offset = 4;

int popcount = 0; if (direction & LSM_D) { offset = -4; - for (i = 0; i < 16; ++i) { - if (mask & (1 << i)) { - ++popcount; - } - } + popcount = __builtin_popcount(mask); address -= (popcount << 2) - 4; }