devctl.h: update for POSIX-1.2024
[newlib-cygwin.git] / newlib / libm / machine / amdgcn / v64sf_ilogb.c
blob2f2a7cac709fe349094b788ada6549460c0d44b8
1 /*
2 * Copyright 2023 Siemens
4 * The authors hereby grant permission to use, copy, modify, distribute,
5 * and license this software and its documentation for any purpose, provided
6 * that existing copyright notices are retained in all copies and that this
7 * notice is included verbatim in any distributions. No written agreement,
8 * license, or royalty fee is required for any of the authorized uses.
9 * Modifications to this software may be copyrighted by their authors
10 * and need not follow the licensing terms described here, provided that
11 * the new terms are clearly indicated on the first page of each file where
12 * they apply.
16 * ====================================================
17 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
19 * Developed at SunPro, a Sun Microsystems, Inc. business.
20 * Permission to use, copy, modify, and distribute this
21 * software is freely granted, provided that this notice
22 * is preserved.
23 * ====================================================
26 /* Based on newlib/libm/common/sf_ilogb.c in Newlib. */
28 #include "amdgcnmach.h"
30 DEF_VS_MATH_FUNC (v64si, ilogbf, v64sf x)
32 FUNCTION_INIT(v64si);
34 v64si hx, ix;
35 GET_FLOAT_WORD (hx, x, NO_COND);
36 hx &= 0x7fffffff;
37 VECTOR_IF (FLT_UWORD_IS_ZERO (hx), cond)
38 VECTOR_RETURN (VECTOR_INIT (-__INT_MAX__), cond); // FP_ILOGB0
39 VECTOR_ENDIF
40 VECTOR_IF (FLT_UWORD_IS_SUBNORMAL (hx), cond)
41 ix = VECTOR_INIT (-126);
42 for (v64si i = (hx << 8);
43 !ALL_ZEROES_P (cond & (i > 0));
44 i <<= 1)
45 VECTOR_COND_MOVE (ix, ix - 1, cond & (i > 0));
46 VECTOR_RETURN (ix, cond);
47 VECTOR_ELSEIF (~FLT_UWORD_IS_FINITE (hx), cond)
48 VECTOR_RETURN (VECTOR_INIT (__INT_MAX__), cond);
49 VECTOR_ENDIF
51 VECTOR_RETURN ((hx >> 23) - 127, NO_COND);
53 FUNCTION_RETURN;
56 DEF_VARIANTS (ilogbf, si, sf)