Skip to content
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

Added MinMagnitude and MaxMagnitude ops #2353

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

johnplatts
Copy link
Contributor

Added the MinMagnitude and MaxMagnitude ops as the upcoming AVX10.2 instruction set will have VMINMAXPH/VMINMAXPS/VMINMAXPD instructions that can carry out the MinMagnitude and MaxMagnitude operations for F16/F32/F64 vectors.

Copy link
Member

@jan-wassenberg jan-wassenberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding!

const auto abs_a = Abs(a);
const auto abs_b = Abs(b);
return IfThenElse(Lt(abs_a, abs_b), a,
Min(IfThenElse(Eq(abs_a, abs_b), a, b), b));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat trick to match the x86 |a| < |b|, |b| < |a|, min(a, b) cases :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants