Skip to content

Commit e212e1f

Browse files
committed
Vectorize SetTargetAtTime processing in AudioParamTimeline
https://bugs.webkit.org/show_bug.cgi?id=216673 <rdar://problem/69111432> Reviewed by Sam Weinig. Fix the SSE implementation of VectorMath::vsadd() to properly deal with source and destination alignment, similarly to what is done in other VectorMath functions. No new tests, fixes existing crash on GTK bots. * platform/audio/VectorMath.cpp: (WebCore::VectorMath::vsadd): Canonical link: https://commits.webkit.org/229503@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267240 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 1b00bb8 commit e212e1f

2 files changed

Lines changed: 47 additions & 8 deletions

File tree

Source/WebCore/ChangeLog

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
2020-09-18 Chris Dumez <cdumez@apple.com>
2+
3+
Vectorize SetTargetAtTime processing in AudioParamTimeline
4+
https://bugs.webkit.org/show_bug.cgi?id=216673
5+
<rdar://problem/69111432>
6+
7+
Reviewed by Sam Weinig.
8+
9+
Fix the SSE implementation of VectorMath::vsadd() to properly deal with source
10+
and destination alignment, similarly to what is done in other VectorMath functions.
11+
12+
No new tests, fixes existing crash on GTK bots.
13+
14+
* platform/audio/VectorMath.cpp:
15+
(WebCore::VectorMath::vsadd):
16+
117
2020-09-18 Zalan Bujtas <zalan@apple.com>
218

319
[LFC][IFC] Move computedLineLogicalRect to InlineFormattingContext::Geometry

Source/WebCore/platform/audio/VectorMath.cpp

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -264,17 +264,40 @@ void vsadd(const float* sourceP, int sourceStride, const float* scalar, float* d
264264

265265
#if CPU(X86_SSE2)
266266
if (sourceStride == 1 && destStride == 1) {
267-
__m128* pSource;
268-
__m128 scalarVector = _mm_set_ps1(*scalar);
267+
// If the sourceP address is not 16-byte aligned, the first several frames (at most three) should be processed separately.
268+
while ((reinterpret_cast<size_t>(sourceP) & 0x0F) && n) {
269+
*destP = *sourceP + *scalar;
270+
sourceP++;
271+
destP++;
272+
n--;
273+
}
269274

275+
// Now the sourceP address is aligned and start to apply SSE.
270276
int group = n / 4;
271-
while (group--) {
272-
pSource = reinterpret_cast<__m128*>(const_cast<float*>(sourceP));
273-
__m128 dest = _mm_add_ps(*pSource, scalarVector);
274-
_mm_storeu_ps(destP, dest);
277+
__m128 mScalar = _mm_set_ps1(*scalar);
278+
__m128* pSource;
279+
__m128* pDest;
280+
__m128 dest;
275281

276-
sourceP += 4;
277-
destP += 4;
282+
bool destAligned = !(reinterpret_cast<size_t>(destP) & 0x0F);
283+
if (destAligned) { // all aligned
284+
while (group--) {
285+
pSource = reinterpret_cast<__m128*>(const_cast<float*>(sourceP));
286+
pDest = reinterpret_cast<__m128*>(destP);
287+
*pDest = _mm_add_ps(*pSource, mScalar);
288+
289+
sourceP += 4;
290+
destP += 4;
291+
}
292+
} else {
293+
while (group--) {
294+
pSource = reinterpret_cast<__m128*>(const_cast<float*>(sourceP));
295+
dest = _mm_add_ps(*pSource, mScalar);
296+
_mm_storeu_ps(destP, dest);
297+
298+
sourceP += 4;
299+
destP += 4;
300+
}
278301
}
279302

280303
// Non-SSE handling for remaining frames which is less than 4.

0 commit comments

Comments
 (0)