fabs not being inlined?

9il ilyayaroshenko at gmail.com
Fri Feb 8 12:33:47 UTC 2019


On Thursday, 7 February 2019 at 23:26:20 UTC, NaN wrote:
> module ohreally;
>
> import std.math;
>
> float foo(float y, float x)
> {
>     float ax = fabs(x);
>     float ay = fabs(y);
>     return ax*ay/3.142f;
> }
>
> ====>
>
> float ohreally.foo(float, float):
>         push    rax
>         movss   dword ptr [rsp + 4], xmm1
>         call    pure nothrow @nogc @safe float 
> std.math.fabs(float)@PLT
>         movss   dword ptr [rsp], xmm0
>         movss   xmm0, dword ptr [rsp + 4]
>         call    pure nothrow @nogc @safe float 
> std.math.fabs(float)@PLT
>         mulss   xmm0, dword ptr [rsp]
>         divss   xmm0, dword ptr [rip + .LCPI0_0]
>         pop     rax
>         ret
>
> Compiled with -O3
>
> Is there something I need to do to get fabs() inlined?

Try also mir-core DUB package. It has mir.math package, fabs will 
be inlined in -O builds without any additional flags.
http://code.dlang.org/packages/mir-core


More information about the digitalmars-d-ldc mailing list