abs: Make value == ZEND_LONG_MIN an unexpected branch

As suggested in GH-12286. This results in slightly better assembly in clang,
because the expected case will be handled by a forward jump that is not taken.
This commit is contained in:
Tim Düsterhus 2023-09-24 17:20:23 +02:00
parent 865535267b
commit 9e66bc9b97
No known key found for this signature in database
GPG key ID: 8FF75566094168AF

View file

@ -260,7 +260,7 @@ PHP_FUNCTION(abs)
switch (Z_TYPE_P(value)) { switch (Z_TYPE_P(value)) {
case IS_LONG: case IS_LONG:
if (Z_LVAL_P(value) == ZEND_LONG_MIN) { if (UNEXPECTED(Z_LVAL_P(value) == ZEND_LONG_MIN)) {
RETURN_DOUBLE(-(double)ZEND_LONG_MIN); RETURN_DOUBLE(-(double)ZEND_LONG_MIN);
} else { } else {
RETURN_LONG(Z_LVAL_P(value) < 0 ? -Z_LVAL_P(value) : Z_LVAL_P(value)); RETURN_LONG(Z_LVAL_P(value) < 0 ? -Z_LVAL_P(value) : Z_LVAL_P(value));