From: commit-bot@chromium.org Date: Mon, 5 Aug 2013 20:25:57 +0000 (+0000) Subject: Minor sk_memset{16|32}_SSE2 optimization. X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~11422 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9772a52f0d9e540d2a360dde2aab0ad41c90b1d8;p=platform%2Fupstream%2FlibSkiaSharp.git Minor sk_memset{16|32}_SSE2 optimization. Using explicitly indexed references allows some compilers to generate more efficient loops. For gcc 4.6.3: 613c18: 83 ea 10 sub $0x10,%edx 613c1b: 66 0f 7f 07 movdqa %xmm0,(%rdi) 613c1f: 66 0f 7f 47 10 movdqa %xmm0,0x10(%rdi) 613c24: 66 0f 7f 47 20 movdqa %xmm0,0x20(%rdi) 613c29: 66 0f 7f 47 30 movdqa %xmm0,0x30(%rdi) 613c2e: 48 83 c7 40 add $0x40,%rdi 613c32: 83 fa 0f cmp $0xf,%edx 613c35: 7f e1 jg 613c18 <_Z16sk_memset32_SSE2Pjji+0x38> vs. previous: 613c18: 83 ea 10 sub $0x10,%edx 613c1b: 66 0f 7f 07 movdqa %xmm0,(%rdi) 613c1f: 66 0f 7f 47 10 movdqa %xmm0,0x10(%rdi) 613c24: 66 0f 7f 47 20 movdqa %xmm0,0x20(%rdi) 613c29: 48 83 c7 40 add $0x40,%rdi 613c2d: 83 fa 0f cmp $0xf,%edx 613c30: 66 0f 7f 47 f0 movdqa %xmm0,-0x10(%rdi) 613c35: 7f e1 jg 613c18 <_Z16sk_memset32_SSE2Pjji+0x38> This yields a 0.2% - 1% improvement with the memset micro benchmarks, presumably due to avoiding a stall on the next store after the %rdi increment. R=reed@google.com, senorblanco@chromium.org Author: fmalita@chromium.org Review URL: https://chromiumcodereview.appspot.com/21703003 git-svn-id: http://skia.googlecode.com/svn/trunk@10545 2bbb7eff-a529-9590-31e7-b0007b416f81 --- diff --git a/src/opts/SkUtils_opts_SSE2.cpp b/src/opts/SkUtils_opts_SSE2.cpp index 08e4f66..e22044d 100644 --- a/src/opts/SkUtils_opts_SSE2.cpp +++ b/src/opts/SkUtils_opts_SSE2.cpp @@ -25,10 +25,11 @@ void sk_memset16_SSE2(uint16_t *dst, uint16_t value, int count) __m128i *d = reinterpret_cast<__m128i*>(dst); __m128i value_wide = _mm_set1_epi16(value); while (count >= 32) { - _mm_store_si128(d++, value_wide); - _mm_store_si128(d++, value_wide); - _mm_store_si128(d++, value_wide); - _mm_store_si128(d++, value_wide); + _mm_store_si128(d , value_wide); + _mm_store_si128(d + 1, value_wide); + _mm_store_si128(d + 2, value_wide); + _mm_store_si128(d + 3, value_wide); + d += 4; count -= 32; } dst = reinterpret_cast(d); @@ -54,10 +55,11 @@ void sk_memset32_SSE2(uint32_t *dst, uint32_t value, int count) __m128i *d = reinterpret_cast<__m128i*>(dst); __m128i value_wide = _mm_set1_epi32(value); while (count >= 16) { - _mm_store_si128(d++, value_wide); - _mm_store_si128(d++, value_wide); - _mm_store_si128(d++, value_wide); - _mm_store_si128(d++, value_wide); + _mm_store_si128(d , value_wide); + _mm_store_si128(d + 1, value_wide); + _mm_store_si128(d + 2, value_wide); + _mm_store_si128(d + 3, value_wide); + d += 4; count -= 16; } dst = reinterpret_cast(d);