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
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
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
)
35 GET_FLOAT_WORD (hx
, x
, NO_COND
);
37 VECTOR_IF (FLT_UWORD_IS_ZERO (hx
), cond
)
38 VECTOR_RETURN (VECTOR_INIT (-__INT_MAX__
), cond
); // FP_ILOGB0
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));
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
);
51 VECTOR_RETURN ((hx
>> 23) - 127, NO_COND
);
56 DEF_VARIANTS (ilogbf
, si
, sf
)