Skip to content

Commit 8655352

Browse files
committedSep 24, 2023
round: Make fractional == 0.5 an unexpected branch
This does indeed result in slightly better assembly for clang.
1 parent 4834e7e commit 8655352

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎ext/standard/math.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static inline double php_round_helper(double value, int mode) {
131131
return integral + copysign(1.0, integral);
132132
}
133133

134-
if (fractional == 0.5) {
134+
if (UNEXPECTED(fractional == 0.5)) {
135135
bool even = !fmod(integral, 2.0);
136136

137137
/* 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) {
148148
return integral + copysign(1.0, integral);
149149
}
150150

151-
if (fractional == 0.5) {
151+
if (UNEXPECTED(fractional == 0.5)) {
152152
bool even = !fmod(integral, 2.0);
153153

154154
if (even) {

0 commit comments

Comments
 (0)