Example #1
0
int
main (void)
{
  float64_t v1 = 3.14159265359;
  float64_t v2 = -2.71828;

  float64_t v1_1[] = {v1};
  float64_t v1_2[] = {v2};
  float64_t e1[] = {v1 * v2};
  test_case (v1_1, v1_2, e1);

  float64_t v2_1[] = {0};
  float64_t v2_2[] = {__builtin_huge_val ()};
  float64_t e2[] = {2.0};
  test_case (v2_1, v2_2, e2);

  float64_t v3_1[] = {0};
  float64_t v3_2[] = {-__builtin_huge_val ()};
  float64_t e3[] = {-2.0};
  test_case (v3_1, v3_2, e3);

  float64_t v4_1[] = {-0.0};
  float64_t v4_2[] = {__builtin_huge_val ()};
  float64_t e4[] = {-2.0};
  test_case (v4_1, v4_2, e4);

  float64_t v5_1[] = {-0.0};
  float64_t v5_2[] = {-__builtin_huge_val ()};
  float64_t e5[] = {2.0};
  test_case (v5_1, v5_2, e5);

  return 0;
}
Example #2
0
int
main (void)
{
  float64_t v1 = 3.14159265359;
  float64_t v2 = 1.383894;

  /* Constant * constant, shouldn't generete fmulx or fmul, only fmov.  */
  SETUP_TEST_CASE_SCALAR (1, vmulxd_f64, float64_t, v1, v2, v1 * v2);
  SETUP_TEST_CASE_SCALAR (2, vmulxd_f64, float64_t, 0.0,
			  __builtin_huge_val (), 2.0);
  SETUP_TEST_CASE_SCALAR (3, vmulxd_f64, float64_t, 0.0,
			  -__builtin_huge_val (), -2.0);
  SETUP_TEST_CASE_SCALAR (4, vmulxd_f64, float64_t, -0.0,
			  __builtin_huge_val (), -2.0);
  SETUP_TEST_CASE_SCALAR (5, vmulxd_f64, float64_t, -0.0,
			  -__builtin_huge_val (), 2.0);
  /* Constant +/- 0 or +/- inf * non-constant should generate fmulx.  */
  SETUP_TEST_CASE_SCALAR (6, vmulxd_f64, float64_t, foo64 (),
			  -__builtin_huge_val (), -__builtin_huge_val ());
  SETUP_TEST_CASE_SCALAR (7, vmulxd_f64, float64_t, foo64 (),
			  __builtin_huge_val (), __builtin_huge_val ());
  SETUP_TEST_CASE_SCALAR (8, vmulxd_f64, float64_t, foo64 (),
			  0, 0);
  SETUP_TEST_CASE_SCALAR (9, vmulxd_f64, float64_t, foo64 (),
			  -0.0, -0.0);
  /* Constant non +/- 0 or non +/- inf * non-constant should generate fmul.  */
  SETUP_TEST_CASE_SCALAR (10, vmulxd_f64, float64_t, foo64 (),
			  v1, v1);

  return 0;
}
Example #3
0
// CHECK-LABEL: define void @bar(
void bar() {
  float f;
  double d;
  long double ld;

  // LLVM's hex representation of float constants is really unfortunate;
  // basically it does a float-to-double "conversion" and then prints the
  // hex form of that.  That gives us weird artifacts like exponents
  // that aren't numerically similar to the original exponent and
  // significand bit-patterns that are offset by three bits (because
  // the exponent was expanded from 8 bits to 11).
  //
  // 0xAE98 == 1010111010011000
  // 0x15D3 == 1010111010011

  f = __builtin_huge_valf();     // CHECK: float    0x7FF0000000000000
  d = __builtin_huge_val();      // CHECK: double   0x7FF0000000000000
  ld = __builtin_huge_vall();    // CHECK: x86_fp80 0xK7FFF8000000000000000
  f = __builtin_nanf("");        // CHECK: float    0x7FF8000000000000
  d = __builtin_nan("");         // CHECK: double   0x7FF8000000000000
  ld = __builtin_nanl("");       // CHECK: x86_fp80 0xK7FFFC000000000000000
  f = __builtin_nanf("0xAE98");  // CHECK: float    0x7FF815D300000000
  d = __builtin_nan("0xAE98");   // CHECK: double   0x7FF800000000AE98
  ld = __builtin_nanl("0xAE98"); // CHECK: x86_fp80 0xK7FFFC00000000000AE98
  f = __builtin_nansf("");       // CHECK: float    0x7FF4000000000000
  d = __builtin_nans("");        // CHECK: double   0x7FF4000000000000
  ld = __builtin_nansl("");      // CHECK: x86_fp80 0xK7FFFA000000000000000
  f = __builtin_nansf("0xAE98"); // CHECK: float    0x7FF015D300000000
  d = __builtin_nans("0xAE98");  // CHECK: double   0x7FF000000000AE98
  ld = __builtin_nansl("0xAE98");// CHECK: x86_fp80 0xK7FFF800000000000AE98

}
Example #4
0
int
main (void)
{
  int i;
  float64_t v1 = 3.14159265359;
  float64_t v2 = 1.383894;
  float64_t v3 = -2.71828;
  float64_t v4 = -3.4891931;

  test_case (v1, v2, v1 * v2);
  test_case (0.0, __builtin_huge_val (), 2.0);
  test_case (0.0, -__builtin_huge_val (), -2.0);
  test_case (-0.0, __builtin_huge_val (), -2.0);
  test_case (-0.0, -__builtin_huge_val (), 2.0);

  return 0;
}
Example #5
0
int jsonp_strtod(strbuffer_t *strbuffer, double *out)
{
    double value;
    char *end;

#if JSON_HAVE_LOCALECONV
    to_locale(strbuffer);
#endif

    errno = 0;
    value = strtod(strbuffer->value, &end);
    assert(end == strbuffer->value + strbuffer->length);

    if((value == __builtin_huge_val() || value == -__builtin_huge_val()) && errno == ERANGE) {
        /* Overflow */
        return -1;
    }

    *out = value;
    return 0;
}
Example #6
0
int
main ()
{
#ifdef __GLIBC__
  if (HUGE_VAL != __builtin_huge_val ())
    link_failure ();
#ifdef HUGE_VALF
  if (HUGE_VALF != __builtin_huge_valf ())
    link_failure ();
#endif
#ifdef HUGE_VALL
  if (HUGE_VALL != __builtin_huge_vall ())
    link_failure ();
#endif
#endif
}
Example #7
0
File: inf-1.c Project: 0day-ci/gcc
int main()
{
#ifndef __SPU__
  /* The SPU single-precision floating point format does not support Inf.  */
  float fi = __builtin_inff();
#endif
  double di = __builtin_inf();
  long double li = __builtin_infl();

  float fh = __builtin_huge_valf();
  double dh = __builtin_huge_val();
  long double lh = __builtin_huge_vall();

#ifndef __SPU__
  if (fi + fi != fi)
    abort ();
#endif
  if (di + di != di)
    abort ();
  if (li + li != li)
    abort ();

#ifndef __SPU__
  if (fi != fh)
    abort ();
#endif
  if (di != dh)
    abort ();
  if (li != lh)
    abort ();

#ifndef __SPU__
  if (fi <= 0)
    abort ();
#endif
  if (di <= 0)
    abort ();
  if (li <= 0)
    abort ();

  return 0;
}
Example #8
0
int main(void) {
	printf("%f\n", __builtin_huge_val());
	return 0;
}
Example #9
0
// RUN: %clang_cc1 -fsyntax-only -verify %s

