Exemple #1
0
int
main (void)
{
  float32_t v1 = 3.14159265359;
  float32_t v2 = 1.383894;
  float32_t v3 = -2.71828;
  float32_t v4 = -3.4891931;

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

  return 0;
}
Exemple #2
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

}
Exemple #3
0
int
main (void)
{
  float32_t v1 = 3.14159265359;
  float32_t v2 = 1.383894;
  float32_t v3 = -2.71828;
  float32_t v4 = -3.4891931;

  float32_t v1_1[] = {v1, v2};
  float32_t v1_2[] = {v3, v4};
  float32_t e1_1[] = {v1 * v3, v2 * v3};
  float32_t e1_2[] = {v1 * v4, v2 * v4};
  test_case (v1_1, v1_2, e1_1, e1_2);

  float32_t v2_1[] = {0, -0.0};
  float32_t v2_2[] = {__builtin_huge_valf (), -__builtin_huge_valf ()};
  float32_t e2_1[] = {2.0, -2.0};
  float32_t e2_2[] = {-2.0, 2.0};
  test_case (v2_1, v2_2, e2_1, e2_2);

  return 0;
}
Exemple #4
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
}
Exemple #5
0
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;
}
Exemple #6
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();


Exemple #8
0
    float32_t actual_lane3[2];						\
    vst1_f32 (actual_lane3, actual_lane3_v);				\
    if (actual_lane3[0] != expected_lane3[0]				\
	|| actual_lane3[1] != expected_lane3[1])			\
      abort ();								\
									\
  }									\

float32_t v1 = 3.14159265359;
float32_t v2 = 1.383894;
float32_t v3 = -2.71828;
float32_t v4 = -3.4891931;

float32_t v5 = 0.0;
float32_t v6 = -0.0;
float32_t v7 = __builtin_huge_valf ();
float32_t v8 = -__builtin_huge_valf ();

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

SETUP_VEC (PASS_ARRAY (v5, v6), PASS_ARRAY (v5, v6, v7, v8),
	   PASS_ARRAY (0.0, -0.0), PASS_ARRAY (-0.0, 0.0),
	   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 } */