View mode: basic / threaded / horizontal-split · Log in · Help
February 24, 2013
Are there any default dmd optimizations
Does the compiler inline any function even without -inline?

What level of optimization is applied even without -O? One that comes to 
mind is the elision of certain struct object copies. Is such an 
optimization applied without -O? If so, are there similar other 
optimizations?

Thank you,
Ali
February 24, 2013
Re: Are there any default dmd optimizations
24-Feb-2013 04:14, Ali Çehreli пишет:
> Does the compiler inline any function even without -inline?
>
> What level of optimization is applied even without -O? One that comes to
> mind is the elision of certain struct object copies. Is such an
> optimization applied without -O? If so, are there similar other
> optimizations?
>

AFAIK NRVO/RVO are working w/o -O switch and are performed in the 
front-end (for better or worse).

> Thank you,
> Ali
>


-- 
Dmitry Olshansky
February 24, 2013
Re: Are there any default dmd optimizations
On 02/23/2013 10:53 PM, Dmitry Olshansky wrote:
> 24-Feb-2013 04:14, Ali Çehreli пишет:
>> Does the compiler inline any function even without -inline?
>>
>> What level of optimization is applied even without -O? One that comes to
>> mind is the elision of certain struct object copies. Is such an
>> optimization applied without -O? If so, are there similar other
>> optimizations?
>>
>
> AFAIK NRVO/RVO are working w/o -O switch and are performed in the
> front-end (for better or worse).

Makes sense that they are performed in the front-end because NRVO and 
RVO and defined at language level in C++ as well.

I will strongly :) assume that no function is inlined unless the -inline 
switch is used.

Ali
February 24, 2013
Re: Are there any default dmd optimizations
On Sunday, 24 February 2013 at 00:14:14 UTC, Ali Çehreli wrote:
> Does the compiler inline any function even without -inline?
>
> What level of optimization is applied even without -O? One that 
> comes to mind is the elision of certain struct object copies. 
> Is such an optimization applied without -O? If so, are there 
> similar other optimizations?
>
> Thank you,
> Ali

I would bet for register promotions, dead read/write eliminations 
and alike. I don't expect inline to be part of it.
February 24, 2013
Re: Are there any default dmd optimizations
On Sunday, February 24, 2013 08:58:38 deadalnix wrote:
> I would bet for register promotions, dead read/write eliminations
> and alike. I don't expect inline to be part of it.

It would actually be problematic if it were, because it would screw with 
debugging.

- Jonathan M Davis
February 24, 2013
Re: Are there any default dmd optimizations
On Sunday, 24 February 2013 at 08:16:37 UTC, Jonathan M Davis 
wrote:
> On Sunday, February 24, 2013 08:58:38 deadalnix wrote:
>> I would bet for register promotions, dead read/write 
>> eliminations
>> and alike. I don't expect inline to be part of it.
>
> It would actually be problematic if it were, because it would 
> screw with
> debugging.
>
> - Jonathan M Davis

Does disabling optimization imply debug build ?
February 24, 2013
Re: Are there any default dmd optimizations
On Sunday, February 24, 2013 09:33:12 deadalnix wrote:
> On Sunday, 24 February 2013 at 08:16:37 UTC, Jonathan M Davis
> 
> wrote:
> > On Sunday, February 24, 2013 08:58:38 deadalnix wrote:
> >> I would bet for register promotions, dead read/write
> >> eliminations
> >> and alike. I don't expect inline to be part of it.
> > 
> > It would actually be problematic if it were, because it would
> > screw with
> > debugging.
> > 
> > - Jonathan M Davis
> 
> Does disabling optimization imply debug build ?

Well, there are three aspects to what usually is meant by a debug build:

1. Debug symbols are compiled in.

2. Optimizations are not enabled.

3. Assertions _are_ enabled.

For dmd, the first one is controlled by -g and -gc, the second one is 
controlled by -O (and probably to some extent by -release), and the third one 
is controlled by -release (and to some extent -noboundscheck). But what it 
actually means for a build to be "debug" or "release" really isn't all that 
well defined. It pretty much just boils down to one of them being compiled for 
debugging and development purposes, whereas the other is what's used in 
released code. In general though, when people compile release builds, they use 
all of the various flags for enabling optimizations and disabling debug symbols 
and assertions, whereas when they compile debug builds, they disable all 
optimizations and enable debugging symbols and assertions.

