xref: /php-src/ext/opcache/tests/opt/sccp_032.phpt (revision e48a5c14)
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=
9zend_test.observer.enabled=0
10--EXTENSIONS--
11opcache
12--FILE--
13<?php
14function test(): Generator {
15    $result = yield from [];
16    $a = [];
17    yield from $a;
18    yield $result;
19    $a[] = 3;
20    yield from $a;
21}
22foreach (test() as $x) {
23    var_export($x);
24    echo "\n";
25}
26?>
27--EXPECTF--
28$_main:
29     ; (lines=11, args=0, vars=1, tmps=2)
30     ; (after optimizer)
31     ; %ssccp_032.php:1-15
320000 INIT_FCALL 0 %d string("test")
330001 V2 = DO_UCALL
340002 V1 = FE_RESET_R V2 0009
350003 FE_FETCH_R V1 CV0($x) 0009
360004 INIT_FCALL 1 %d string("var_export")
370005 SEND_VAR CV0($x) 1
380006 DO_ICALL
390007 ECHO string("
40")
410008 JMP 0003
420009 FE_FREE V1
430010 RETURN int(1)
44LIVE RANGES:
45     1: 0003 - 0009 (loop)
46
47test:
48     ; (lines=5, args=0, vars=0, tmps=1)
49     ; (after optimizer)
50     ; %ssccp_032.php:2-9
510000 GENERATOR_CREATE
520001 YIELD null
530002 T0 = YIELD_FROM array(...)
540003 FREE T0
550004 GENERATOR_RETURN null
56NULL
573
58