xref: /PHP-7.3/ext/opcache/tests/opt/sccp_006.phpt (revision 8c22d3e7)
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
8--SKIPIF--
9<?php require_once('skipif.inc'); ?>
10--FILE--
11<?php
12function foo(int $x) {
13	$a = ["a"=>1,"a"=>2,"a"=>$x];
14	echo $a["a"];
15}
16?>
17--EXPECTF--
18$_main: ; (lines=1, args=0, vars=0, tmps=0)
19    ; (after optimizer)
20    ; %ssccp_006.php:1-7
21L0 (7):     RETURN int(1)
22
23foo: ; (lines=8, args=1, vars=2, tmps=1)
24    ; (after optimizer)
25    ; %ssccp_006.php:2-5
26L0 (2):     CV0($x) = RECV 1
27L1 (3):     T2 = INIT_ARRAY 3 int(1) string("a")
28L2 (3):     T2 = ADD_ARRAY_ELEMENT int(2) string("a")
29L3 (3):     T2 = ADD_ARRAY_ELEMENT CV0($x) string("a")
30L4 (3):     CV1($a) = QM_ASSIGN T2
31L5 (4):     T2 = FETCH_DIM_R CV1($a) string("a")
32L6 (4):     ECHO T2
33L7 (5):     RETURN null
34LIVE RANGES:
35        2: L2 - L4 (tmp/var)
36