release mode optimization

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Jan 9 17:12:56 PST 2013


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


More information about the Digitalmars-d-learn mailing list