pcg-c-basic icon indicating copy to clipboard operation
pcg-c-basic copied to clipboard

Optimize `pcg32_random_r` utilizing more instruction level parallelism

Open xiver77 opened this issue 3 years ago • 0 comments

I had also sent you (the author) an email a while ago about the same issue.

The original code has a chain of shift -> xor -> shift, while the modified code has a chain of shift | shift -> xor. Two shifts can run in parallel.

Clang (14.0) does this optimization even with the original code, but GCC (12.1) doesn't, so it produces better code with manual optimization.

You can compare the machine code output (https://godbolt.org/z/5bMjdsYnf).

xiver77 avatar Jul 14 '22 14:07 xiver77