pragma(inline, true) errors?

Steven Schveighoffer schveiguy at gmail.com
Thu Apr 1 19:21:31 UTC 2021


On 4/1/21 3:13 PM, tsbockman wrote:
> On Thursday, 1 April 2021 at 18:38:45 UTC, Steven Schveighoffer wrote:
>> Here is a relevant run.dlang.io snippet: https://run.dlang.io/is/UEtyE8
>>
>> Some interesting things about this:
>>
>> 1. With -w, I get no errors.
>> 2. With -wi, I get a warning that the function can be inlined
>> 3. Using ASM view, it appears the function is NOT inlined in either case.
> 
> DMD's inliner often gets confused by multiple `return` statements. The 
> solution is to either convert to single-`return` style, or use LDC/GDC 
> which do not have this problem.
> 
> ```D
> extern(C) pragma(inline, true) static float EaseBounceOut(float t, float 
> b, float c, float d)
> {
>     float ret;
>     if ((t/=d) < (1.0f/2.75f))
>     {
>         ret = (c*(7.5625f*t*t) + b);
>     }
>     else if (t < (2.0f/2.75f))
>     {
>         float postFix = t-=(1.5f/2.75f);
>         ret = (c*(7.5625f*(postFix)*t + 0.75f) + b);
>     }
>     else if (t < (2.5/2.75))
>     {
>         float postFix = t-=(2.25f/2.75f);
>         ret = (c*(7.5625f*(postFix)*t + 0.9375f) + b);
>     }
>     else
>     {
>         float postFix = t-=(2.625f/2.75f);
>         ret = (c*(7.5625f*(postFix)*t + 0.984375f) + b);
>     }
>     return ret;
> }
> ```

Yeah, I'm not too concerned with the fact that this can't be inlined, 
though I probably should just remove that from the lib (looks like that 
was a recent addition).

I'm more concerned with the larger issue that it's not doing what it 
says it should be doing.

> (I have no comment on the larger issues that you raised. Also, hurray 
> for rich text formatting!)

Grrrr... I want formatting too :(. Vladimir, we need an X-DFormat = 
markdown header or something I can use in Thunderbird.

-Steve


More information about the Digitalmars-d mailing list