julia icon indicating copy to clipboard operation
julia copied to clipboard

Fix fastmath for vararg +, *, min, max methods

Open Zentrik opened this issue 1 month ago • 0 comments

Currently using the fastmath vararg +, *, min, max methods only actually sets fastmath if they are specifically overloaded even when the correct 2 argument methods have been defined. As such, ComplexF32, ComplexF64 do not currently set fastmath when using the vararg methods. This will also fix any other types, such as those in SIMD.jl, which don't overload the vararg methods.

E.g.

x = ComplexF64(1)
f(x) = @fastmath x + x + x

now works correctly.

I see no reason why the vararg methods shouldn't default to using the fastmath 2 argument methods instead of the non fastmath ones, which is the current behaviour.

I also switched the implementation to use afoldl as that's what the non fastmath vararg methods use.

Fixes #54456 and https://github.com/eschnett/SIMD.jl/issues/108.

Zentrik avatar May 17 '24 21:05 Zentrik