php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #71102 Dead code elimination
Submitted: 2015-12-12 14:05 UTC Modified: 2015-12-12 14:24 UTC
From: flip101 at gmail dot com Assigned: laruence (profile)
Status: Closed Package: Performance problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: flip101 at gmail dot com
New email:
PHP Version: OS:

 

 [2015-12-12 14:05 UTC] flip101 at gmail dot com
Description:
------------
When php parses the source files and converts it to bytecode, does it do dead code elimination? For things like

if (false) {}
or when using constants (self defined or predefined)
or when checking certain expressions such as   if (4 > 10-15) {}

I couldn't find anything about this after searching. It would certainly benefit libraries which have a lot of version checks and checks on which operating system it's using. To me (unknowingly of anything happening in the compiler) it seems a bit low hanging fruit optimization, but perhaps to cover all the edge cases is not so trivial. However a partial implementation would already help a lot. In case it does exist please link to relevant documentation or source files.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-12 14:09 UTC] laruence@php.net
We do it in opcache. you can look into ext/opcache/Optimizer/
 [2015-12-12 14:10 UTC] laruence@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: laruence
 [2015-12-12 14:24 UTC] flip101 at gmail dot com
if (4 > 10-15) {} <-- wrong example, should have been --> if (4 > 10-5) {}
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 01:01:30 2024 UTC