Source file src/simd/archsimd/ops_emulated_arm64.go

     1  // Copyright 2026 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build goexperiment.simd && arm64
     6  
     7  package archsimd
     8  
     9  // ReduceSum returns the sum of all elements in x.
    10  //
    11  // Emulated, CPU Feature: NEON
    12  func (x Float32x4) ReduceSum() float32 {
    13  	x = x.ConcatAddPairs(x) // [x0+x1, x2+x3, x0+x1, x2+x3]
    14  	x = x.ConcatAddPairs(x) // [(x0+x1)+(x2+x3), ...]
    15  	return x.GetElem(0)
    16  }
    17  
    18  // ReduceSum returns the sum of all elements in x.
    19  //
    20  // Emulated, CPU Feature: NEON
    21  func (x Float64x2) ReduceSum() float64 {
    22  	return x.ConcatAddPairs(x).GetElem(0) // [x0+x1, x0+x1]
    23  }
    24  

View as plain text