xref: /PHP-7.3/ext/opcache/tests/opt/sccp_002.phpt (revision 9fe6b293)
1--TEST--
2SCCP 002: 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	$a = [$x];
14	$i = 1;
15	$c = $i < 2;
16	if ($c) {
17		$k = 2 * $i;
18		$a[$k] = $i;
19		echo $a[$k];
20	}
21	echo $a[2];
22}
23?>
24--EXPECTF--
25$_main: ; (lines=1, args=0, vars=0, tmps=0)
26    ; (after optimizer)
27    ; %ssccp_002.php:1-14
28L0 (14):    RETURN int(1)
29
30foo: ; (lines=4, args=1, vars=1, tmps=0)
31    ; (after optimizer)
32    ; %ssccp_002.php:2-12
33L0 (2):     CV0($x) = RECV 1
34L1 (9):     ECHO int(1)
35L2 (11):    ECHO int(1)
36L3 (12):    RETURN null
37