Beispiel #1
0
int
fn1 (void)
{
  if (__builtin_constant_p ()) /* { dg-error "7:not enough" } */
    return 0;
  if (__builtin_constant_p (1, 2)) /* { dg-error "7:too many" } */
    return 1;
  if (__builtin_isfinite ()) /* { dg-error "7:not enough" } */
    return 3;
  if (__builtin_isfinite (1, 2)) /* { dg-error "7:too many" } */
    return 4;
  if (__builtin_isless (0)) /* { dg-error "7:not enough" } */
    return 5;
  if (__builtin_isless (1, 2, 3)) /* { dg-error "7:too many" } */
    return 6;
  if (__builtin_fpclassify (1, 2, 3, 4, 5)) /* { dg-error "7:not enough" } */
    return 7;
  if (__builtin_fpclassify (1, 2, 3, 4, 5, r, 6)) /* { dg-error "7:too many" } */
    return 8;
  if (__builtin_assume_aligned (p)) /* { dg-error "7:too few" } */
    return 9;
  if (__builtin_assume_aligned (p, r, p, p)) /* { dg-error "7:too many" } */
    return 10;
  if (__builtin_add_overflow ()) /* { dg-error "7:not enough" } */
    return 11;
  if (__builtin_add_overflow (1, 2, 3, &r)) /* { dg-error "7:too many" } */
    return 12;
  return -1;
}
Beispiel #2
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;
}
Beispiel #3
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" } */
}
Beispiel #4
0
// CHECK: define void @test_float_builtins
void test_float_builtins(float F, double D, long double LD) {
  volatile int res;
  res = __builtin_isinf(F);
  // CHECK:  call float @fabsf(float
  // CHECK:  fcmp oeq float {{.*}}, 0x7FF0000000000000

  res = __builtin_isinf(D);
  // CHECK:  call double @fabs(double
  // CHECK:  fcmp oeq double {{.*}}, 0x7FF0000000000000
  
  res = __builtin_isinf(LD);
  // CHECK:  call x86_fp80 @fabsl(x86_fp80
  // CHECK:  fcmp oeq x86_fp80 {{.*}}, 0xK7FFF8000000000000000
  
  res = __builtin_isfinite(F);
  // CHECK: fcmp oeq float 
  // CHECK: call float @fabsf
  // CHECK: fcmp une float {{.*}}, 0x7FF0000000000000
  // CHECK: and i1 

  res = __builtin_isnormal(F);
  // CHECK: fcmp oeq float
  // CHECK: call float @fabsf
  // CHECK: fcmp ult float {{.*}}, 0x7FF0000000000000
  // CHECK: fcmp uge float {{.*}}, 0x3810000000000000
  // CHECK: and i1
  // CHECK: and i1
}
Beispiel #5
0
// CHECK-LABEL: define void @test_float_builtins
void test_float_builtins(float F, double D, long double LD) {
  volatile int res;
  res = __builtin_isinf(F);
  // CHECK:  call float @llvm.fabs.f32(float
  // CHECK:  fcmp oeq float {{.*}}, 0x7FF0000000000000

  res = __builtin_isinf(D);
  // CHECK:  call double @llvm.fabs.f64(double
  // CHECK:  fcmp oeq double {{.*}}, 0x7FF0000000000000

  res = __builtin_isinf(LD);
  // CHECK:  call x86_fp80 @llvm.fabs.f80(x86_fp80
  // CHECK:  fcmp oeq x86_fp80 {{.*}}, 0xK7FFF8000000000000000

  res = __builtin_isinf_sign(F);
  // CHECK:  %[[ABS:.*]] = call float @llvm.fabs.f32(float %[[ARG:.*]])
  // CHECK:  %[[ISINF:.*]] = fcmp oeq float %[[ABS]], 0x7FF0000000000000
  // CHECK:  %[[BITCAST:.*]] = bitcast float %[[ARG]] to i32
  // CHECK:  %[[ISNEG:.*]] = icmp slt i32 %[[BITCAST]], 0
  // CHECK:  %[[SIGN:.*]] = select i1 %[[ISNEG]], i32 -1, i32 1
  // CHECK:  select i1 %[[ISINF]], i32 %[[SIGN]], i32 0

  res = __builtin_isinf_sign(D);
  // CHECK:  %[[ABS:.*]] = call double @llvm.fabs.f64(double %[[ARG:.*]])
  // CHECK:  %[[ISINF:.*]] = fcmp oeq double %[[ABS]], 0x7FF0000000000000
  // CHECK:  %[[BITCAST:.*]] = bitcast double %[[ARG]] to i64
  // CHECK:  %[[ISNEG:.*]] = icmp slt i64 %[[BITCAST]], 0
  // CHECK:  %[[SIGN:.*]] = select i1 %[[ISNEG]], i32 -1, i32 1
  // CHECK:  select i1 %[[ISINF]], i32 %[[SIGN]], i32 0

  res = __builtin_isinf_sign(LD);
  // CHECK:  %[[ABS:.*]] = call x86_fp80 @llvm.fabs.f80(x86_fp80 %[[ARG:.*]])
  // CHECK:  %[[ISINF:.*]] = fcmp oeq x86_fp80 %[[ABS]], 0xK7FFF8000000000000000
  // CHECK:  %[[BITCAST:.*]] = bitcast x86_fp80 %[[ARG]] to i80
  // CHECK:  %[[ISNEG:.*]] = icmp slt i80 %[[BITCAST]], 0
  // CHECK:  %[[SIGN:.*]] = select i1 %[[ISNEG]], i32 -1, i32 1
  // CHECK:  select i1 %[[ISINF]], i32 %[[SIGN]], i32 0

  res = __builtin_isfinite(F);
  // CHECK: call float @llvm.fabs.f32(float
  // CHECK: fcmp one float {{.*}}, 0x7FF0000000000000

  res = finite(D);
  // CHECK: call double @llvm.fabs.f64(double
  // CHECK: fcmp one double {{.*}}, 0x7FF0000000000000

  res = __builtin_isnormal(F);
  // CHECK: fcmp oeq float
  // CHECK: call float @llvm.fabs.f32(float
  // CHECK: fcmp ult float {{.*}}, 0x7FF0000000000000
  // CHECK: fcmp uge float {{.*}}, 0x3810000000000000
  // CHECK: and i1
  // CHECK: and i1
}
Beispiel #6
0
int main() {
  volatile float a = __builtin_nanf("");
  if (__builtin_isfinite(a)) {
    return 1;
  }
  volatile float b = __builtin_inff();
  if (__builtin_isfinite(b)) {
    return 1;
  }
  volatile double c = __builtin_nan("");
  if (__builtin_isfinite(c)) {
    return 1;
  }
  volatile double d = __builtin_inf();
  if (__builtin_isfinite(d)) {
    return 1;
  }
#ifdef __clang__ // TODO: dragonegg uses native calls which do not work with X86_FP80
  volatile long double e = __builtin_nanl("");
  if (__builtin_isfinite(e)) {
    return 1;
  }
  volatile long double f = __builtin_infl();
  if (__builtin_isfinite(f)) {
    return 1;
  }
#endif
  volatile float g = 0;
  if (!__builtin_isfinite(g)) {
    return 1;
  }
  volatile double h = 0;
  if (!__builtin_isfinite(h)) {
    return 1;
  }
#ifdef __clang__ // TODO: dragonegg uses native calls which do not work with X86_FP80
  volatile long double i = 0;
  if (!__builtin_isfinite(i)) {
    return 1;
  }
#endif
  return 0;
}
Beispiel #7
0
int
finitel (long double x)
{
#ifdef _LDBL_EQ_DBL
  return finite (x);
#else
  /* Let the compiler do this for us.
     Note - we do not know how many bits there are in a long double.
     Some architectures for example have an 80-bit long double whereas
     others use 128-bits.  We use macros and comiler builtin functions
     to avoid specific knowledge of the long double format.  */
  return __builtin_isfinite (x);
#endif
}
Beispiel #8
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;
}
Beispiel #9
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;
}
Beispiel #10
0
char isinf_sign_neg_inf[__builtin_isinf_sign(-__builtin_inf()) == -1 ? 1 : -1];

