-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libclc] Move minmag & maxmag to the CLC library #137982
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
const __CLC_GENTYPE res = __clc_select( | ||
y, x, | ||
__CLC_CONVERT_BIT_INTN(__clc_isgreater(__clc_fabs(x), __clc_fabs(y)))); | ||
return __clc_select( | ||
res, __clc_fmax(x, y), | ||
__CLC_CONVERT_BIT_INTN(__clc_isnan(x) || __clc_isnan(y) || | ||
__clc_isequal(__clc_fabs(x), __clc_fabs(y)))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a lot more code than is needed. Why the isequal or conversions? This should be 1 fmax, 2 fabs + 2 select?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it does seem excessive. I don't really understand the isequal
.
The conversions are necessary because select
only accepts conditions of the same size as the vector, but the scalar relational functions unhelpfully return int
even for double
. There's no implicit conversions on vector types so we need the explicit select. This all comes out in the wash as in LLVM IR it's just i1
types fed from comparison to select anyway.
I've been wondering if we could alleviate this through extra overloads of __clc_select
that accept intN conditions across the board, but that might also lead to some confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just use ternary operator, I don't see what the select is adding other than complexity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a move but the implementation could be better
No description provided.