xref: /PHP-8.4/ext/opcache/tests/opt/sccp_006.phpt (revision e48a5c14)
1--TEST--
2SCCP 006: 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(int $x) {
15    $a = ["a"=>1,"a"=>2,"a"=>$x];
16    echo $a["a"];
17}
18?>
19--EXPECTF--
20$_main:
21     ; (lines=1, args=0, vars=0, tmps=0)
22     ; (after optimizer)
23     ; %ssccp_006.php:1-7
240000 RETURN int(1)
25
26foo:
27     ; (lines=8, args=1, vars=2, tmps=1)
28     ; (after optimizer)
29     ; %ssccp_006.php:2-5
300000 CV0($x) = RECV 1
310001 T2 = INIT_ARRAY 3 int(1) string("a")
320002 T2 = ADD_ARRAY_ELEMENT int(2) string("a")
330003 T2 = ADD_ARRAY_ELEMENT CV0($x) string("a")
340004 CV1($a) = QM_ASSIGN T2
350005 T2 = FETCH_DIM_R CV1($a) string("a")
360006 ECHO T2
370007 RETURN null
38LIVE RANGES:
39     2: 0002 - 0004 (tmp/var)
40