This page contains an overview of optimizations that C++ compilers can perform on C++ code that is common in Blend2D. It was decided that the source code should avoid hand-written optimizations that C++ compilers can do easily. These optimizations include vectorization of floating point computations and exclude vectorization of integral computations as these are trickier. Each item in the tables below has a link to a Compiler Explorer that can be used to verify the current status of the feature. We expect compilers to improve in the future and we would be happy to see the status of all features as resolved.
|Optimized initialization of data / structs||Yes||Yes||Only 32-bit|
|Optimized reads/writes of small ints||Yes||Yes||No|
Blend2D compiles with
-fno-math-errno by default, but doesn't use
-ffast-math as that is considered unsafe. With these options both GCC and Clang produce pretty good machine code for FP operations and rounding. MSVC doesn't have
-fno-math-errno option so we use
__pragma(float_control()) locally to make the code it generates a bit better, but in many cases it cannot compete with what GCC/Clang can do.
|Optimized isnan()||Yes||Yes||No [bug]|
|Optimized isnan() [multiple checks]||Clang 9+ [bug]||Yes||No|
|Optimized min(), max(), and conditional expressions||Yes||Yes||Yes|
|Optimized nearbyint()||Yes||GCC 9+||No|
Blend2D expects C++ compiler to automatically vectorize computations that happen in pairs. Some data structures like
BLPoint are used as like they were 128-bit SIMD registers representing two double precision floating points.
|Vectorized division||Yes||GCC 8 regresses||v19.20+|
|Vectorized min() / max()||Yes||No||No|
|Vectorized sqrt()||Clang 6+||GCC 7+||No|
|Vectorized lerp()||Yes||GCC 7+||No|
|Vectorized affine matrix multiplication||Clang 7+||No||No|
|Vectorized evaluation of quadratic curve||Clang 7+||GCC 9+||No|
|Vectorized evaluation of cubic curve||Clang 7+||GCC 9+||No|
|Vectorized extrema of quadratic curve||Clang 7+||No||No|
|Vectorized computation of unit vector||Yes||No||No|
|Vectorized intersection of two lines||No||No||No|