3 ms·
The c code defines a function that returns the sum computed in the loop. This function is than run using Haskell's FFI. GCC has no way of knowing there is no si
by gizmo686 9y ago
The c code defines a function that returns the sum computed in the loop. This function is than run using Haskell's FFI. GCC has no way of knowing there is no side effects, because other code might link to it and use the result of the function.
GHC, in concept, does know that there are no side effects, but that would apply to all of the functions being tested. Further, since it is using a benchmarking library, I assume the authors of said library were aware of the issue, and wrote it in such a way as to force evalutation of the function.
https://gist.github.com/snoyberg/9b1c77b595c4adf90880213fc49f2a21#file-main-hs https://gist.github.com/snoyberg/9b1c77b595c4adf90880213fc49...