Re: Re: com php-src: Convert ASSIGN_ADD $a, $b into $a = ADD $a, $b, if possible.: ext/opcache/Optimizer/dfa_pass.c
| From: | Nikita Popov | Date: | Wed, 23 Mar 2016 10:10:25 +0000 |
| Subject: | Re: Re: com php-src: Convert ASSIGN_ADD $a, $b into $a = ADD $a, $b, if possible.: ext/opcache/Optimizer/dfa_pass.c | ||
| References: | 1 2 | Groups: | php.cvs php.internals |
| Request: | Send a blank email to php-cvs+get-91466@lists.php.net to get a copy of this message | ||
On Wed, Mar 23, 2016 at 5:38 AM, Matt Wilmas <php_lists@realplain.com>
wrote:
> Hi Dmitry,
>
> ----- Original Message -----
> From: "Dmitry Stogov"
> Sent: Tuesday, March 22, 2016
>
> Commit: d8b75b0807a5d94bd7b6b175d56aba8bc5be8d7a
>> Author: Dmitry Stogov <dmitry@zend.com> Tue, 22 Mar 2016
>> 23:57:26 +0300
>> Parents: 76d612129bb6b67171308f43c19d7e4791d7919e
>> Branches: master
>>
>> Link:
>>
>> http://git.php.net/?p=php-src.git;a=commitdiff;h=d8b75b0807a5d94bd7b6b175d56aba8bc5be8d7a
>>
>> Log:
>> Convert ASSIGN_ADD $a, $b into $a = ADD $a, $b, if possible.
>>
>> Changed paths:
>> M ext/opcache/Optimizer/dfa_pass.c
>>
>
> So this changes $a += $b into $a = $a + $b?
>
> What is the purpose of that...? I always use the former, because I
> thought the latter created a temp value for $a + $b prior to assignment...
> (Maybe I'm wrong or it's different now? :-/)
>
> Otherwise, is the idea to "deaden" the ASSIGN_* handlers and consolidate
> stuff to a common handler, thus improving CPU instruction cache usage?
>
$a = $a + $b compiles to T0 = ADD $a, $b; ASSIGN $a, T0. This
transformation compiles to $a = ADD $a, $b, i.e. $a is directly used as the
result operand of the ADD opcode. This is only possible because we know
that $a does not contain a refcounted type prior to this operation, so its
value does not require destruction.
$a = ADD $a, $b is faster than ASSIGN_ADD $a, $b because it doesn't have to
do a whole slew of checks and has a fast-path for common cases. Furthermore
(and in this instance, more importantly) the ADD opcode will be picked up
by type-specialization.
Nikita