3 ms·
One of the cool things about god bolt is I get to share some of the (probably edge case) optimizations that llvm employs. Compare the following two for loops:
by archgoon 8y ago
One of the cool things about god bolt is I get to share some of the (probably edge case) optimizations that llvm employs.
Compare the following two for loops:
(gcc)
https://godbolt.org/z/bNbPmo https://godbolt.org/z/bNbPmo
(clang)
https://godbolt.org/z/QUPTGu https://godbolt.org/z/QUPTGu
Note that clang elides the loop and performs in constant time. Note also that changing the types of some of the variable signatures form long to int removes the optimization.