But as for inlining, enabling it (or any other optimizations) screw with 
debugging, so they shouldn't be used with any builds which are intended for 
debugging, and with the way most compilers' flags work, optimizations aren't 
enabled unless you ask for them, making debug builds the default.

- Jonathan M Davis
February 24, 2013
Re: Are there any default dmd optimizations
On 2013-02-24 09:43, Jonathan M Davis wrote:

> Well, there are three aspects to what usually is meant by a debug build:
>
> 1. Debug symbols are compiled in.
>
> 2. Optimizations are not enabled.
>
> 3. Assertions _are_ enabled.
>
> For dmd, the first one is controlled by -g and -gc, the second one is
> controlled by -O (and probably to some extent by -release), and the third one
> is controlled by -release (and to some extent -noboundscheck). But what it
> actually means for a build to be "debug" or "release" really isn't all that
> well defined. It pretty much just boils down to one of them being compiled for
> debugging and development purposes, whereas the other is what's used in
> released code. In general though, when people compile release builds, they use
> all of the various flags for enabling optimizations and disabling debug symbols
> and assertions, whereas when they compile debug builds, they disable all
> optimizations and enable debugging symbols and assertions.
>
> But as for inlining, enabling it (or any other optimizations) screw with
> debugging, so they shouldn't be used with any builds which are intended for
> debugging, and with the way most compilers' flags work, optimizations aren't
> enabled unless you ask for them, making debug builds the default.

Then there's the -debug flag as well.

-- 
/Jacob Carlborg
February 24, 2013
Re: Are there any default dmd optimizations
On Sunday, February 24, 2013 13:07:39 Jacob Carlborg wrote:
> On 2013-02-24 09:43, Jonathan M Davis wrote:
> > Well, there are three aspects to what usually is meant by a debug build:
> > 
> > 1. Debug symbols are compiled in.
> > 
> > 2. Optimizations are not enabled.
> > 
> > 3. Assertions _are_ enabled.
> > 
> > For dmd, the first one is controlled by -g and -gc, the second one is
> > controlled by -O (and probably to some extent by -release), and the third
> > one is controlled by -release (and to some extent -noboundscheck). But
> > what it actually means for a build to be "debug" or "release" really
> > isn't all that well defined. It pretty much just boils down to one of
> > them being compiled for debugging and development purposes, whereas the
> > other is what's used in released code. In general though, when people
> > compile release builds, they use all of the various flags for enabling
> > optimizations and disabling debug symbols and assertions, whereas when
> > they compile debug builds, they disable all optimizations and enable
> > debugging symbols and assertions.
> > 
> > But as for inlining, enabling it (or any other optimizations) screw with
> > debugging, so they shouldn't be used with any builds which are intended
> > for
> > debugging, and with the way most compilers' flags work, optimizations
> > aren't enabled unless you ask for them, making debug builds the default.
> 
> Then there's the -debug flag as well.

Yeah, which just adds the confusion, because all it does is enable debug bocks 
and isn't at all what people normal mean by "debug mode" (though it would make 
sense to use -debug in "debug mode"). The -debug flag is why I generally end up 
talking about release mode and non-release mode in D rather than release vs 
debug, as release mode has far more to do with -release than -debug. Heck, you 
can technically enable -debug with -release and full optimizations turned on. 
So, useful as -debug may be, its name confuses things.

- Jonathan M Davis
February 24, 2013
Re: Are there any default dmd optimizations
On 2/24/13, Jonathan M Davis <jmdavisProg@gmx.com> wrote:
> Yeah, which just adds the confusion, because all it does is enable debug
> bocks.

The feature almost doesn't pay its weight. I mean technically you can
use -version=Debug and then use version(Debug) blocks. All `debug`
does is saves a little bit of typing.
« First   ‹ Prev
1 2 3 4 5
Top | Discussion index | About this forum | D home