Has someone encountered similar issues with -cov?

Johan Engelen via Digitalmars-d digitalmars-d at puremagic.com
Sat Jul 2 08:30:36 PDT 2016


On Saturday, 2 July 2016 at 14:03:29 UTC, Andrei Alexandrescu 
wrote:
>
> Nice, thanks. I've tried to not rely too much on mixing 
> statically-known and dynamically-known Boolean expressions. Can 
> I safely assume that all compilers will generate good code for 
> such?

I'd be very surprised if not (especially with statically-known 
booleans upfront in the expression).

I get this for opCast!(short, int)(int):

asm.dlang.org ("-O -inline")
     push   %rax
     mov    %rdi,%rcx
     movswl %cx,%eax
     cmp    %ecx,%eax
     jne    label1
     mov    %rdi,%rax
     jmp    label2
     label1:
     xor    %eax,%eax
     label2:
     pop    %rcx
     retq

LDC trunk (-O3)  (identical code for your and my version)
     movswl  %di, %eax
     cmpl      %edi, %eax
     jne         LBB2_1
     movswl  %di, %eax
     retq
     LBB2_1:
     xorl        %eax, %eax
     retq

Define "good" ;-) ;-)

PS: you can look at LDC's annotated asm output with "-c 
-output-s".



More information about the Digitalmars-d mailing list