xref: /PHP-7.3/ext/opcache/tests/opt/sccp_003.phpt (revision 9fe6b293)
1--TEST--
2SCCP 003: 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() {
13	$a = [1,2,3];
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_003.php:1-14
28L0 (14):    RETURN int(1)
29
30foo: ; (lines=3, args=0, vars=0, tmps=0)
31    ; (after optimizer)
32    ; %ssccp_003.php:2-12
33L0 (9):     ECHO int(1)
34L1 (11):    ECHO int(1)
35L2 (12):    RETURN null
36