xref: /PHP-7.3/ext/opcache/tests/opt/sccp_008.phpt (revision 8c22d3e7)
1--TEST--
2SCCP 008: Conditional Constant Propagation of non-escaping array elements
3--INI--
4opcache.enable=1
5opcache.enable_cli=1
6opcache.optimization_level=-1
7opcache.opt_debug_level=0x20000
8--SKIPIF--
9<?php require_once('skipif.inc'); ?>
10--FILE--
11<?php
12function foo(int $x) {
13	if ($x) {
14		$a = [0,1];
15	} else {
16		$a = [0,2];
17	}
18	echo $a[1];
19}
20?>
21--EXPECTF--
22$_main: ; (lines=1, args=0, vars=0, tmps=0)
23    ; (after optimizer)
24    ; %ssccp_008.php:1-11
25L0 (11):    RETURN int(1)
26
27foo: ; (lines=8, args=1, vars=2, tmps=1)
28    ; (after optimizer)
29    ; %ssccp_008.php:2-9
30L0 (2):     CV0($x) = RECV 1
31L1 (3):     JMPZ CV0($x) L4
32L2 (4):     CV1($a) = QM_ASSIGN array(...)
33L3 (4):     JMP L5
34L4 (6):     CV1($a) = QM_ASSIGN array(...)
35L5 (8):     T2 = FETCH_DIM_R CV1($a) int(1)
36L6 (8):     ECHO T2
37L7 (9):     RETURN null
38