On Sonntag, 17. Dezember 2017 22:00:43 CET Linus Torvalds wrote: > On Sun, Dec 17, 2017 at 4:38 AM, Berthold Stoeger > > <[email protected]> wrote: > > I tried to look at the assembler output and the first thing I noted is > > that we don't compile with -O2? Is that on purpose? > > I do think we should use -O2. In fact, we *do* use it for release builds: > > CMAKE_CXX_FLAGS_RELEASE:STRING=-O2 -DNDEBUG > CMAKE_C_FLAGS_RELEASE:STRING=-O2 -DNDEBUG > > but the DEBUG builds are done with just "-g". That's a mistake, in my > opinion.
Ok, that explains it. When I find time, I will try to find out how to change that. > Sure, -O2 *can* make debugging a bit harder in that it can remove some > trivial variables, but honestly, that's very rare, and it can go the > other way too. > > For example, for the kernel, unoptimized assembly is *so* stupid that > it's actually hard to debug, and we've never even supported it. We > don't have those kinds of low-level issues with subsurface, though. Indeed, the assembler output for a simple if-statement was absolute SIMD gibberish. This must be on purpose to help the optimizer, but it makes -O0 useless even for debug mode. > > Anyway, with -O3, the first case in plannernotes.h produces better code > > without casting to float. You could of course get the same result by > > replacing 1000.0 with 1000.0f, but this seems rather obscure. > > I would suggest strongly against -O3. > > It can improve things. It can also make things _much_ worse, and it's > generally not nearly as well tested as -O2. It tends to be where gcc > starts doing "unproven" optimizations. OT: Some compilers do funky things even with -O2. Infamous example: https://kristerw.blogspot.co.at/2017/09/why-undefined-behavior-may-call-never.html > Like "short", the only time "float" makes lots of sense is in > datastructures where size really really matters. Thanks, noted. Berthold _______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
