[php-src] PR #24179: JIT: add ZEND_BW_NOT handler for integer operands
| From: | adapik | Date: | Wed, 07 Oct 2026 17:28:18 +0000 |
| Subject: | [php-src] PR #24179: JIT: add ZEND_BW_NOT handler for integer operands | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-39239@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/24179
Author: adapik
ZEND_BW_NOT is currently the only bitwise opcode without a JIT handler:
BW_OR, BW_AND, BW_XOR, SL and SR
are all compiled. As a result, an expression such as ~$a & $b breaks the compiled
code with a call into the VM handler, and values kept in registers have to be spilled around it.
This and-not combination shows up in bit-manipulation code such as hash functions, checksums and
other algorithms.
This PR adds a handler for the case where the operand is known to be int. Any other
operand type (string, float, bool, null, array, object, undefined, constant) is not handled and
keeps going through the VM handler, so behaviour,
warnings and TypeError messages are unchanged.
Release build (-O2), x86-64, best of several runs, 20M iterations of
$s ^= (~$a & $b) ^ ($i << 3):
| JIT | before | after |
|---|---|---|
| tracing | 0.037s | 0.011s |
| function | 0.036s | 0.025s |
This is a micro-benchmark that isolates the affected pattern.