================ @@ -46,9 +46,7 @@ _CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_hypot(__CLC_GENTYPE x, __CLC_GENTYPE retval = __clc_sqrt(__clc_mad(fx, fx, fy * fy)) * fx_exp; retval = (ux > PINFBITPATT_SP32 || uy == 0) ? __CLC_AS_GENTYPE(ux) : retval; - retval = (ux == PINFBITPATT_SP32 || uy == PINFBITPATT_SP32) - ? __CLC_AS_GENTYPE((__CLC_UINTN)PINFBITPATT_SP32) - : retval; + retval = __clc_isinf(x) || __clc_isinf(y) ? __CLC_GENTYPE_INF : retval; ---------------- frasercrmck wrote:
I can't tell from the documentation: what do `frexp_exp` and `frexp_mant` do with subnormal numbers? For `exp`, `D0.i32 = exponent(S0.f32) - 127 + 1` implies it returns `-126`, which wouldn't be what `frexp` returns for the same input. So `frexp` relies on extra processing of `frexp_exp` and `frexp_mant`? We would want consistent results across all libclc targets for a hypothetical `__clc_frexp_exp` and `__clc_frexp_mant`. We'd need to define the various edge cases and subnormal handling. For targets without native support for either of these operations I worry that using these functions would be less optimal than doing bit manipulation/scaling/etc directly inline. Might we not just end up in a scenario where AMDGPU in fact wants a custom implementation of `__clc_hypot`, rather than a generic solution for all targets involving frexp/ldexp? https://github.com/llvm/llvm-project/pull/129738 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits