[fpc-devel] Tail recursion optimization

2006-10-10 Thread Florian Klaempfl
Yesterday, I've implemented tail recursion optimization (http://svn.freepascal.org/svn/fpc/trunk/compiler/opttail.pas resulting in http://www.hu.freepascal.org/fpcircbot/cgipastebin?msgid=158 pp11 is the new compiler, fpc11 the old, both are 2.1.1). It isn't enabled yet because it still needs some

Re: [fpc-devel] Tail recursion optimization

2006-10-10 Thread Daniël Mantione
Op Tue, 10 Oct 2006, schreef Florian Klaempfl: Yesterday, I've implemented tail recursion optimization (http://svn.freepascal.org/svn/fpc/trunk/compiler/opttail.pas resulting in http://www.hu.freepascal.org/fpcircbot/cgipastebin?msgid=158 pp11 is the new compiler, fpc11 the old, both are

Re: [fpc-devel] Tail recursion optimization

2006-10-10 Thread Jonas Maebe
On 10 okt 2006, at 10:05, Daniël Mantione wrote: If the optimization needs significant processing power, -O3. If it doesn't but is debug safe, -O1, if it is not debug safe, -O2. It's definitely not debug safe, since it messes up stack information. A separate option -OoTAILREC is IMHO not

Re: [fpc-devel] Tail recursion optimization

2006-10-10 Thread Micha Nelissen
Florian Klaempfl wrote: Yesterday, I've implemented tail recursion optimization (http://svn.freepascal.org/svn/fpc/trunk/compiler/opttail.pas resulting in http://www.hu.freepascal.org/fpcircbot/cgipastebin?msgid=158 pp11 is the new compiler, fpc11 the old, both are 2.1.1). It isn't enabled yet

Re: [fpc-devel] Tail recursion optimization

2006-10-10 Thread Florian Klaempfl
Daniël Mantione wrote: Op Tue, 10 Oct 2006, schreef Florian Klaempfl: Yesterday, I've implemented tail recursion optimization (http://svn.freepascal.org/svn/fpc/trunk/compiler/opttail.pas resulting in http://www.hu.freepascal.org/fpcircbot/cgipastebin?msgid=158 pp11 is the new compiler,

Re: [fpc-devel] Tail recursion optimization

2006-10-10 Thread Florian Klaempfl
Jonas Maebe wrote: On 10 okt 2006, at 10:05, Daniël Mantione wrote: If the optimization needs significant processing power, -O3. If it doesn't but is debug safe, -O1, if it is not debug safe, -O2. It's definitely not debug safe, since it messes up stack information. Not really. I

Re: [fpc-devel] Tail recursion optimization

2006-10-10 Thread Vinzent Hoefler
On Tuesday 10 October 2006 08:29, Florian Klaempfl wrote: Daniël Mantione wrote: Op Tue, 10 Oct 2006, schreef Florian Klaempfl: Yesterday, I've implemented tail recursion optimization (http://svn.freepascal.org/svn/fpc/trunk/compiler/opttail.pas resulting in

Re: [fpc-devel] Tail recursion optimization

2006-10-10 Thread Florian Klaempfl
Micha Nelissen wrote: Florian Klaempfl wrote: Yesterday, I've implemented tail recursion optimization (http://svn.freepascal.org/svn/fpc/trunk/compiler/opttail.pas resulting in http://www.hu.freepascal.org/fpcircbot/cgipastebin?msgid=158 pp11 is the new compiler, fpc11 the old, both are

Re: [fpc-devel] Tail recursion optimization

2006-10-10 Thread Florian Klaempfl
Vinzent Hoefler wrote: On Tuesday 10 October 2006 08:29, Florian Klaempfl wrote: Daniël Mantione wrote: Op Tue, 10 Oct 2006, schreef Florian Klaempfl: Yesterday, I've implemented tail recursion optimization (http://svn.freepascal.org/svn/fpc/trunk/compiler/opttail.pas resulting in

Re: [fpc-devel] Tail recursion optimization

2006-10-10 Thread Micha Nelissen
Florian Klaempfl wrote: -OoTAILREC? -O3? Something different? It doesn't always improve performance ? It takes much more code ? ? I thought the difference between -O2 and -O3 is that -O3 is not actually guaranteed to improve global performance, for example due to the code expanding a lot.

Re: [fpc-devel] Tail recursion optimization

2006-10-10 Thread Jonas Maebe
On 10 okt 2006, at 10:34, Florian Klaempfl wrote: Not really. I didn't try it yet but it shouldn't mess up much. The optimziation is done completely on the node level, the pascal code would look like http://www.hu.freepascal.org/fpcircbot/cgipastebin?msgid=156 except that there are temps

Re: [fpc-devel] Tail recursion optimization

