libclc: Fix signed integer underflow in abs_diff
We noticed this same issue in our own implementation of abs_diff, and the same issue also came up in the abs_diff reference function in the OpenCL CTS. Reviewed By: rjodinchr Differential Revision: https://reviews.llvm.org/D159275
This commit is contained in:
parent
27313b68ef
commit
37a3de1e2e
@ -1,3 +1,5 @@
|
|||||||
_CLC_OVERLOAD _CLC_DEF __CLC_U_GENTYPE abs_diff(__CLC_GENTYPE x, __CLC_GENTYPE y) {
|
_CLC_OVERLOAD _CLC_DEF __CLC_U_GENTYPE abs_diff(__CLC_GENTYPE x, __CLC_GENTYPE y) {
|
||||||
return __builtin_astype((__CLC_GENTYPE)(x > y ? x-y : y-x), __CLC_U_GENTYPE);
|
__CLC_U_GENTYPE ux = __builtin_astype(x, __CLC_U_GENTYPE);
|
||||||
|
__CLC_U_GENTYPE uy = __builtin_astype(y, __CLC_U_GENTYPE);
|
||||||
|
return x > y ? ux - uy : uy - ux;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user