com php-src: Fix loop identification: ext/opcache/Optimizer/zen d_cfg.c

[email protected] (Nikita Popov)
Newsgroups php.cvs
Message-ID <[email protected]>
Commit:    abf16c18c77815b310af9528106d0c76eb8a81ab
Author:    Nikita Popov <[email protected]>         Mon, 17 Apr 2017 12:17:32 +0200
Parents:   f69c1082498569dcab95706ce1f6b9c2ac07f367
Branches:  PHP-7.1 master

Link:       http://git.php.net/?p=php-src.git;a=commitdiff;h=abf16c18c77815b310af9528106d0c76eb8a81ab

Log:
Fix loop identification

When assigning loop headers, we should treat already detected
loops as collapsed to their loop header, instead of ignoring them.

This fixes the loop header of BB2 in mandel2 if live-range CFG
splitting is enabled.

Changed paths:
  M  ext/opcache/Optimizer/zend_cfg.c


Diff:
diff --git a/ext/opcache/Optimizer/zend_cfg.c b/ext/opcache/Optimizer/zend_cfg.c
index 1e9bfe4..ec71166 100644
--- a/ext/opcache/Optimizer/zend_cfg.c
+++ b/ext/opcache/Optimizer/zend_cfg.c
@@ -855,7 +855,10 @@ int zend_cfg_identify_loops(const zend_op_array *op_array, zend_cfg *cfg, uint32
 		}
 		while (zend_worklist_len(&work)) {
 			j = zend_worklist_pop(&work);
-			if (blocks[j].loop_header < 0 && j != i) {
+			while (blocks[j].loop_header >= 0) {
+				j = blocks[j].loop_header;
+			}
+			if (j != i) {
 				blocks[j].loop_header = i;
 				for (k = 0; k < blocks[j].predecessors_count; k++) {
 					zend_worklist_push(&work, cfg->predecessors[blocks[j].predecessor_offset + k]);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.