2006-10-10 Thread Daniël Mantione
Op Tue, 10 Oct 2006, schreef Micha Nelissen: Florian Klaempfl wrote: Yesterday, I've implemented tail recursion optimization (http://svn.freepascal.org/svn/fpc/trunk/compiler/opttail.pas resulting in http://www.hu.freepascal.org/fpcircbot/cgipastebin?msgid=158 pp11 is the new

Re: [fpc-devel] Tail recursion optimization

2006-10-10 Thread Florian Klaempfl
Jonas Maebe wrote: On 10 okt 2006, at 10:34, Florian Klaempfl wrote: Not really. I didn't try it yet but it shouldn't mess up much. The optimziation is done completely on the node level, the pascal code would look like http://www.hu.freepascal.org/fpcircbot/cgipastebin?msgid=156 except

Re: [fpc-devel] Tail recursion optimization

2006-10-10 Thread Jonas Maebe
On 10 okt 2006, at 11:09, Florian Klaempfl wrote: Also, do you actually insert goto/label nodes? That would degrade the performance of the register variable assignment because of the current limitations concerning flow analysis (i.e., for sufficiently complex routines, the tail recursion

[fpc-devel] Recompilation optimization patch

2006-10-10 Thread Micha Nelissen
Hi, I'm trying to reduce the number of recompilation needed of units. Currently compiler very often recompiles due to possibility of changed inlined functions being present. Attached patch tries store this info in ppu (whether inlined functions are present). Is this a good patch ? Btw,

Re: [fpc-devel] Tail recursion optimization

2006-10-10 Thread Florian Klaempfl
Jonas Maebe wrote: The recursive call is usually inside an if anyways so the ssa optimizer is lost anyways, no? For the part inside the if: yes. But not for the part coming before it. What's more important however is that goto/label not only removes the usage of SSA, it also means that all

Re: [fpc-devel] Tail recursion optimization

2006-10-10 Thread Daniël Mantione
Op Tue, 10 Oct 2006, schreef Florian Klaempfl: There's a FlagsUsed field in the ttaiprop record which is set to true if the flags result of that instruction is used. I guess it could be used to change to code above to leal 1(%esi),%eax ? Or is this slower on some CPUs? In the worst

Re: [fpc-devel] Tail recursion optimization

2006-10-10 Thread Jonas Maebe
On 10 okt 2006, at 13:46, Florian Klaempfl wrote: Practical argument: the assembler code _is_ better for the code I tested and up to as twice as fast as the original one. That's indeed true for an extremely small function with so few local variables/parameters that even on an i386 it

Re: [fpc-devel] Tail recursion optimization

2006-10-10 Thread Florian Klaempfl
Jonas Maebe wrote: [...] Well, basically I agree with all your points ;) That's why I said the optimization is almost useless for real world programs. Nevertheless it helps for the benchmarks and gcc does it to. I'll try to find out the influence on the compiler/rtl, there are some examples

[fpc-devel] Default strings encoding

2006-10-10 Thread Felipe Monteiro de Carvalho
Hello, If I have a ansistring, and cast that to a WideString, fpc is converting from which encoding to which encoding? ansistring can hold utf-8 also, not only iso. I'm not sure what WideString holds. Maybe UTF-16? Or a limited UTF-16 with only 2 bytes characters. thanks, -- Felipe Monteiro de

Re: [fpc-devel] Default strings encoding

2006-10-10 Thread Daniël Mantione
Op Tue, 10 Oct 2006, schreef Felipe Monteiro de Carvalho: Hello, If I have a ansistring, and cast that to a WideString, fpc is converting from which encoding to which encoding? Without widestring manager, it converts iso-8859-1 to UCS-2. ansistring can hold utf-8 also, not only iso.

Re: [fpc-devel] Recompilation optimization patch

2006-10-10 Thread Peter Vreman
Hi, I'm trying to reduce the number of recompilation needed of units. Currently compiler very often recompiles due to possibility of changed inlined functions being present. Attached patch tries store this info in ppu (whether inlined functions are present). Is this a good patch ? Btw,

Re: [fpc-devel] Recompilation optimization patch

2006-10-10 Thread Micha Nelissen
Peter Vreman wrote: This is not correct. Also other things like calling conventions can change in delphi mode. In ppu.pas at line 33 you can enable {$define INTFPPU} Because the calling convention is only specified in the implementation ? Micha ___

RE: [fpc-devel] Default strings encoding

2006-10-10 Thread peter green
I'm not sure what WideString holds. Maybe UTF-16? Or a limited UTF-16 with only 2 bytes characters. UCS-2. Basically this is UTF-16 with only 2-byte characters, allthough there are small differences in the high regions; UCS-2 is code points $0..$, while UTF-16 has facilities to allow

[fpc-devel] FindFirst

2006-10-10 Thread Micha Nelissen
Hi, Can the FindFirst optimization in 2.1.1 for unix/sysutils.pp be merged to 2.0.5 ? Revision 4772. Not only is it more efficient, it also fixes a bug: I cannot find a single directory with FindFirst in 2.0.5. Furthermore, attached is a patch for another optimization: do not allocate a record