On Thu, Jan 10, 2013 at 02:03:47AM +0100, David Nadlinger wrote: > On Thursday, 10 January 2013 at 00:40:21 UTC, Jonathan M Davis > wrote: > >So clearly, dmd does _not_ optimize out the loop. I have no idea what > >gdc and ldc do though. > > Wow, DMD doesn't optimize it away indeed, just confirmed that by a > look at the assembly.
I tested DMD on a loop containing assert(true);, and apparently that *is* optimized out with -O. So DMD does catch simpler cases of no-op loops. Probably the OP's code is a bit beyond DMD's optimizer to recognize as a no-op loop. > LDC does delete the loop though, starting at -O1, and I can't > imagine that GDC wouldn't as well. [...] Yeah, something like that would be a sitting duck for GCC's optimizer. T -- Claiming that your operating system is the best in the world because more people use it is like saying McDonalds makes the best food in the world. -- Carl B. Constantine
