Skip to content

Commit 5f4d1f7

Browse files
authored
[libclc] Make CLC library warning-free (#128864)
There is a long-standing workaround in the libclc build system that silences a warning about the use of parentheses in bitwise conditional operations. In an effort to remove this workaround, this commit re-enables the warning on the internal CLC library, where most of the bodies of the builtins will eventually be defined. Thus as we move builtin implementations into this library, the warnings will trigger and we can clean up the codebase as we go. As it happens the only instance in the CLC library which triggered the warning was in __clc_ldexp.
1 parent 900220d commit 5f4d1f7

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

libclc/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,6 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
377377
-D${CLC_TARGET_DEFINE}
378378
# All libclc builtin libraries see CLC headers
379379
-I${CMAKE_CURRENT_SOURCE_DIR}/clc/include
380-
# FIXME: Fix libclc to not require disabling this noisy warning
381-
-Wno-bitwise-conditional-parentheses
382380
)
383381

384382
if( NOT "${cpu}" STREQUAL "" )
@@ -400,6 +398,8 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
400398

401399
list( APPEND build_flags
402400
-I${CMAKE_CURRENT_SOURCE_DIR}/generic/include
401+
# FIXME: Fix libclc to not require disabling this noisy warning
402+
-Wno-bitwise-conditional-parentheses
403403
)
404404

405405
add_libclc_builtin_set(

libclc/clc/lib/generic/math/clc_ldexp.cl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ _CLC_DEF_ldexp _CLC_OVERLOAD float __clc_ldexp(float x, int n) {
4141
int s = i & 0x80000000;
4242
int v = __clc_add_sat(e, n);
4343
v = __clc_clamp(v, 0, 0xff);
44-
int mr = e == 0 | v == 0 | v == 0xff ? 0 : m;
44+
int mr = (e == 0 || v == 0 || v == 0xff) ? 0 : m;
4545
int c = e == 0xff;
4646
mr = c ? m : mr;
4747
int er = c ? e : v;
@@ -96,7 +96,7 @@ _CLC_DEF_ldexp _CLC_OVERLOAD float __clc_ldexp(float x, int n) {
9696
val_ui = dexp == 0 ? dval_ui : val_ui;
9797
val_f = __clc_as_float(val_ui);
9898

99-
val_f = __clc_isnan(x) | __clc_isinf(x) | val_x == 0 ? x : val_f;
99+
val_f = (__clc_isnan(x) || __clc_isinf(x) || val_x == 0) ? x : val_f;
100100
return val_f;
101101
}
102102

0 commit comments

Comments
 (0)