Example #1
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 #2
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 #3
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 #4
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());
/* { 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 } */