Quote Originally Posted by flp1969 View Post
Code:
$ gcc -O2 -ffast-math -o sqrt-test sqrt-test.c
$ ./sqrt-test 1000000000
 sqrt( 1000000000 ) = 31622 (109 cycles)
isqrt( 1000000000 ) = 31622 (553 cycles)
So, without the proper optimizations, isqrt() is, indeed, faster.
Very interesting. I compiled without -ffast-math and I tested using no optimisations, -O2 and -O3. And for each option and 1073741822 iterations and timing using the time command (time ./a.out) and valgrind both showed sqrt() to be significantly faster on my i7-8700K. Just one of those things I guess.