xref: /PHP-7.3/ext/opcache/tests/opt/dce_004.phpt (revision 9fe6b293)
1--TEST--
2DCE 004: Elimination of assignment to non-escaping arrays
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, int $y) {
13	$a = [$x];
14	$a[1] = $y;
15	$a = $y;
16	return $a;
17}
18--EXPECTF--
19$_main: ; (lines=1, args=0, vars=0, tmps=0)
20    ; (after optimizer)
21    ; %sdce_004.php:1-8
22L0 (8):     RETURN int(1)
23
24foo: ; (lines=4, args=2, vars=3, tmps=0)
25    ; (after optimizer)
26    ; %sdce_004.php:2-7
27L0 (2):     CV0($x) = RECV 1
28L1 (2):     CV1($y) = RECV 2
29L2 (5):     CV2($a) = QM_ASSIGN CV1($y)
30L3 (6):     RETURN CV2($a)
31