[Issue 23857] backend inliner takes too long on recursive function call

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Apr 24 19:58:23 UTC 2023


https://issues.dlang.org/show_bug.cgi?id=23857

Dennis <dkorpel at live.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |backend
                 CC|                            |dkorpel at live.nl
           Hardware|x86_64                      |All
            Summary|Compilation of certain      |backend inliner takes too
                   |recursion takes too long    |long on recursive function
                   |                            |call
                 OS|Linux                       |All

--- Comment #1 from Dennis <dkorpel at live.nl> ---
This is a problem with the dmd's backend inliner recursively trying to inline
f. `-release` is needed to remove bounds checks, otherwise it doesn't inline
it. By using .ptr on a, the -release switch is not needed. Reduced a bit
further:

```D
int f(int[] a, int u) 
{
    return (a.ptr[u] < 0) ? u : (a.ptr[u] = f(a, a.ptr[u]));
}

void main() 
{
    f([], 0);
    f([], 0);
}
```

--


More information about the Digitalmars-d-bugs mailing list