To see where the popcnt instructions go, let's insert one in a place where we can easily find it back.
Add a few lines to main.c:
Code: Select all
(...)
#include "bitcount.h"
int main(int argc, char* argv[]) {
std::cout << "popcount(123456) = " << popcount<Full>(123456) << std::endl;
std::cout << engine_info() << std::endl;
(...)
Now compile and dump the output of otool to a text file (otool stockfish >assembly.txt).
Load the text file into an editor and look either for main or for $0x1e240 (which is 123456):
Code: Select all
000000000040b820 <main>:
40b820: 55 push %rbp
40b821: 48 89 e5 mov %rsp,%rbp
40b824: 41 57 push %r15
40b826: 41 56 push %r14
40b828: 41 55 push %r13
40b82a: 41 54 push %r12
40b82c: 53 push %rbx
40b82d: bb 40 e2 01 00 mov $0x1e240,%ebx
40b832: f3 48 0f b8 db popcnt %rbx,%rbx
This is from objdump, so with otool it will look a bit different, but it shouldn't be hard to locate this part.
With make profile-build I get (gcc 4.8.1, on Linux):
Code: Select all
000000000040b1a0 <main>:
40b1a0: 55 push %rbp
40b1a1: 48 89 e5 mov %rsp,%rbp
40b1a4: 41 57 push %r15
40b1a6: 41 56 push %r14
40b1a8: 41 55 push %r13
40b1aa: 41 54 push %r12
40b1ac: 53 push %rbx
40b1ad: bb 40 e2 01 00 mov $0x1e240,%ebx
40b1b2: f3 4c 0f b8 e3 popcnt %rbx,%r12
So practically the same.