char isinf_inf_pos[__builtin_isinf(__builtin_inf()) ? 1 : -1];
char isinf_pos    [!__builtin_isinf(1.0) ? 1 : -1];
char isinf_normf  [!__builtin_isinf(1e-37f) ? 1 : -1];
char isinf_denormf[!__builtin_isinf(1e-38f) ? 1 : -1];
char isinf_norm   [!__builtin_isinf(1e-307) ? 1 : -1];
char isinf_denorm [!__builtin_isinf(1e-308) ? 1 : -1];
char isinf_zero   [!__builtin_isinf(0.0) ? 1 : -1];
char isinf_negzero[!__builtin_isinf(-0.0) ? 1 : -1];
char isinf_neg    [!__builtin_isinf(-1.0) ? 1 : -1];
char isinf_inf_neg[__builtin_isinf(-__builtin_inf()) ? 1 : -1];
char isinf_nan    [!__builtin_isinf(__builtin_nan("")) ? 1 : -1];
char isinf_snan   [!__builtin_isinf(__builtin_nans("")) ? 1 : -1];

char isfinite_inf_pos[!__builtin_isfinite(__builtin_inf()) ? 1 : -1];
char isfinite_pos    [__builtin_isfinite(1.0) ? 1 : -1];
char isfinite_normf  [__builtin_isfinite(1e-37f) ? 1 : -1];
char isfinite_denormf[__builtin_isfinite(1e-38f) ? 1 : -1];
char isfinite_norm   [__builtin_isfinite(1e-307) ? 1 : -1];
char isfinite_denorm [__builtin_isfinite(1e-308) ? 1 : -1];
char isfinite_zero   [__builtin_isfinite(0.0) ? 1 : -1];
char isfinite_negzero[__builtin_isfinite(-0.0) ? 1 : -1];
char isfinite_neg    [__builtin_isfinite(-1.0) ? 1 : -1];
char isfinite_inf_neg[!__builtin_isfinite(-__builtin_inf()) ? 1 : -1];
char isfinite_nan    [!__builtin_isfinite(__builtin_nan("")) ? 1 : -1];
char isfinite_snan   [!__builtin_isfinite(__builtin_nans("")) ? 1 : -1];

char isnan_inf_pos[!__builtin_isnan(__builtin_inf()) ? 1 : -1];
char isnan_pos    [!__builtin_isnan(1.0) ? 1 : -1];
char isnan_normf  [!__builtin_isnan(1e-37f) ? 1 : -1];
Beispiel #11
0
			inline SPROUT_CONSTEXPR bool
			builtin_isfinite(FloatType x) {
				return __builtin_isfinite(x);
			}