inlining...

Manu turkeyman at gmail.com
Wed Mar 19 19:07:33 PDT 2014


On 20 March 2014 06:23,
<7d89a89974b0ff40.invalid at internationalized.invalid>wrote:

> On Wednesday, 19 March 2014 at 12:35:30 UTC, Manu wrote:
>
>> Okay, do you have use cases for any of this stuff? Are you just making it
>> up, or do you have significant experience to say this is what you need?
>>
>
> I don't need anything, I hand optimize prematurely. And I don't want to do
> that.
>
> But yes, inner loops benefits from exhaustive inlining because you get to
> move common expressions out of the loop or change them to delta increments.
> It is only when you trash the caches that inlining does not pay off.
>
> I do it by hand. I don't want to do it by hand.
>
>
>  If you ask me, I have no value in recursive inlining, infact, that would
>> anger me considerably.
>>
>
> Why? You could always set the depth to 1, or make 1 the default.
>
> And it isn't difficult to implement.
>

The problem is upside down. If you want to inline multiple levels, you
start from the leaves and move downwards, not from the root moving upwards
(leaving a bunch of leaves perhaps not inlined), which is what you're
really suggesting.
Inlining should be strictly deliberate, there's nothing to say that every
function called in a tree should be inlined. There's a high probability
there's one/some that shouldn't be among a few that should.

Remember too, that call-site inlining isn't the only method, there would
also be always-inline. I think always-inline is what you want for some
decidedly trivial functions (although these will probably be heuristically
inlined anyway), not call-site inlining. I just don't see how recursive
call-site inlining is appropriate, considering that call trees are often
complex, subject to change, and may even call functions that you don't have
source for. You can cascade the mixin keyword if you want to, that's very
simple. I'd be highly surprised if you ever encountered a call tree where
you wanted to inline everything (and the optimiser didn't do it for you).
As soon as you encounter a single function in the tree that shouldn't be
inlined, then you'll be forced to do it one level at a time anyway.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20140320/f2fa4491/attachment.html>


More information about the Digitalmars-d mailing list