From 865535267b7e3f7427cbe7c4ae3a227fa86994ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sun, 24 Sep 2023 16:50:53 +0200 Subject: [PATCH] round: Make `fractional == 0.5` an unexpected branch This does indeed result in slightly better assembly for clang. --- ext/standard/math.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/standard/math.c b/ext/standard/math.c index b43e76ffb01..68f15d0bf27 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -131,7 +131,7 @@ static inline double php_round_helper(double value, int mode) { return integral + copysign(1.0, integral); } - if (fractional == 0.5) { + if (UNEXPECTED(fractional == 0.5)) { bool even = !fmod(integral, 2.0); /* If the integral part is not even we can make it even @@ -148,7 +148,7 @@ static inline double php_round_helper(double value, int mode) { return integral + copysign(1.0, integral); } - if (fractional == 0.5) { + if (UNEXPECTED(fractional == 0.5)) { bool even = !fmod(integral, 2.0); if (even) {