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>
This commit is contained in:
parent
5127998795
commit
bb29f4353b
@ -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(); }
|
||||
|
Loading…
Reference in New Issue
Block a user