pcg-c-basic
pcg-c-basic copied to clipboard
Optimize `pcg32_random_r` utilizing more instruction level parallelism
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).