From 8d029a4ebeda9d99c40b864e9c93c55be58b05af Mon Sep 17 00:00:00 2001 From: mtklein Date: Mon, 26 Jan 2015 07:07:03 -0800 Subject: [PATCH] Don't do a pointless << 0. It's very common (universal?) that alpha is the top byte. You'd hope the compiler would remove the left shift then, but I've seen Clang just do a dumb left shift of zero. :( BUG=skia: Review URL: https://codereview.chromium.org/872243003 --- src/opts/SkColor_opts_SSE2.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/opts/SkColor_opts_SSE2.h b/src/opts/SkColor_opts_SSE2.h index 95fb69cceb..970abb859b 100644 --- a/src/opts/SkColor_opts_SSE2.h +++ b/src/opts/SkColor_opts_SSE2.h @@ -81,8 +81,12 @@ static inline __m128i SkAlphaMulQ_SSE2(const __m128i& c, const unsigned scale) { } static inline __m128i SkGetPackedA32_SSE2(const __m128i& src) { +#if SK_A32_SHIFT == 24 // It's very common (universal?) that alpha is the top byte. + return _mm_srli_epi32(src, 24); // You'd hope the compiler would remove the left shift then, +#else // but I've seen Clang just do a dumb left shift of zero. :( __m128i a = _mm_slli_epi32(src, (24 - SK_A32_SHIFT)); return _mm_srli_epi32(a, 24); +#endif } static inline __m128i SkGetPackedR32_SSE2(const __m128i& src) {