Adding fmaddsub#1136
Merged
serge-sans-paille merged 1 commit intoxtensor-stack:masterfrom Jul 2, 2025
Merged
Conversation
| static constexpr bool get(unsigned const i, unsigned) noexcept { return (i & 1u) == 0; } | ||
| }; | ||
| const auto mask = make_batch_bool_constant<T, even_lane, A>(); | ||
| return fma(x, y, select(mask, neg(z), z)); |
Contributor
There was a problem hiding this comment.
Is select a better option compared to a multiply?
Contributor
Author
There was a problem hiding this comment.
I think multiply is overly complicated. If we extend batch_constant to double (remove bitwise operators) then it might be worth it.
struct imag_neg {
static constexpr int get(const unsigned i, unsigned) noexcept { return (i & 1u) ? 1.0 : -1.0; }
};
// Generator first, then arch
const auto mask = xsimd::batch_cast<double>(xsimd::make_batch_constant<xsimd::as_integer_t<double>, imag_neg, arch>().as_batch());Also, I do not see a big difference on my machine:

(swizzle/multiply vs swizzle/select)
Contributor
There was a problem hiding this comment.
thanks for going all the way down to the experiment!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi all,
I have added support and tests for fmaddsub since it is useful in my scientific computations.
I tested it on x86 but I do not have access to arm/neon.
I proposed fmas but I have no strong opinion on the name of the function I picked something that seems to fit the style.
Let me know what you think and if/how we can get the new API included!
Thanks,
Marco