void TestD(double X, double Y) {
  A = __builtin_isgreater(X, Y);
  B = __builtin_isgreaterequal(X, Y);
  C = __builtin_isless(X, Y);
  D = __builtin_islessequal(X, Y);
  E = __builtin_islessgreater(X, Y);
  F = __builtin_isunordered(X, Y);
  //G = __builtin_isordered(X, Y);    // Our current snapshot doesn't include this builtin.  FIXME
  H = __builtin_isunordered(X, Y);
}
void TestF(float X, float Y) {
  A = __builtin_isgreater(X, Y);
  B = __builtin_isgreaterequal(X, Y);
  C = __builtin_isless(X, Y);
  D = __builtin_islessequal(X, Y);
  E = __builtin_islessgreater(X, Y);
  F = __builtin_isunordered(X, Y);
  //G = __builtin_isordered(X, Y);    // Our current snapshot of GCC doesn't include this builtin
  H = __builtin_isunordered(X, Y);
}
Example #3
0
int main()
{
  if (__builtin_isunordered (f, f) != 0)
    link_error ();
  if (__builtin_isunordered (d, d) != 0)
    link_error ();
  if (__builtin_isunordered (ld, ld) != 0)
    link_error ();

  if (__builtin_isnan (f) != 0)
    link_error ();
  if (__builtin_isnan (d) != 0)
    link_error ();
  if (__builtin_isnan (ld) != 0)
    link_error ();
  if (__builtin_isnanf (f) != 0)
    link_error ();
  if (__builtin_isnanl (ld) != 0)
    link_error ();

  if (__builtin_finite (f) != 1)
    link_error ();
  if (__builtin_finite (d) != 1)
    link_error ();
  if (__builtin_finite (ld) != 1)
    link_error ();
  if (__builtin_finitef (f) != 1)
    link_error ();
  if (__builtin_finitel (ld) != 1)
    link_error ();

  if (__builtin_isinf (f) != 0)
    link_error ();
  if (__builtin_isinf (d) != 0)
    link_error ();
  if (__builtin_isinf (ld) != 0)
    link_error ();

  if (__builtin_isfinite (f) != 1)
    link_error ();
  if (__builtin_isfinite (d) != 1)
    link_error ();
  if (__builtin_isfinite (ld) != 1)
    link_error ();

  if (f != f)
    link_error ();
  if (d != d)
    link_error ();
  if (ld != ld)
    link_error ();
  return 0;
}
Example #4
0
void
fn0 (int n)
{
  p = __builtin_alloca_with_align (n, 6); /* { dg-error "39:must be a constant integer" } */

  r += __builtin_isfinite (0); /* { dg-error "28:non-floating-point argument in call" } */
  r += __builtin_isinf (0); /* { dg-error "25:non-floating-point argument in call" } */
  r += __builtin_isinf_sign (0); /* { dg-error "30:non-floating-point argument in call" } */
  r += __builtin_isnan (0); /* { dg-error "25:non-floating-point argument in call" } */
  r += __builtin_isnormal (0); /* { dg-error "28:non-floating-point argument in call" } */
  r += __builtin_signbit (0); /* { dg-error "27:non-floating-point argument in call" } */

  r += __builtin_isgreater (0, 0); /* { dg-error "8:non-floating-point arguments in call to function" } */
  r += __builtin_isgreaterequal (0, 0); /* { dg-error "8:non-floating-point arguments in call to function" } */
  r += __builtin_isless (0, 0); /* { dg-error "8:non-floating-point arguments in call to function" } */
  r += __builtin_islessequal (0, 0); /* { dg-error "8:non-floating-point arguments in call to function" } */
  r += __builtin_islessgreater (0, 0); /* { dg-error "8:non-floating-point arguments in call to function" } */
  r += __builtin_isunordered (0, 0); /* { dg-error "8:non-floating-point arguments in call to function" } */

  r += __builtin_fpclassify (1, 2, n, 4, 5, n); /* { dg-error "36:non-const integer argument 3 in call" } */
  r += __builtin_fpclassify (1, 2, 3, 4, 5, 6); /* { dg-error "45:non-floating-point argument in call" } */

  d = __builtin_assume_aligned (p, n, p); /* { dg-error "39:non-integer argument 3 in call" } */

  b = __builtin_add_overflow (n, *d, &r); /* { dg-error "34:argument 2 in call to function" } */
  b = __builtin_add_overflow (n, 5, d); /* { dg-error "37:argument 3 in call" } */
  b = __builtin_sub_overflow (n, *d, &r); /* { dg-error "34:argument 2 in call to function" } */
  b = __builtin_sub_overflow (n, 5, d); /* { dg-error "37:argument 3 in call" } */
  b = __builtin_mul_overflow (n, *d, &r); /* { dg-error "34:argument 2 in call to function" } */
  b = __builtin_mul_overflow (n, 5, d); /* { dg-error "37:argument 3 in call" } */
}
void TestD(double X, double Y) {
  A = __builtin_isgreater(X, Y);
  B = __builtin_isgreaterequal(X, Y);
  C = __builtin_isless(X, Y);
  D = __builtin_islessequal(X, Y);
  E = __builtin_islessgreater(X, Y);
  F = __builtin_isunordered(X, Y);
}
void TestF(float X, float Y) {
  A = __builtin_isgreater(X, Y);
  B = __builtin_isgreaterequal(X, Y);
  C = __builtin_isless(X, Y);
  D = __builtin_islessequal(X, Y);
  E = __builtin_islessgreater(X, Y);
  F = __builtin_isunordered(X, Y);
}
Example #7
0
void foo(float f)
{
  if (__builtin_isunordered (f, f) != 1)
    abort ();
  if (__builtin_isnan (f) != 1)
    abort ();
  if (__builtin_finite (f) != 0)
    abort ();
}
Example #8
0
int
main ()
{
  int i;
  asm volatile ("" : : : "memory");
  for (i = 0; i < 4; i++)
    e[i] = __builtin_isunordered (s1[i], s2[i]) && s1[i] != s2[i] ? -1 : 0;
  asm volatile ("" : : : "memory");
  return 0;
}
Example #9
0
int main()
{
  if (__builtin_isunordered (f, f) != 0)
    link_error ();
  if (__builtin_isnan (f) != 0)
    link_error ();
  if (__builtin_finite (f) != 1)
    link_error ();
  if (f != f)
    link_error ();
  return 0;
}
Example #10
0
int
main (void)
{
    int i;
    asm volatile ("" : : : "memory");
    for (i = 0; i < 4; i++)
        s3[0 * 4 + i] = __builtin_isgreater (s1[i], s2[i]) ? -1.0 : 0.0;
    for (i = 0; i < 4; i++)
        s3[1 * 4 + i] = (!__builtin_isgreater (s1[i], s2[i])) ? -1.0 : 0.0;
    for (i = 0; i < 4; i++)
        s3[2 * 4 + i] = __builtin_isgreaterequal (s1[i], s2[i]) ? -1.0 : 0.0;
    for (i = 0; i < 4; i++)
        s3[3 * 4 + i] = (!__builtin_isgreaterequal (s1[i], s2[i])) ? -1.0 : 0.0;
    for (i = 0; i < 4; i++)
        s3[4 * 4 + i] = __builtin_isless (s1[i], s2[i]) ? -1.0 : 0.0;
    for (i = 0; i < 4; i++)
        s3[5 * 4 + i] = (!__builtin_isless (s1[i], s2[i])) ? -1.0 : 0.0;
    for (i = 0; i < 4; i++)
        s3[6 * 4 + i] = __builtin_islessequal (s1[i], s2[i]) ? -1.0 : 0.0;
    for (i = 0; i < 4; i++)
        s3[7 * 4 + i] = (!__builtin_islessequal (s1[i], s2[i])) ? -1.0 : 0.0;
    for (i = 0; i < 4; i++)
        s3[8 * 4 + i] = __builtin_islessgreater (s1[i], s2[i]) ? -1.0 : 0.0;
    for (i = 0; i < 4; i++)
        s3[9 * 4 + i] = (!__builtin_islessgreater (s1[i], s2[i])) ? -1.0 : 0.0;
    for (i = 0; i < 4; i++)
        s3[10 * 4 + i] = __builtin_isunordered (s1[i], s2[i]) ? -1.0 : 0.0;
    for (i = 0; i < 4; i++)
        s3[11 * 4 + i] = (!__builtin_isunordered (s1[i], s2[i])) ? -1.0 : 0.0;
    for (i = 0; i < 4; i++)
        s3[12 * 4 + i] = s1[i] > s2[i] ? -1.0 : 0.0;
    for (i = 0; i < 4; i++)
        s3[13 * 4 + i] = s1[i] >= s2[i] ? -1.0 : 0.0;
    for (i = 0; i < 4; i++)
        s3[14 * 4 + i] = s1[i] < s2[i] ? -1.0 : 0.0;
    for (i = 0; i < 4; i++)
        s3[15 * 4 + i] = s1[i] <= s2[i] ? -1.0 : 0.0;
    asm volatile ("" : : : "memory");
    return 0;
}
Example #11
0
void
check (TYPE a,
       TYPE b,
       int eq,
       int ne,
       int lt,
       int le,
       int gt,
       int ge,
       int i_lt,
       int i_le,
       int i_gt,
       int i_ge,
       int i_lg,
       int i_un)
{
  if (eq != (a == b))
    abort ();

  if (ne != (a != b))
    abort ();

  if (lt != (a < b))
    abort ();

  if (le != (a <= b))
    abort ();

  if (gt != (a > b))
    abort ();

  if (ge != (a >= b))
    abort ();

  if (i_lt != __builtin_isless (a, b))
    abort ();

  if (i_le != __builtin_islessequal (a, b))
    abort ();

  if (i_gt != __builtin_isgreater (a, b))
    abort ();

  if (i_ge != __builtin_isgreaterequal (a, b))
    abort ();

  if (i_lg != __builtin_islessgreater (a, b))
    abort ();

  if (i_un != __builtin_isunordered (a, b))
    abort ();
}
Example #12
0
/*
 * Copyright (c) 2017, 2018, Oracle and/or its affiliates.
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification, are
 * permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this list of
 * conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
 * conditions and the following disclaimer in the documentation and/or other materials provided
 * with the distribution.
 *
 * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
 * endorse or promote products derived from this software without specific prior written
 * permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 */
