[Development] Enabling SSE2 by default on x86 builds (32-bit)

Thiago Macieira thiago.macieira at intel.com
Sun Nov 10 08:19:03 CET 2013

This came up as an impromptu discussion during Dev Days.

According to Lars and Simon, the new V4's JIT engine generates floating-point 
math for QML only using SSE registers on x86. That means the JIT code cannot 
run on CPUs that don't have SSE support. Those CPUs can only run the 
interpreted bytecode instead.

Also, please consider that MS Visual Studio 2012 has switched to using SSE2 
instructions by default. The old behaviour can be obtained by passing the 
appropriate command-line arguments.

Here's what we're proposing:
1) in the Linux 32-bit packages generated by the Qt Project, we switch to 
generating SSE2 code by default and also ask GCC to use that instead of x87 
for FPU operations (add to the command-line: -msse2 -mfpmath=sse).

2) remove the AVX-based drawhelpers and leave only the SSE2-based ones, with 
*no* runtime check. The SSSE3 improvements will still be runtime checked (they 
are only a handful of functions, which are easy to contain). Simultaneously, 
we'll apply the same change to the ARM Neon-based drawhelpers, which are 
giving us headaches: no runtime detection.

3) the default for source builds should be also the above. The original 
behaviour can be restored by passing -no-sse2 to configure. That will also 
disable the SSE2-based draw helpers completely. With MSVC, since the switch 
comes from the compiler, users need to modify their qmake.conf in addition to 
passing the extra option to configure.

4) this change to be implemented in 5.3.0.

Additional benefits of this change are:
 a) all FP math done in Qt will be done using SSE instead of the slower x87 

 b) the drawhelpers will be unconditionally enabled

 c) the SSE2-based code for the Latin1 and UTF-8 codecs will be 
unconditionally enabled

We honestly do not expect anyone who's actually building Qt 5 from sources to 
be targetting a CPU made prior to 2004 (with the exception of the 2013 Intel 
Quark). There may be a few people who download from sources and try to run on 
CPUs older than Intel Pentium-M, Intel Pentium 4, AMD Opteron and Athlon 64. 
Those people will be forced to switch to a source build instead.

No one using Mac OS X will be affected. All compilers for Mac OS X already 
enable SSSE3 by default, even in 32-bit mode, since the first CPUs where that 
OS ran already had support for SSSE3.

On Windows, as I said above, MSVC 2012 builds will not be affected, since they 
already target SSE2. However, the MinGW and MSVC 2010 builds will be: they 
will also begin targeting SSE2-capable CPUs.

The major party affected with this change will be Linux distributions. We'd 
like to encourage Linux distributions to seriously consider whether any of 
their users are likely to use Qt 5 for those older CPUs. If they do not have a 
strong reason to keep old CPU support, they should leave the defaults alone 
and let the minimum requirement include support for SSE2.

If the distribution really requires support for those older CPUs, we highly 
recommend you compile Qt 5 libraries twice and install the SSE2-requiring 
version in $prefix/lib/sse2. The Linux dynamic linker searches for libraries 
there on its own already and has done that for a really long time. All 
binaries should come only from the -no-sse2 build.

If you cannot or will not do that, then you will need to build with -no-sse2, 
incurring performance penalties to your users.

Finally, anyone trying to run Qt 5 on the Intel Quark should pass -no-sse2 
anyway, since that CPU does not and will not have SSE or MMX support, so 
there's no point in even wasting precious CPU cycles to detect support (the 
Quark does have the CPUID instruction). You probably want to trim down the Qt 
build anyway.

Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/development/attachments/20131110/44cf8689/attachment.bin 

More information about the Development mailing list