Library/Operators/Arithmetical/ArithmeticalBaseOperator.php
public function optimizeConstantFolding(array $expression, CompilationContext $compilationContext)
    {
        if ('int' != $expression['left']['type'] && 'double' != $expression['left']['type']) {
            return false;
        }

        if ($compilationContext->config->get('constant-folding', 'optimizations')) {
            if ('int' == $expression['left']['type'] && 'int' == $expression['right']['type']) {
                switch ($this->operator) {
                    case '+':
                        return new CompiledExpression('int', $expression['left']['value'] + $expression['right']['value'], $expression);

                    case '-':
                        return new CompiledExpression('int', $expression['left']['value'] - $expression['right']['value'], $expression);

                    case '*':
                        return new CompiledExpression('int', $expression['left']['value'] * $expression['right']['value'], $expression);
                }
            }

            if (('double' == $expression['left']['type'] && 'double' == $expression['right']['type']) || ('double' == $expression['left']['type'] && 'int' == $expression['right']['type']) || ('int' == $expression['left']['type'] && 'double' == $expression['right']['type'])) {
                switch ($this->operator) {
                    case '+':
                        return new CompiledExpression('double', $expression['left']['value'] + $expression['right']['value'], $expression);

                    case '-':
                        return new CompiledExpression('double', $expression['left']['value'] - $expression['right']['value'], $expression);

                    case '*':
                        return new CompiledExpression('double', $expression['left']['value'] * $expression['right']['value'], $expression);
                }
            }
        }

        return false;
    }
public function optimizeConstantFolding(array $expression, CompilationContext $compilationContext)
    {
        if ('int' != $expression['left']['type'] && 'double' != $expression['left']['type']) {
            return false;
        }

        if ($compilationContext->config->get('constant-folding', 'optimizations')) {
            if ('int' == $expression['left']['type'] && 'int' == $expression['right']['type']) {
                switch ($this->operator) {
                    case '+':
                        return new CompiledExpression('int', $expression['left']['value'] + $expression['right']['value'], $expression);

                    case '-':
                        return new CompiledExpression('int', $expression['left']['value'] - $expression['right']['value'], $expression);

                    case '*':
                        return new CompiledExpression('int', $expression['left']['value'] * $expression['right']['value'], $expression);
                }
            }

            if (('double' == $expression['left']['type'] && 'double' == $expression['right']['type']) || ('double' == $expression['left']['type'] && 'int' == $expression['right']['type']) || ('int' == $expression['left']['type'] && 'double' == $expression['right']['type'])) {
                switch ($this->operator) {
                    case '+':
                        return new CompiledExpression('double', $expression['left']['value'] + $expression['right']['value'], $expression);

                    case '-':
                        return new CompiledExpression('double', $expression['left']['value'] - $expression['right']['value'], $expression);

                    case '*':
                        return new CompiledExpression('double', $expression['left']['value'] * $expression['right']['value'], $expression);
                }
            }
        }

        return false;
    }
public function optimizeConstantFolding ( array $ expression , CompilationContext $ compilationContext ) { if ( 'int' != $ expression [ 'left' ] [ 'type' ] && 'double' != $ expression [ 'left' ] [ 'type' ] ) { return false ; } if ( $ compilationContext -> config -> get ( 'constant-folding' , 'optimizations' ) ) { if ( 'int' == $ expression [ 'left' ] [ 'type' ] && 'int' == $ expression [ 'right' ] [ 'type' ] ) { switch ( $ this -> operator ) { case '+' : return new CompiledExpression ( 'int' , $ expression [ 'left' ] [ 'value' ] + $ expression [ 'right' ] [ 'value' ] , $ expression ) ; case '-' : return new CompiledExpression ( 'int' , $ expression [ 'left' ] [ 'value' ] - $ expression [ 'right' ] [ 'value' ] , $ expression ) ; case '*' : return new CompiledExpression ( 'int' , $ expression [ 'left' ] [ 'value' ] * $ expression [ 'right' ] [ 'value' ] , $ expression ) ; } } if ( ( 'double' == $ expression [ 'left' ] [ 'type' ] && 'double' == $ expression [ 'right' ] [ 'type' ] ) || ( 'double' == $ expression [ 'left' ] [ 'type' ] && 'int' == $ expression [ 'right' ] [ 'type' ] ) || ( 'int' == $ expression [ 'left' ] [ 'type' ] && 'double' == $ expression [ 'right' ] [ 'type' ] ) ) { switch ( $ this -> operator ) { case '+' : return new CompiledExpression ( 'double' , $ expression [ 'left' ] [ 'value' ] + $ expression [ 'right' ] [ 'value' ] , $ expression ) ; case '-' : return new CompiledExpression ( 'double' , $ expression [ 'left' ] [ 'value' ] - $ expression [ 'right' ] [ 'value' ] , $ expression ) ; case '*' : return new CompiledExpression ( 'double' , $ expression [ 'left' ] [ 'value' ] * $ expression [ 'right' ] [ 'value' ] , $ expression ) ; } } } return false ; }
This tries to perform arithmetical operations.

Probably gcc/clang will optimize them without this optimization

@see http://en.wikipedia.org/wiki/Constant_folding

@param array              $expression
@param CompilationContext $compilationContext

@return bool|CompiledExpression
This tries to perform arithmetical operations .