[php-src] PR #25362: Build with SSE2 & fpmath=sse on x86
| From: | marc-mabe | Date: | Tue, 10 Nov 2026 09:06:39 +0000 |
| Subject: | [php-src] PR #25362: Build with SSE2 & fpmath=sse on x86 | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-40497@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25362
Author: marc-mabe
SSE2 is part of the x86-64 baseline, but optional on 32-bit x86, where GCC targets i686 by default.
Such builds miss the __SSE2__ code paths and compute doubles on the x87 unit.
x87 registers have a 15-bit exponent that zend_init_fpu() cannot clamp, so subnormal results are
rounded twice and can be one ULP off:
$a = 5.678650331314532e-158;
$b = 2.3715405351663569e-153;
var_dump($a * $b);
// x87: 1.34671494457485E-310
// SSE2 and 64-bit: 1.3467149445748E-310 (correctly rounded)
The new PHP_CHECK_SSE2 macro in build/php.m4, called from the platform-specific compile settings in
configure.ac, prepends to CFLAGS and CXXFLAGS on x86 targets:
- -msse2 if supported and not enabled by default;
- -mfpmath=sse if SSE2 is enabled and doubles do not use it by default. Clang does this by itself;
GCC needs the flag.
Configure warns but builds without SSE2 if the build machine cannot run SSE2 code. When cross
compiling, -msse2 is added without that check.
The resulting build requires SSE2. Pass CFLAGS=-mno-sse2 to build without SSE2.
phpize builds do not call the macro, but an extension can call PHP_CHECK_SSE2 from its config.m4.