Skip to content

Opcache idea: Combine is_int($x) || is_string($x) #6

Open
@TysonAndre

Description

@TysonAndre
<?php
function f1($x, $y) {
    var_export($y === null || is_int($y));
    return $y === null || is_int($y);
}

The TYPE_CHECK can be combined if the pattern is recognized

For~/php-8.0.0-dev-install/bin/php -d opcache.file_cache= -d opcache.opt_debug_level=0x20000 test.php

f1: ; (lines=12, args=2, vars=2, tmps=1)
    ; (after optimizer)
    ; /path/to/test.php:3-6
L0 (3):     CV0($x) = RECV 1
L1 (3):     CV1($y) = RECV 2
L2 (4):     INIT_FCALL 1 96 string("var_export")
L3 (4):     T2 = TYPE_CHECK (null) CV1($y)
L4 (4):     T2 = JMPNZ_EX T2 L6
L5 (4):     T2 = TYPE_CHECK (long) CV1($y)
L6 (4):     SEND_VAL T2 1
L7 (4):     DO_ICALL
L8 (5):     T2 = TYPE_CHECK (null) CV1($y)
L9 (5):     T2 = JMPNZ_EX T2 L11
L10 (5):    T2 = TYPE_CHECK (long) CV1($y)
L11 (5):    RETURN T2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions