xref: /PHP-8.2/ext/opcache/tests/opt/sccp_008.phpt (revision e48a5c14)
1--TEST--
2SCCP 008: 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    if ($x) {
16        $a = [0,1];
17    } else {
18        $a = [0,2];
19    }
20    echo $a[1];
21}
22?>
23--EXPECTF--
24$_main:
25     ; (lines=1, args=0, vars=0, tmps=0)
26     ; (after optimizer)
27     ; %ssccp_008.php:1-11
280000 RETURN int(1)
29
30foo:
31     ; (lines=8, args=1, vars=2, tmps=1)
32     ; (after optimizer)
33     ; %ssccp_008.php:2-9
340000 CV0($x) = RECV 1
350001 JMPZ CV0($x) 0004
360002 CV1($a) = QM_ASSIGN array(...)
370003 JMP 0005
380004 CV1($a) = QM_ASSIGN array(...)
390005 T2 = FETCH_DIM_R CV1($a) int(1)
400006 ECHO T2
410007 RETURN null
42