poor codegen for abs(), and div by literal?

NaN divide at by.zero
Fri Feb 8 00:21:38 UTC 2019


On Thursday, 7 February 2019 at 23:35:36 UTC, H. S. Teoh wrote:
> On Thu, Feb 07, 2019 at 11:15:08PM +0000, NaN via Digitalmars-d 
> wrote:
>> Given the following code...
> [...]
>> the compiler outputs the following for the function body, 
>> (excluding
>> prolog and epilogue code)...
> [...]
>> So to do the abs(), it stores to memory from XMM reg, loads 
>> into x87 FPU regs, does the abs with the old FPU instruction, 
>> then for some reason stores the result as a double, loads that 
>> back into an XMM, converts it back to single.
>
> Which compiler are you using?
>
> For performance / codegen quality issues, I highly recommend 
> looking at the output of ldc or gdc, rather than dmd.  It's 
> well-known that dmd codegen tends to lag behind ldc/gdc as far 
> as efficiency / optimization is concerned.  These days, I don't 
> even look at dmd output anymore when I'm looking for 
> performance.  IME, dmd consistently produces code that's about 
> 20-30% slower than ldc or gdc produced code, sometimes even as 
> high as 40%.

I use LDC primarily, just that wasnt inlining the fabs calls, and 
figured I would check to see what DMD was doing and that was 
screwy in a different way.

Wasnt sure if it was something worth reporting but it looks like 
its a known issue from what kinke posted.






More information about the Digitalmars-d mailing list