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