Skip to content

Commit b5868b9

Browse files
authored
Satisfy Complex muladd TODO for mulsub with negated muladd (#36140)
Modern LLVM has sufficient optimizations to translate muladds with multiple negations into the appropriate fused-multiple-subtract instructions on x86_64.
1 parent 162cde1 commit b5868b9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

base/complex.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ inv(z::Complex{<:Integer}) = inv(float(z))
278278
real(z) * imag(w) + imag(z) * real(w))
279279

280280
muladd(z::Complex, w::Complex, x::Complex) =
281-
Complex(muladd(real(z), real(w), real(x)) - imag(z)*imag(w), # TODO: use mulsub given #15985
282-
muladd(real(z), imag(w), muladd(imag(z), real(w), imag(x))))
281+
Complex(muladd(real(z), real(w), -muladd(imag(z), imag(w), -real(x))),
282+
muladd(real(z), imag(w), muladd(imag(z), real(w), imag(x))))
283283

284284
# handle Bool and Complex{Bool}
285285
# avoid type signature ambiguity warnings
@@ -326,7 +326,7 @@ muladd(z::Complex, x::Real, w::Complex) =
326326
Complex(muladd(real(z),x,real(w)), muladd(imag(z),x,imag(w)))
327327
muladd(x::Real, y::Real, z::Complex) = Complex(muladd(x,y,real(z)), imag(z))
328328
muladd(z::Complex, w::Complex, x::Real) =
329-
Complex(muladd(real(z), real(w), x) - imag(z)*imag(w), # TODO: use mulsub given #15985
329+
Complex(muladd(real(z), real(w), -muladd(imag(z), imag(w), -x)),
330330
muladd(real(z), imag(w), imag(z) * real(w)))
331331

332332
/(a::R, z::S) where {R<:Real,S<:Complex} = (T = promote_type(R,S); a*inv(T(z)))

0 commit comments

Comments
 (0)