diff --git a/include/arbor/simd/simd.hpp b/include/arbor/simd/simd.hpp index 4a319216543370ccb8487630c406e06cf1cb67ac..535b823347032728893b5e82d6cce5ddc25da662 100644 --- a/include/arbor/simd/simd.hpp +++ b/include/arbor/simd/simd.hpp @@ -220,9 +220,15 @@ namespace simd_detail { scalar_type a[width]; Impl::copy_to(s, a); - for (unsigned i = 0; i<width; ++i) { - p[o[i]] += a[i]; + scalar_type temp = 0; + for (unsigned i = 0; i<width-1; ++i) { + temp += a[i]; + if (o[i] != o[i+1]) { + p[o[i]] += temp; + temp = 0; + } } + p[o[width-1]] = temp; } break; case index_constraint::independent: