xref: /PHP-8.0/ext/opcache/tests/opt/dce_004.phpt (revision 7aacc705)
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
8opcache.preload=
9--SKIPIF--
10<?php require_once('skipif.inc'); ?>
11--FILE--
12<?php
13function foo(int $x, int $y) {
14    $a = [$x];
15    $a[1] = $y;
16    $a = $y;
17    return $a;
18}
19?>
20--EXPECTF--
21$_main:
22     ; (lines=1, args=0, vars=0, tmps=0)
23     ; (after optimizer)
24     ; %sdce_004.php:1-9
250000 RETURN int(1)
26
27foo:
28     ; (lines=4, args=2, vars=3, tmps=0)
29     ; (after optimizer)
30     ; %sdce_004.php:2-7
310000 CV0($x) = RECV 1
320001 CV1($y) = RECV 2
330002 CV2($a) = QM_ASSIGN CV1($y)
340003 RETURN CV2($a)
35