Welcome to mirror list, hosted at ThFree Co, Russian Federation.

v64df_ilogb.c « amdgcn « machine « libm « newlib - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ea51bf10523528233d3924689e5176eed7fe5b30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
 * ====================================================
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
 *
 * Developed at SunPro, a Sun Microsystems, Inc. business.
 * Permission to use, copy, modify, and distribute this
 * software is freely granted, provided that this notice 
 * is preserved.
 * ====================================================
 */

/* Based on newlib/libm/common/s_ilogb.c in Newlib.  */

#include "amdgcnmach.h"

DEF_VD_MATH_PRED (v64si, ilogb, v64df x)
{
  FUNCTION_INIT(v64si);
  v64si hx, lx, ix;
  EXTRACT_WORDS (hx, lx, x);
  hx &= 0x7fffffff;
  VECTOR_IF (hx < 0x00100000, cond)
    VECTOR_RETURN (VECTOR_INIT (-__INT_MAX__), cond & ((hx | lx) == 0));  // FP_ILOGB0
    VECTOR_IF2 (hx == 0, cond2, cond)
      ix = VECTOR_INIT (-1043);
      for (v64si i = lx;
            !ALL_ZEROES_P (cond2 & (i > 0));
            i <<= 1)
        VECTOR_COND_MOVE (ix, ix - 1, cond2 & (i > 0));
    VECTOR_ELSE2 (cond2, cond)
      ix = VECTOR_INIT (-1022);
      for (v64si i = (hx << 11);
            !ALL_ZEROES_P (cond2 & (i > 0));
            i <<= 1)
        VECTOR_COND_MOVE (ix, ix - 1, cond2 & (i > 0));
    VECTOR_ENDIF
    VECTOR_RETURN (ix, cond);
  VECTOR_ENDIF
  VECTOR_RETURN ((hx >> 20) - 1023, hx < 0x7ff00000);
  VECTOR_RETURN (VECTOR_INIT (__INT_MAX__), NO_COND);

  FUNCTION_RETURN;
}

DEF_VARIANTS (ilogb, si, df)