Re: [Tinycc-devel] manually inlining functions

2021-05-07 Thread Michael Matz
Hello, On Tue, 4 May 2021, uso ewin wrote: Tinycc handle inline function like if they were macro, so using inline in tcc always inline functions. That's not accurate. Inline functions in TCC are emitted like normal functions but only when there's reason to emit them (which are involved

Re: [Tinycc-devel] manually inlining functions

2021-05-01 Thread Vincent Lefevre
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

Re: [Tinycc-devel] manually inlining functions

2021-05-01 Thread Vincent Lefevre
On 2021-05-01 00:43:27 +, Kyryl Melekhin wrote: > Yakov wrote: > > > Kyryl you cannot inline everything because you will get code > > explosion, often infinite code explosion when functions have a > > circular dependency on each other. I am just talking about inlining > > certain functions

Re: [Tinycc-devel] manually inlining functions

2021-04-30 Thread Elijah Stone
On Sat, 1 May 2021, Yakov wrote: On this sample using macros speeds the program up 400% Be that as it may, it's not representative of most application. For instance, cpython's performance increases by only 10-15% with the inliner turned on. (And actually that's misleading, because

Re: [Tinycc-devel] manually inlining functions

2021-04-30 Thread Kyryl Melekhin
Well, I may take that back, recursion may be useful if you have a 5000 loc function that you need to invoke on some very rare occasion once. And if you care about the size of your executable a lot for some reason. But on hotpath, it makes no sense. Unless you are trying to satisfy your academia,

Re: [Tinycc-devel] manually inlining functions

2021-04-30 Thread Kyryl Melekhin
Yakov wrote: > Kyryl you cannot inline everything because you will get code > explosion, often infinite code explosion when functions have a > circular dependency on each other. I am just talking about inlining > certain functions carefully chosen by a programmer. Yeah, I get that. That's why

Re: [Tinycc-devel] manually inlining functions

2021-04-30 Thread Yakov
I have recently read a paper about a Linear Scan Register Allocator[1], they claim it gives you 95% performance or Graph Coloring Register Allocator in basically no time, and requires no SSA. 1. http://web.cs.ucla.edu/~palsberg/course/cs132/linearscan.pdf сб, 1 мая 2021 г. в 10:51, Elijah

Re: [Tinycc-devel] manually inlining functions

2021-04-30 Thread Yakov
Saying that calls are cheap may be right for many cases but definitely not for me, here is a tiny example I made by copying/pasting from my actual project which is a compiler that uses TinyC as a backend. On this sample using macros speeds the program up 400% i.e. 4 times on my AMD Ryzen5. In a

Re: [Tinycc-devel] manually inlining functions

2021-04-30 Thread Yakov
Kyryl you cannot inline everything because you will get code explosion, often infinite code explosion when functions have a circular dependency on each other. I am just talking about inlining certain functions carefully chosen by a programmer. сб, 1 мая 2021 г. в 11:13, Kyryl Melekhin : > >

Re: [Tinycc-devel] manually inlining functions

2021-04-30 Thread Kyryl Melekhin
Yakov wrote: > Manual inlining seems to be a straightforward thing, just clone the > node into the ast and rename all variables to something unique so I > thought maybe that's what tcc supports with some pragma or what not. If you create such a tool which can take any C code and straight up

Re: [Tinycc-devel] manually inlining functions

2021-04-30 Thread Elijah Stone
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

[Tinycc-devel] manually inlining functions

2021-04-30 Thread Yakov
I know TinyC does not optimize (that's why it's fast and that's what I love) but 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. Is there a way in Tiny to tell the compiler always to inline