tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] manually inlining functions


From: Vincent Lefevre
Subject: Re: [Tinycc-devel] manually inlining functions
Date: Sat, 1 May 2021 17:35:27 +0200
User-agent: Mutt/2.0.6+169 (acb2bdd4) vl-137001 (2021-04-28)

On 2021-04-30 20:50:36 -0700, Elijah Stone wrote:
> On Sat, 1 May 2021, Yakov wrote:
> 
> > having to write macros for performance feels so obsolete, double
> > evaluation hiding in dark corners etc. And function calls are so
> > expensive in tight loops.
> 
> Calls are fairly cheap, on modern architectures.  The performance impact of
> an inliner would be fairly marginal for tcc, compared with, say, a register
> allocator.

Inline functions have (at least) 3 advantages:

1. They eliminate the call, which is rather useful in case a call
   to a function of a shared library, as such calls can be very
   expensive. For very simple functions (e.g. accessing a field
   of a structure), there would be much overhead.

2. With the inline definition, the compiler can know what the function
   does (e.g. enabling value range propagation), so that it may be
   able optimize the code around.

3. A call to an inline function may have specific arguments, such
   as constant ones, so that the compiler may be able to optimize
   the code of the instantiated function, e.g. avoiding tests and
   eliminating dead code via constant propagation.

I think that tcc could benefit from these 3 points.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]