int main() {
  volatile float pos1 = 1.;
  volatile float neg1 = -1.;
  volatile float posZero = 0.;
  volatile float negZero = -0.;
  volatile float nan = __builtin_nanf("");
  if (__builtin_isunordered(neg1, neg1) != 0) {
    return 1;
  }
  if (__builtin_isunordered(posZero, negZero) != 0) {
    return 1;
  }
  if (__builtin_isunordered(pos1, nan) == 0) {
    return 1;
  }
  if (__builtin_isunordered(nan, pos1) == 0) {
    return 1;
  }
  if (__builtin_isunordered(nan, nan) == 0) {
    return 1;
  }
  return 0;
}
Example #13
0
void
foo (void)
{
  int i;
  for (i = 0; i < 4; i++)
    s3[0 * 4 + i] = __builtin_isgreater (s1[i], s2[i]) ? -1.0 : 0.0;
  for (i = 0; i < 4; i++)
    s3[1 * 4 + i] = (!__builtin_isgreater (s1[i], s2[i])) ? -1.0 : 0.0;
  for (i = 0; i < 4; i++)
    s3[2 * 4 + i] = __builtin_isgreaterequal (s1[i], s2[i]) ? -1.0 : 0.0;
  for (i = 0; i < 4; i++)
    s3[3 * 4 + i] = (!__builtin_isgreaterequal (s1[i], s2[i])) ? -1.0 : 0.0;
  for (i = 0; i < 4; i++)
    s3[4 * 4 + i] = __builtin_isless (s1[i], s2[i]) ? -1.0 : 0.0;
  for (i = 0; i < 4; i++)
    s3[5 * 4 + i] = (!__builtin_isless (s1[i], s2[i])) ? -1.0 : 0.0;
  for (i = 0; i < 4; i++)
    s3[6 * 4 + i] = __builtin_islessequal (s1[i], s2[i]) ? -1.0 : 0.0;
  for (i = 0; i < 4; i++)
    s3[7 * 4 + i] = (!__builtin_islessequal (s1[i], s2[i])) ? -1.0 : 0.0;
  for (i = 0; i < 4; i++)
    s3[8 * 4 + i] = __builtin_islessgreater (s1[i], s2[i]) ? -1.0 : 0.0;
  for (i = 0; i < 4; i++)
    s3[9 * 4 + i] = (!__builtin_islessgreater (s1[i], s2[i])) ? -1.0 : 0.0;
  for (i = 0; i < 4; i++)
    s3[10 * 4 + i] = __builtin_isunordered (s1[i], s2[i]) ? -1.0 : 0.0;
  for (i = 0; i < 4; i++)
    s3[11 * 4 + i] = (!__builtin_isunordered (s1[i], s2[i])) ? -1.0 : 0.0;
  for (i = 0; i < 4; i++)
    s3[12 * 4 + i] = s1[i] > s2[i] ? -1.0 : 0.0;
  for (i = 0; i < 4; i++)
    s3[13 * 4 + i] = s1[i] <= s2[i] ? -1.0 : 0.0;
  for (i = 0; i < 4; i++)
    s3[14 * 4 + i] = s1[i] < s2[i] ? -1.0 : 0.0;
  for (i = 0; i < 4; i++)
    s3[15 * 4 + i] = s1[i] >= s2[i] ? -1.0 : 0.0;
}
Example #14
0
int test3(double x)
{
  if (x ==  1) return __builtin_fpclassify(1,2,3,4,5,x,x); /* { dg-error "too many arguments" } */
  if (x ==  2) return __builtin_isfinite(x, x); /* { dg-error "too many arguments" } */
  if (x ==  3) return __builtin_isinf_sign(x, x); /* { dg-error "too many arguments" } */
  if (x ==  4) return __builtin_isinf(x, x); /* { dg-error "too many arguments" } */
  if (x ==  5) return __builtin_isnan(x, x); /* { dg-error "too many arguments" } */
  if (x ==  6) return __builtin_isnormal(x, x); /* { dg-error "too many arguments" } */
  if (x ==  7) return __builtin_isgreater(x, x, x); /* { dg-error "too many arguments" } */
  if (x ==  8) return __builtin_isgreaterequal(x, x, x); /* { dg-error "too many arguments" } */
  if (x ==  9) return __builtin_isless(x, x, x); /* { dg-error "too many arguments" } */
  if (x == 10) return __builtin_islessequal(x, x, x); /* { dg-error "too many arguments" } */
  if (x == 11) return __builtin_islessgreater(x, x, x); /* { dg-error "too many arguments" } */
  if (x == 12) return __builtin_isunordered(x, x, x); /* { dg-error "too many arguments" } */
  if (x == 13) return __builtin_signbit(x, x); /* { dg-error "too many arguments" } */
  return 0;
}
Example #15
0
int test1(struct X x)
{
  if (x.x ==  1) return __builtin_fpclassify(1,2,3,4,5,x); /* { dg-error "non-floating-point argument" } */
  if (x.x ==  2) return __builtin_isfinite(x); /* { dg-error "non-floating-point argument" } */
  if (x.x ==  3) return __builtin_isinf_sign(x); /* { dg-error "non-floating-point argument" } */
  if (x.x ==  4) return __builtin_isinf(x); /* { dg-error "non-floating-point argument" } */
  if (x.x ==  5) return __builtin_isnan(x); /* { dg-error "non-floating-point argument" } */
  if (x.x ==  6) return __builtin_isnormal(x); /* { dg-error "non-floating-point argument" } */
  if (x.x ==  7) return __builtin_isgreater(x, x); /* { dg-error "non-floating-point arguments" } */
  if (x.x ==  8) return __builtin_isgreaterequal(x, x); /* { dg-error "non-floating-point arguments" } */
  if (x.x ==  9) return __builtin_isless(x, x); /* { dg-error "non-floating-point arguments" } */
  if (x.x == 10) return __builtin_islessequal(x, x); /* { dg-error "non-floating-point arguments" } */
  if (x.x == 11) return __builtin_islessgreater(x, x); /* { dg-error "non-floating-point arguments" } */
  if (x.x == 12) return __builtin_isunordered(x, x); /* { dg-error "non-floating-point arguments" } */
  if (x.x == 13) return __builtin_signbit(x); /* { dg-error "non-floating-point argument" } */

  return 0;
}
Example #16
0
int
main (void)
{
  /* TYPE: float */

  f1 = -f2;
  f1 = f2 + f3;
  f1 = f2 - f3;
  f1 = f2 * f3;
  f1 = f2 / f3;
  f1 += f2;
  f1 -= f2;
  f1 *= f2;
  f1 /= f2;

  si = f1 == f2;
  si = f1 != f2;
  si = f1 > f2;
  si = f1 < f2;
  si = f1 >= f2;
  si = f1 <= f2;

  si = __builtin_isgreater (f1, f2);
  si = __builtin_isgreaterequal (f1, f2);
  si = __builtin_isless (f1, f2);
  si = __builtin_islessequal (f1, f2);
  si = __builtin_islessgreater (f1, f2);
  si = __builtin_isunordered (f1, f2);

  sc = f1;
  uc = f1;
  ss = f1;
  us = f1;
  si = f1;
  ui = f1;
  sl = f1;
  ul = f1;
  d1 = f1;
  D1 = f1;

  f1 = sc;
  f1 = uc;
  f1 = ss;
  f1 = us;
  f1 = si;
  f1 = ui;
  f1 = sl;
  f1 = ul;
  f1 = d1;
  f1 = D1;

  d1 = -d2;
  d1 = d2 + d3;
  d1 = d2 - d3;
  d1 = d2 * d3;
  d1 = d2 / d3;
  d1 += d2;
  d1 -= d2;
  d1 *= d2;
  d1 /= d2;

  si = d1 == d2;
  si = d1 != d2;
  si = d1 > d2;
  si = d1 < d2;
  si = d1 >= d2;
  si = d1 <= d2;

  si = __builtin_isgreater (d1, d2);
  si = __builtin_isgreaterequal (d1, d2);
  si = __builtin_isless (d1, d2);
  si = __builtin_islessequal (d1, d2);
  si = __builtin_islessgreater (d1, d2);
  si = __builtin_isunordered (d1, d2);

  sc = d1;
  uc = d1;
  ss = d1;
  us = d1;
  si = d1;
  ui = d1;
  sl = d1;
  ul = d1;
  f1 = d1;
  D1 = d1;

  d1 = sc;
  d1 = uc;
  d1 = ss;
  d1 = us;
  d1 = si;
  d1 = ui;
  d1 = sl;
  d1 = ul;
  d1 = f1;
  d1 = D1;

  D1 = -D2;
  D1 = D2 + D3;
  D1 = D2 - D3;
  D1 = D2 * D3;
  D1 = D2 / D3;
  D1 += D2;
  D1 -= D2;
  D1 *= D2;
  D1 /= D2;

  si = D1 == D2;
  si = D1 != D2;
  si = D1 > D2;
  si = D1 < D2;
  si = D1 >= D2;
  si = D1 <= D2;

  si = __builtin_isgreater (D1, D2);
  si = __builtin_isgreaterequal (D1, D2);
  si = __builtin_isless (D1, D2);
  si = __builtin_islessequal (D1, D2);
  si = __builtin_islessgreater (D1, D2);
  si = __builtin_isunordered (D1, D2);

  sc = D1;
  uc = D1;
  ss = D1;
  us = D1;
  si = D1;
  ui = D1;
  sl = D1;
  ul = D1;
  f1 = D1;
  d1 = D1;

  D1 = sc;
  D1 = uc;
  D1 = ss;
  D1 = us;
  D1 = si;
  D1 = ui;
  D1 = sl;
  D1 = ul;
  D1 = f1;
  D1 = d1;

  d1 = acos (d2);
  d1 = asin (d2);
  d1 = atan (d2);
  d1 = atan2 (d2, d3);
  d1 = cos (d2);
  d1 = sin (d2);
  d1 = tan (d2);
  d1 = cosh (d2);
  d1 = sinh (d2);
  d1 = tanh (d2);
  d1 = exp (d2);
  d1 = frexp (d2, &i1);
  d1 = ldexp (d2, i2);
  d1 = log (d2);
  d1 = log10 (d2);
  d1 = modf (d2, &d3);
  d1 = pow (d2, d3);
  d1 = sqrt (d2);
  d1 = ceil (d2);
  d1 = fabs (d2);
  d1 = floor (d2);
  d1 = fmod (d2, d3);

  return 0;
}
Example #17
0
float
foo (float x, float y)
{
  return __builtin_isunordered (x, y) ? x : y;
}
Example #18
0
			inline SPROUT_CONSTEXPR bool
			builtin_isunordered(FloatType x, FloatType y) {
				return __builtin_isunordered(x, y);
			}
Example #19
0
static FLOAT
test_isunordered(FLOAT x, FLOAT y, FLOAT a, FLOAT b)
{
  return __builtin_isunordered(x, y) ? a : b;
}
Example #20
0
int h(double ccc, float ddd){
  int xc = __builtin_isunordered(ccc, ccc);
  int xd = __builtin_isunordered(ddd, ddd);
  return xc | xd;
}
Example #21
0
int f(double aaa, double bbb){
  int xa = __builtin_isunordered(aaa, aaa);
  int xb = __builtin_isunordered(bbb, bbb);
  return xa | xb;
}
int test2(float X, float Y) {
    return !__builtin_isunordered(X, Y);
}
Example #23
0
int FUNC (TYPE x, TYPE y) { return __builtin_isunordered (x, y); }
inline bool isunordered(const Y& v1,const Y& v2)
{
    return __builtin_isunordered(v1,v2);
}