xref: /PHP-8.0/ext/opcache/tests/opt/sccp_032.phpt (revision 543684e7)
1--TEST--
2SCCP 032: Yield from optimizations
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 test(): Generator {
14    $result = yield from [];
15    $a = [];
16    yield from $a;
17    yield $result;
18    $a[] = 3;
19    yield from $a;
20}
21foreach (test() as $x) {
22    var_export($x);
23    echo "\n";
24}
25?>
26--EXPECTF--
27$_main:
28     ; (lines=11, args=0, vars=1, tmps=2)
29     ; (after optimizer)
30     ; %ssccp_032.php:1-15
310000 INIT_FCALL 0 %d string("test")
320001 V2 = DO_UCALL
330002 V1 = FE_RESET_R V2 0009
340003 FE_FETCH_R V1 CV0($x) 0009
350004 INIT_FCALL 1 %d string("var_export")
360005 SEND_VAR CV0($x) 1
370006 DO_ICALL
380007 ECHO string("
39")
400008 JMP 0003
410009 FE_FREE V1
420010 RETURN int(1)
43LIVE RANGES:
44     1: 0003 - 0009 (loop)
45
46test:
47     ; (lines=5, args=0, vars=0, tmps=1)
48     ; (after optimizer)
49     ; %ssccp_032.php:2-9
500000 GENERATOR_CREATE
510001 YIELD null
520002 T0 = YIELD_FROM array(...)
530003 FREE T0
540004 GENERATOR_RETURN null
55NULL
563
57