Re: [PHP-DEV] Generating more efficient code for while-loop

2015-01-16 Thread Xinchen Hui
ginal ====== > From: Dmitry Stogov > To: Benjamin Coutu > Date: Fri, 16 Jan 2015 17:12:34 +0100 > Subject: Re: [PHP-DEV] Generating more efficient code for while-loop > > Hi Benjamin, > > Thanks for idea. > With PHP7 AST compiler, it's quite easy to implement this

Re: [PHP-DEV] Generating more efficient code for while-loop

2015-01-16 Thread Benjamin Coutu
== From: Dmitry Stogov To: Benjamin Coutu Date: Fri, 16 Jan 2015 17:12:34 +0100 Subject: Re: [PHP-DEV] Generating more efficient code for while-loop Hi Benjamin, Thanks for idea. With PHP7 AST compiler, it's quite easy to implement this (it took us 15 minutes to try :) However, it doesn&#x

Re: [PHP-DEV] Generating more efficient code for while-loop

2015-01-16 Thread Nikita Popov
On Fri, Jan 16, 2015 at 6:09 PM, Dmitry Stogov wrote: > See the patch for "while" and "for" loops > > https://gist.github.com/dstogov/9cc5767a14f3b88e1275 > > All tests passed. > The patch leads to 2% improvement in number of CPU instructions retired on > bench.php. > Unfortunately, It doesn't ma

Re: [PHP-DEV] Generating more efficient code for while-loop

2015-01-16 Thread Dmitry Stogov
See the patch for "while" and "for" loops https://gist.github.com/dstogov/9cc5767a14f3b88e1275 All tests passed. The patch leads to 2% improvement in number of CPU instructions retired on bench.php. Unfortunately, It doesn't make any visible speed difference. Anyway, I'm going to commit it on Mo

Re: [PHP-DEV] Generating more efficient code for while-loop

2015-01-16 Thread Xinchen Hui
Hey: On Sat, Jan 17, 2015 at 12:12 AM, Dmitry Stogov wrote: > Hi Benjamin, > > Thanks for idea. > With PHP7 AST compiler, it's quite easy to implement this (it took us 15 > minutes to try :) yeah... by handy :) > However, it doesn't make big improvement on our benchmarks. in reallife app, IR has

Re: [PHP-DEV] Generating more efficient code for while-loop

2015-01-16 Thread Dmitry Stogov
Hi Benjamin, Thanks for idea. With PHP7 AST compiler, it's quite easy to implement this (it took us 15 minutes to try :) However, it doesn't make big improvement on our benchmarks. We will take a look into possibilities to apply your idea to other patterns (e.g. for and foreach loops). Anyway, it

[PHP-DEV] Generating more efficient code for while-loop

2015-01-15 Thread Benjamin Coutu
Hello, Please consider the following PHP code: while ( ) { } It currently compiles to something like this for the Zend Engine: 0: 1: JMPZ -> 4 2: 3: JMP -> 0 4: ... This can easily be rewritten in an equivalent but much more efficient form: 0: JMP -> 2 1: 2: 3: JMPNZ -> 1 The trick i