Optimize qt_memfill32 a little
Benchmarking shows it took up to 3.5% of Qt Creator's initialization cost. Optimize by modifying only one variable per loop: instead of updating n and dst128, we only update one variable at a time. Removing the Duff's Device also improves the code, since the compiler won't try to update dst128 four times per loop, only once. The moving of the epilogue close to the prologue was just to make the code a little cleaner. Change-Id: I5b74e27d520ca821f380aef0533c244805f003b7 Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>bb10
parent
af8c35bda4
commit
ab1ec81f58
|
|
@ -259,19 +259,6 @@ void qt_memfill32(quint32 *dest, quint32 value, int count)
|
|||
case 12: *dest++ = value; --count;
|
||||
}
|
||||
|
||||
int count128 = count / 4;
|
||||
__m128i *dst128 = reinterpret_cast<__m128i*>(dest);
|
||||
const __m128i value128 = _mm_set_epi32(value, value, value, value);
|
||||
|
||||
int n = (count128 + 3) / 4;
|
||||
switch (count128 & 0x3) {
|
||||
case 0: do { _mm_stream_si128(dst128++, value128);
|
||||
case 3: _mm_stream_si128(dst128++, value128);
|
||||
case 2: _mm_stream_si128(dst128++, value128);
|
||||
case 1: _mm_stream_si128(dst128++, value128);
|
||||
} while (--n > 0);
|
||||
}
|
||||
|
||||
const int rest = count & 0x3;
|
||||
if (rest) {
|
||||
switch (rest) {
|
||||
|
|
@ -280,6 +267,25 @@ void qt_memfill32(quint32 *dest, quint32 value, int count)
|
|||
case 1: dest[count - 1] = value;
|
||||
}
|
||||
}
|
||||
|
||||
int count128 = count / 4;
|
||||
__m128i *dst128 = reinterpret_cast<__m128i*>(dest);
|
||||
__m128i *end128 = dst128 + count128;
|
||||
const __m128i value128 = _mm_set_epi32(value, value, value, value);
|
||||
|
||||
while (dst128 + 3 < end128) {
|
||||
_mm_stream_si128(dst128 + 0, value128);
|
||||
_mm_stream_si128(dst128 + 1, value128);
|
||||
_mm_stream_si128(dst128 + 2, value128);
|
||||
_mm_stream_si128(dst128 + 3, value128);
|
||||
dst128 += 4;
|
||||
}
|
||||
|
||||
switch (count128 & 0x3) {
|
||||
case 3: _mm_stream_si128(dst128++, value128);
|
||||
case 2: _mm_stream_si128(dst128++, value128);
|
||||
case 1: _mm_stream_si128(dst128++, value128);
|
||||
}
|
||||
}
|
||||
|
||||
void QT_FASTCALL comp_func_solid_SourceOver_sse2(uint *destPixels, int length, uint color, uint const_alpha)
|
||||
|
|
|
|||
Loading…
Reference in New Issue