-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Satisfy TODO in Complex muladd #36140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Is
|
I don't think so. The IEEE spec doesn't discuss complex numbers, and the C spec doesn't define an FMA for them.
Agreed: "fusing" is a necessary property of |
|
OK, I was concerned that that might be the response, but I thought I'd give it a try.
|
|
Doesn’t the complex muladd already do that? We should change the TODOs now that the mulsub issue is resolved: did you want to update the PR to do that? |
Yes — what I meant was that for the real case, I want to force
Sure, I can do that. |
Modern LLVM has sufficient optimizations to translate muladds with multiple negations into the appropriate fused-multiple-subtract instructions on x86_64.
|
OK, I've replaced the original commits with a new one which simply completes the |
|
Thanks! |
…#36140) Modern LLVM has sufficient optimizations to translate muladds with multiple negations into the appropriate fused-multiple-subtract instructions on x86_64.
This PR has reduced in scope/changed goals. The original message is shown below, but the purpose now is to simply satisfy an old TODO in the definition of
muladdforComplexarguments that mentions a "future"mulsubfunction. Themulsubfunction was never added (see #15985), and modern LLVM's optimizations are sufficient to take a sequence ofmuladdand negations and turn it into the corresponding fused multiply-subtract where appropriate.PR #15980 defined
muladdforComplex(and various combinations of mixedComplex-Real) arguments. It seems the same could (should?) be done forfmaas well.The original TODO comments concerning a future
mulsubno longer apply since LLVM appears to be capable of reconstructing the fused multiply-subtract, as already mentioned recently in #35562 (comment):For a motivating reason, I've been working on an algorithm where
fmaon real inputs is necessary for maintaining as much numerical accuracy as possible, but the mathematical function is technically defined over the complex domain as well. Without appropriate definitions offmaforComplex, the algorithm currently fails for complex arguments (or requires an extra type-based branch to fall back tomuladd, which would give divergent answers when the complex input is located on the real axis).