From 9e66bc9b97878b6c044dbcade404a93fa25b338f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sun, 24 Sep 2023 17:20:23 +0200 Subject: [PATCH] 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. --- ext/standard/math.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/standard/math.c b/ext/standard/math.c index 68f15d0bf27..734ebaba075 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -260,7 +260,7 @@ PHP_FUNCTION(abs) switch (Z_TYPE_P(value)) { 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); } else { RETURN_LONG(Z_LVAL_P(value) < 0 ? -Z_LVAL_P(value) : Z_LVAL_P(value));