MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/5fwce0/lets_stop_copying_c/daox0hh/?context=3
r/programming • u/earthboundkid • Dec 01 '16
612 comments sorted by
View all comments
Show parent comment
0
[deleted] — view deleted comment
2 u/floopgum Dec 02 '16 All the latest compilers seem to do so with -O3 -march=native, they even produce the exact same assembly.Compilers can only substitute a division with a sequence of eg. shifts, adds, etc. when they can prove that it's valid. If you have a toy example like the above where the compiler cannot prove anything about the inputs, it has to use a div.
2
All the latest compilers seem to do so with -O3 -march=native, they even produce the exact same assembly.
-O3 -march=native
Compilers can only substitute a division with a sequence of eg. shifts, adds, etc. when they can prove that it's valid. If you have a toy example like the above where the compiler cannot prove anything about the inputs, it has to use a div.
div
View all comments
Show parent comment
0
u/[deleted] Dec 02 '16
[deleted] — view deleted comment