forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[libclc] Optimize CLC vector is(un)ordered builtins (llvm#124546)
These are similar to 347fb20, but these builtins are expressed in terms of other builtins. The LLVM IR generated features the same fcmp ord/uno comparisons as before, but consistently in vector form.
- Loading branch information
1 parent
f1d5e70
commit eaa5897
Showing
3 changed files
with
18 additions
and
109 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,30 @@ | ||
#include <clc/internal/clc.h> | ||
#include <clc/relational/clc_isequal.h> | ||
#include <clc/relational/relational.h> | ||
|
||
// Note: It would be nice to use __builtin_isunordered with vector inputs, but | ||
// it seems to only take scalar values as input, which will produce incorrect | ||
// output for vector input types. | ||
#define _CLC_RELATIONAL_OP(X, Y) \ | ||
!__clc_isequal((X), (X)) || !__clc_isequal((Y), (Y)) | ||
|
||
_CLC_DEFINE_RELATIONAL_BINARY(int, __clc_isunordered, __builtin_isunordered, | ||
float, float) | ||
_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, int, __clc_isunordered, float, float) | ||
|
||
#ifdef cl_khr_fp64 | ||
|
||
#pragma OPENCL EXTENSION cl_khr_fp64 : enable | ||
|
||
// The scalar version of __clc_isunordered(double, double) returns an int, but | ||
// the vector versions return long. | ||
|
||
_CLC_DEF _CLC_OVERLOAD int __clc_isunordered(double x, double y) { | ||
return __builtin_isunordered(x, y); | ||
} | ||
|
||
_CLC_DEFINE_RELATIONAL_BINARY_VEC_ALL(long, __clc_isunordered, double, double) | ||
_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, long, __clc_isunordered, double, double) | ||
|
||
#endif | ||
|
||
#ifdef cl_khr_fp16 | ||
|
||
#pragma OPENCL EXTENSION cl_khr_fp16 : enable | ||
|
||
// The scalar version of __clc_isunordered(half, half) returns an int, but the | ||
// vector versions return short. | ||
|
||
_CLC_DEF _CLC_OVERLOAD int __clc_isunordered(half x, half y) { | ||
return __builtin_isunordered(x, y); | ||
} | ||
|
||
_CLC_DEFINE_RELATIONAL_BINARY_VEC_ALL(short, __clc_isunordered, half, half) | ||
_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, short, __clc_isunordered, half, half) | ||
|
||
#endif | ||
|
||
#undef _CLC_RELATIONAL_OP |