aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkOpts.cpp
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2017-08-23 10:42:28 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-23 15:11:25 +0000
commitbb29f4353b138faccc35960c983fbc360486c0c8 (patch)
tree31480a22fad5cd06438ad849c57f4ffecaa13beb /src/core/SkOpts.cpp
parent51279987957a64d0f1a9cf7d299a8689734a0e50 (diff)
add compile-time not-supported checks to runtime CPU checks
There's no reason to call Init_ssse3() if we know Skia's built globally with SSSE3. And there's definitely no reason to call Init_ssse3() if Skia's build globally with SSE4.1+. These are the only places the Init_foo() methods are called, and those in turn are the only places that refer to their optimized routines, so guarding like this allows redundant routines to be dead-code stripped by the linker. There are still situations where we end up with two copies of the same routine, compiled at _the same_ optimization level. If you're on a Mac and have SSSE3 or SSE4.1 as your global baseline instruction set, you'll get two copies, one from SkOpts.o's defaults, and one from SkOpts_{ssse3,sse41}.o's "better" routines. I'm still thinking about how to best fix this. Might just be as simple as removing "static" and letting the linker dedup. This cuts off about 70K of code on a build of ok. Change-Id: Ia349d2c5299072bbd43966132798500de059b9ca Reviewed-on: https://skia-review.googlesource.com/37600 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src/core/SkOpts.cpp')
-rw-r--r--src/core/SkOpts.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/core/SkOpts.cpp b/src/core/SkOpts.cpp
index 724f53d966..4131546485 100644
--- a/src/core/SkOpts.cpp
+++ b/src/core/SkOpts.cpp
@@ -96,10 +96,21 @@ namespace SkOpts {
static void init() {
#if !defined(SK_BUILD_NO_OPTS)
#if defined(SK_CPU_X86)
- if (SkCpu::Supports(SkCpu::SSSE3)) { Init_ssse3(); }
- if (SkCpu::Supports(SkCpu::SSE41)) { Init_sse41(); }
- if (SkCpu::Supports(SkCpu::SSE42)) { Init_sse42(); }
- if (SkCpu::Supports(SkCpu::AVX )) { Init_avx(); }
+ #if SK_CPU_SSE_LEVEL < SK_CPU_SSE_LEVEL_SSSE3
+ if (SkCpu::Supports(SkCpu::SSSE3)) { Init_ssse3(); }
+ #endif
+
+ #if SK_CPU_SSE_LEVEL < SK_CPU_SSE_LEVEL_SSE41
+ if (SkCpu::Supports(SkCpu::SSE41)) { Init_sse41(); }
+ #endif
+
+ #if SK_CPU_SSE_LEVEL < SK_CPU_SSE_LEVEL_SSE42
+ if (SkCpu::Supports(SkCpu::SSE42)) { Init_sse42(); }
+ #endif
+
+ #if SK_CPU_SSE_LEVEL < SK_CPU_SSE_LEVEL_AVX
+ if (SkCpu::Supports(SkCpu::AVX )) { Init_avx(); }
+ #endif
#elif defined(SK_CPU_ARM64)
if (SkCpu::Supports(SkCpu::CRC32)) { Init_crc32(); }