3 ms·
Are compiler optimizations like summing a series done on an ad-hoc basis? Certainly the compiler couldn’t have discovered or inferred (not sure what term to use
by incadenza 7y ago
Are compiler optimizations like summing a series done on an ad-hoc basis? Certainly the compiler couldn’t have discovered or inferred (not sure what term to use) that formula, no?
Just generally curious.
- kibwen 7y agoThose optimizations are happening on LLVM's end (though the higher-level language will have to expose sufficiently transparent abstractions to make these optimizations possible). I'd love to read a book on the optimization techniques that are implemented in LLVM/GCC to make transformations like this possible.
- incadenza 7y agoGotcha. Thanks. So presumably Clang would have done the same for C?
- danieldk 7y agoEasy to check, thanks to godbolt: https://godbolt.org/z/SopXnf https://godbolt.org/z/SopXnf
- steveklabnik 7y agoYes, and it's mentioned in the post that the C code was also brought into parity.
- incadenza 7y agoYeah I saw that, but just wasn’t sure how using intrinsics played a role.
- exacube 7y agoAd-hoc basis. Usually comes out of studying the most common classes of computation and optimizing for it. For example, the "summing a series" probably falls out of loop optimizations: https://en.wikipedia.org/wiki/Loop_optimization https://en.wikipedia.org/wiki/Loop_optimization