Skip to content

Conversation

@frasercrmck
Copy link
Contributor

No description provided.

@frasercrmck frasercrmck added the libclc libclc OpenCL library label Apr 30, 2025
@frasercrmck frasercrmck requested a review from arsenm April 30, 2025 16:00
Comment on lines +11 to +17
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))));
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor

@arsenm arsenm left a 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

@frasercrmck frasercrmck merged commit 6c4dd8d into llvm:main May 1, 2025
11 checks passed
@frasercrmck frasercrmck deleted the libclc-clc-minmag-maxmag branch May 1, 2025 08:49
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
GeorgeARM pushed a commit to GeorgeARM/llvm-project that referenced this pull request May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libclc libclc OpenCL library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants