From e3b110dc6e5f7e1c2bdeb16d4d0ca03221c5ee25 Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Tue, 16 Apr 2019 11:36:55 -0500 Subject: [PATCH] align skvx::Vec to N*sizeof(T) This increases the alignment of these vector types. I would have liked to keep the alignment minimal, but it's probably no big deal either way. In terms of code generation, it doesn't make much difference for x86 or ARMv8, but it seems hugely important for good ARMv7 NEON code. It's a ~10x difference for the bench I've been playing around with that spends most of its time in that SkOpts::blit_row_color32 routine. Bug: chromium:952502 Change-Id: Ib12caad6b9b3f3f6e821ed70bfb57099db37b15f Reviewed-on: https://skia-review.googlesource.com/c/skia/+/208581 Commit-Queue: Michael Ludwig Reviewed-by: Michael Ludwig Auto-Submit: Mike Klein --- include/private/SkVx.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/private/SkVx.h b/include/private/SkVx.h index 66d63d9b04..310ac4e3c0 100644 --- a/include/private/SkVx.h +++ b/include/private/SkVx.h @@ -16,7 +16,9 @@ // // We've also fixed a few of the caveats that used to make SkNx awkward to work // with across translation units. skvx::Vec always has N*sizeof(T) size -// and alignof(T) alignment and is safe to use across translation units freely. +// and alignment and is safe to use across translation units freely. +// +// (Ideally we'd only align to T, but that tanks ARMv7 NEON codegen.) #include "SkTypes.h" // SK_CPU_SSE_LEVEL*, etc. #include // std::min, std::max @@ -38,7 +40,7 @@ namespace skvx { // This gives Vec a consistent ABI, letting them pass between files compiled with // different instruction sets (e.g. SSE2 and AVX2) without fear of ODR violation. template -struct Vec { +struct alignas(N * sizeof(T)) Vec { static_assert((N & (N-1)) == 0, "N must be a power of 2."); Vec lo, hi;