// Math stuff

double       g0  = __builtin_huge_val();
float        g1  = __builtin_huge_valf();
long double  g2  = __builtin_huge_vall();

double       g3  = __builtin_inf();
float        g4  = __builtin_inff();
long double  g5  = __builtin_infl();

double       g6  = __builtin_nan("");
float        g7  = __builtin_nanf("");
long double  g8  = __builtin_nanl("");

// GCC constant folds these too (via native strtol):
//double       g6_1  = __builtin_nan("1");
//float        g7_1  = __builtin_nanf("1");
//long double  g8_1  = __builtin_nanl("1");

// APFloat doesn't have signalling NaN functions.
//double       g9  = __builtin_nans("");
//float        g10 = __builtin_nansf("");
//long double  g11 = __builtin_nansl("");

//int          g12 = __builtin_abs(-12);

double       g13 = __builtin_fabs(-12.);
double       g13_0 = __builtin_fabs(-0.);
double       g13_1 = __builtin_fabs(-__builtin_inf());
// RUN: %clang_cc1 -fsyntax-only %s -verify -pedantic

// Math stuff

float        g0 = __builtin_huge_val();
double       g1 = __builtin_huge_valf();
long double  g2 = __builtin_huge_vall();
float        g3 = __builtin_inf();
double       g4 = __builtin_inff();
long double  g5 = __builtin_infl();

// GCC misc stuff

extern int f();

int h0 = __builtin_types_compatible_p(int,float);
//int h1 = __builtin_choose_expr(1, 10, f());
//int h2 = __builtin_expect(0, 0);
int h3 = __builtin_bswap16(0x1234) == 0x3412 ? 1 : f();
int h4 = __builtin_bswap32(0x1234) == 0x34120000 ? 1 : f();
int h5 = __builtin_bswap64(0x1234) == 0x3412000000000000 ? 1 : f();

short somefunc();

short t = __builtin_constant_p(5353) ? 42 : somefunc();


Example #11
0
    float64x2_t actual_lane1_v =					\
      test_vmulxq_laneq_f64_lane1 (vec1, vec2);				\
    float64_t actual_lane1[2];						\
    vst1q_f64 (actual_lane1, actual_lane1_v);				\
    for (i = 0; i < 2; ++i)						\
      if (actual_lane1[i] != expected_lane1[i])				\
	abort ();							\
									\
  }									\

float64_t v1 = 3.14159265359;
float64_t v2 = 1.383894;

float64_t v3 = 0.0;
float64_t v4 = -0.0;
float64_t v5 = __builtin_huge_val ();
float64_t v6 = -__builtin_huge_val ();

float64_t spec = __builtin_huge_val () * __builtin_huge_val ();

SETUP_VEC (PASS_ARRAY (v1, v2), PASS_ARRAY (v1, v2), PASS_ARRAY (v1*v1, v2*v1),
	   PASS_ARRAY (v1*v2, v2*v2), 1)

SETUP_VEC (PASS_ARRAY (v3, v4), PASS_ARRAY (v5, v6), PASS_ARRAY (2.0, -2.0),
	   PASS_ARRAY (-2.0, 2.0), 2)

int
main (void)
{
  set_and_test_case1 ();
  set_and_test_case2 ();
/* { dg-do compile } */

float fi = __builtin_inff();
double di = __builtin_inf();
long double li = __builtin_infl();

float fh = __builtin_huge_valf();
double dh = __builtin_huge_val();
long double lh = __builtin_huge_vall();

/* { dg-warning "does not support infinity" "INF unsupported" { target vax-*-* } 3 } */
/* { dg-warning "does not support infinity" "INF unsupported" { target vax-*-* } 4 } */
/* { dg-warning "does not support infinity" "INF unsupported" { target vax-*-* } 5 } */