xref: /PHP-8.4/ext/opcache/tests/opt/sccp_003.phpt (revision e48a5c14)
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
8opcache.preload=
9zend_test.observer.enabled=0
10--EXTENSIONS--
11opcache
12--FILE--
13<?php
14function foo() {
15    $a = [1,2,3];
16    $i = 1;
17    $c = $i < 2;
18    if ($c) {
19        $k = 2 * $i;
20        $a[$k] = $i;
21        echo $a[$k];
22    }
23    echo $a[2];
24}
25?>
26--EXPECTF--
27$_main:
28     ; (lines=1, args=0, vars=0, tmps=0)
29     ; (after optimizer)
30     ; %ssccp_003.php:1-14
310000 RETURN int(1)
32
33foo:
34     ; (lines=3, args=0, vars=0, tmps=0)
35     ; (after optimizer)
36     ; %ssccp_003.php:2-12
370000 ECHO string("1")
380001 ECHO string("1")
390002 RETURN null
40