From 6f47304884e8a71a71ac628080262ad2733a1dac Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sat, 8 Jun 2019 06:47:16 -0400 Subject: [PATCH] Add note about alignment of Vector::load() --- include/simd/vector.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/simd/vector.hpp b/include/simd/vector.hpp index d056be33..5be44311 100644 --- a/include/simd/vector.hpp +++ b/include/simd/vector.hpp @@ -84,6 +84,11 @@ struct Vector { /** Reads an array of 4 values. */ static Vector load(const float *x) { + /* + My benchmarks show that _mm_loadu_ps() performs equally as fast as _mm_load_ps() when data is actually aligned. + This post seems to agree. https://stackoverflow.com/a/20265193/272642 + So use _mm_loadu_ps() for generality, so you can load unaligned arrays using the same function (although it will be slower). + */ return Vector(_mm_loadu_ps(x)); }