Loop optimization

bearophile bearophileHUGS at lycos.com
Mon May 17 15:07:58 PDT 2010


Walter Bright:

>In my view, such switches are bad news, because:<

The Intel compiler, Microsoft compiler, GCC and LLVM have a similar switch (fp:fast in the Microsoft compiler, -ffast-math on GCC, etc). So you might send your list of comments to the devs of each of those four compilers.

I have used the "unsafe fp" switch in LDC to run faster my small raytracers, with good results. So I use it now and then where max precision is not important and small errors are not going to ruin the output.

I have asked the LLVM head developer to improve this optimization on LLVM, because in my opinion it's not aggressive enough, to put LLVM on par with GCC. So LDC too will probably get better on this, in future. This unsafe optimization is off on default, so if you don't like it you can avoid it. Its presence in LDC has caused zero problems to me so far in LDC (because when I need safer/more precise results I don't use it).


>4. most of those optimizations can be done by hand if you want to, meaning that then their behavior will be reliable, portable and correct for your application<

This is true for any optimization.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list