dmd: if still there

Rainer Schuetze via Digitalmars-d digitalmars-d at puremagic.com
Sun Sep 21 06:29:02 PDT 2014



On 19.09.2014 17:30, Daniel Murphy wrote:
> "Chris"  wrote in message news:kcsnboocxeykhknjljfl at forum.dlang.org...
>> Out of curiosity. dmd still produces the if statement, although it
>> ain't gonna happen. Same is true of "DoIt.yes". I know, it's an
>> unlikely and marginal example.
>
> No it doesn't, here's main:
>
>> _Dmain:
>> push RBP
>> mov RBP,RSP
>> mov EDI,1
>> call   _D7dump_if4doitFE7dump_if4DoItZv at PC32
>> xor EAX,EAX
>> pop RBP
>> ret
>> 0f1f
>> add [RAX],R8B
>> .text._Dmain ends
>
> See, no branches or comparisons.

The branch is still in the doIt function:

 > _D7dump_if4doitFE7dump_if4DoItZv:
 >          push    RBP
 >          mov    RBP,RSP
 >          sub    RSP,010h
 >          mov    -8[RBP],EDI
 >          cmp    dword ptr -8[RBP],0
 >          jne    L29

dmd didn't do any inlining at all. It is very restrained with inlining, 
you'll get much better results with GDC or LDC.


More information about the Digitalmars-d mailing list