xref: /PHP-8.2/ext/opcache/tests/opt/dce_004.phpt (revision e48a5c14)
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=
9zend_test.observer.enabled=0
10--EXTENSIONS--
11opcache
12--FILE--
13<?php
14function foo(int $x, int $y) {
15    $a = [$x];
16    $a[1] = $y;
17    $a = $y;
18    return $a;
19}
20?>
21--EXPECTF--
22$_main:
23     ; (lines=1, args=0, vars=0, tmps=0)
24     ; (after optimizer)
25     ; %sdce_004.php:1-9
260000 RETURN int(1)
27
28foo:
29     ; (lines=4, args=2, vars=3, tmps=0)
30     ; (after optimizer)
31     ; %sdce_004.php:2-7
320000 CV0($x) = RECV 1
330001 CV1($y) = RECV 2
340002 CV2($a) = QM_ASSIGN CV1($y)
350003 RETURN CV2($a)
36