[libclc] [libclc] Reduce bithacking for INF/NAN values (PR #129738)

Matt Arsenault via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 5 04:41:03 PST 2025


================
@@ -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;
----------------
arsenm wrote:

aux and auy can be rewritten to float typed fabs(x),y. ux and uy are then applying a umax, which can be replaced by fmax. The fmax result then has the implied infiniteness, and you can check if that is infinity down here.

The bithacking below that is frexp, and the scaling applied to fx and fy can be done with ldexp from the integer exponent obtained from the frexp 

https://github.com/llvm/llvm-project/pull/129738


More information about the cfe-commits mailing list