Hi everyone, I've been experimenting with the archsimd package and I noticed something confusing, and was hoping for some feedback.
The method Float64x4.MulAddEvenSubOdd (
https://cs.opensource.google/go/go/+/refs/tags/go1.27.0:src/simd/archsimd/ops_amd64.go;l=4155) says it implements "Asm: VFMADDSUB213PD, CPU Feature: FMA".
The doc comment for Float64x4.MulAddEvenSubOdd (
https://pkg.go.dev/simd/arch...@go1.27.0#Float64x4.MulAddEvenSubOdd) says "MulAddEvenSubOdd performs a fused (x * y) - z for odd-indexed elements, and (x * y) + z for even-indexed elements." but the actual behaviour, and the documentation for the actual VFMADDSUB213PD instruction seem to say that's actually backwards.
"VFMADDSUB213PD: Multiplies the two, four, or eight packed double precision floating-point values from the second source operand to the two or four packed double precision floating-point values in the first source operand. From the infinite precision intermediate result,
adds the odd double precision floating-point elements and subtracts the even double precision floating-point values in the third source operand, performs rounding and stores the resulting two or four packed double precision floating-point values to the destination operand (first source operand)."
https://www.felixcloutier.com/x86/vfmaddsub132pd:vfmaddsub213pd:vfmaddsub231pd It doesn't seem to be an actual bug in the package, but it does seem to be a bug in the doc comment, and possibly the function name, and a quick google search seems to show that this is a known misunderstanding about this family of functions related to the order of the operands. If the comment is wrong, it's probably also wrong for all of the related functions (MulAddEvenSubOdd and MulAddOddSubEven on all types).
Am I just misunderstanding the naming conventions here?
Thanks,
Mike.