OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkOpts.h" | 8 #include "SkOpts.h" |
9 | 9 |
| 10 namespace sse2 { // This helps identify methods from this file when debugging /
profiling. |
| 11 |
| 12 static void memset16(uint16_t* dst, uint16_t val, int n) { |
| 13 auto dst8 = (__m128i*)dst; |
| 14 auto val8 = _mm_set1_epi16(val); |
| 15 for ( ; n >= 8; n -= 8) { |
| 16 _mm_storeu_si128(dst8++, val8); |
| 17 } |
| 18 dst = (uint16_t*)dst8; |
| 19 if (n & 4) { |
| 20 _mm_storel_epi64((__m128i*)dst, val8); |
| 21 dst += 4; |
| 22 } |
| 23 if (n & 2) { |
| 24 *(uint32_t*)dst = _mm_cvtsi128_si32(val8); |
| 25 dst += 2; |
| 26 } |
| 27 if (n & 1) { |
| 28 *dst = val; |
| 29 } |
| 30 } |
| 31 |
| 32 static void memset32(uint32_t* dst, uint32_t val, int n) { |
| 33 auto dst4 = (__m128i*)dst; |
| 34 auto val4 = _mm_set1_epi32(val); |
| 35 for ( ; n >= 4; n -= 4) { |
| 36 _mm_storeu_si128(dst4++, val4); |
| 37 } |
| 38 dst = (uint32_t*)dst4; |
| 39 if (n & 2) { |
| 40 _mm_storel_epi64((__m128i*)dst, val4); |
| 41 dst += 2; |
| 42 } |
| 43 if (n & 1) { |
| 44 *dst = val; |
| 45 } |
| 46 } |
| 47 |
| 48 } // namespace sse2 |
| 49 |
10 namespace SkOpts { | 50 namespace SkOpts { |
11 void Init_sse2() { | 51 void Init_sse2() { |
12 | 52 memset16 = sse2::memset16; |
| 53 memset32 = sse2::memset32; |
13 } | 54 } |
14 } | 55 } |
OLD | NEW |