diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/fixed-point')
16 files changed, 511 insertions, 85 deletions
diff --git a/gcc/testsuite/gcc.dg/fixed-point/composite-type.c b/gcc/testsuite/gcc.dg/fixed-point/composite-type.c index 5ae11981e2..026bdaf564 100644 --- a/gcc/testsuite/gcc.dg/fixed-point/composite-type.c +++ b/gcc/testsuite/gcc.dg/fixed-point/composite-type.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-std=gnu99 -O -Wall -Wno-unused" } */ +/* { dg-options "-std=gnu99 -O -Wall -Wno-unused -ftrack-macro-expansion=0" } */ /* C99 6.2.7: Compatible type and composite type. */ diff --git a/gcc/testsuite/gcc.dg/fixed-point/convert-1.c b/gcc/testsuite/gcc.dg/fixed-point/convert-1.c new file mode 100644 index 0000000000..04adea88bf --- /dev/null +++ b/gcc/testsuite/gcc.dg/fixed-point/convert-1.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -O0" } */ + +/* C99 6.3 Conversions. + + Check conversions involving fixed-point. */ + +extern void abort (void); + +#include "convert.h" + +int main () +{ + ALL_CONV (short _Fract, hr); + ALL_CONV (_Fract, r); + ALL_CONV (long _Fract, lr); + ALL_CONV (long long _Fract, llr); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/fixed-point/convert-2.c b/gcc/testsuite/gcc.dg/fixed-point/convert-2.c new file mode 100644 index 0000000000..fc5bc1fcbb --- /dev/null +++ b/gcc/testsuite/gcc.dg/fixed-point/convert-2.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -O0" } */ + +/* C99 6.3 Conversions. + + Check conversions involving fixed-point. */ + +extern void abort (void); + +#include "convert.h" + +int main () +{ + ALL_CONV (unsigned short _Fract, uhr); + ALL_CONV (unsigned _Fract, ur); + ALL_CONV (unsigned long _Fract, ulr); + ALL_CONV (unsigned long long _Fract, ullr); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/fixed-point/convert-3.c b/gcc/testsuite/gcc.dg/fixed-point/convert-3.c new file mode 100644 index 0000000000..753c472a84 --- /dev/null +++ b/gcc/testsuite/gcc.dg/fixed-point/convert-3.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -O0" } */ + +/* C99 6.3 Conversions. + + Check conversions involving fixed-point. */ + +extern void abort (void); + +#include "convert.h" + +int main () +{ + ALL_CONV (short _Accum, hk); + ALL_CONV (_Accum, k); + ALL_CONV (long _Accum, lk); + ALL_CONV (long long _Accum, llk); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/fixed-point/convert-4.c b/gcc/testsuite/gcc.dg/fixed-point/convert-4.c new file mode 100644 index 0000000000..17c4e66ebb --- /dev/null +++ b/gcc/testsuite/gcc.dg/fixed-point/convert-4.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -O0" } */ + +/* C99 6.3 Conversions. + + Check conversions involving fixed-point. */ + +extern void abort (void); + +#include "convert.h" + +int main () +{ + ALL_CONV (unsigned short _Accum, uhk); + ALL_CONV (unsigned _Accum, uk); + ALL_CONV (unsigned long _Accum, ulk); + ALL_CONV (unsigned long long _Accum, ullk); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/fixed-point/convert-accum-neg.c b/gcc/testsuite/gcc.dg/fixed-point/convert-accum-neg.c new file mode 100644 index 0000000000..af95610429 --- /dev/null +++ b/gcc/testsuite/gcc.dg/fixed-point/convert-accum-neg.c @@ -0,0 +1,33 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -O0" } */ + +/* C99 6.3 Conversions. + + Check conversions involving fixed-point. */ + +extern void abort (void); + +#include "convert.h" + +int main () +{ + ALL_ACCUM_CONV (short _Accum, hk); + ALL_ACCUM_CONV (_Accum, k); + ALL_ACCUM_CONV (long _Accum, lk); + ALL_ACCUM_CONV (long long _Accum, llk); + ALL_ACCUM_CONV (unsigned short _Accum, uhk); + ALL_ACCUM_CONV (unsigned _Accum, uk); + ALL_ACCUM_CONV (unsigned long _Accum, ulk); + ALL_ACCUM_CONV (unsigned long long _Accum, ullk); + + NEG_CONV (short _Fract, hr); + NEG_CONV (_Fract, r); + NEG_CONV (long _Fract, lr); + NEG_CONV (long long _Fract, llr); + NEG_CONV (short _Accum, hk); + NEG_CONV (_Accum, k); + NEG_CONV (long _Accum, lk); + NEG_CONV (long long _Accum, llk); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/fixed-point/convert-float-1.c b/gcc/testsuite/gcc.dg/fixed-point/convert-float-1.c new file mode 100644 index 0000000000..b36adab570 --- /dev/null +++ b/gcc/testsuite/gcc.dg/fixed-point/convert-float-1.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -O0" } */ + +/* C99 6.3 Conversions. + + Check conversions involving fixed-point. */ + +extern void abort (void); + +#include "convert.h" + +int main () +{ + ALL_CONV_FLOAT (short _Fract, hr); + ALL_CONV_FLOAT (_Fract, r); + ALL_CONV_FLOAT (long _Fract, lr); + ALL_CONV_FLOAT (long long _Fract, llr); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/fixed-point/convert-float-2.c b/gcc/testsuite/gcc.dg/fixed-point/convert-float-2.c new file mode 100644 index 0000000000..2a3f3e95a1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/fixed-point/convert-float-2.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -O0" } */ + +/* C99 6.3 Conversions. + + Check conversions involving fixed-point. */ + +extern void abort (void); + +#include "convert.h" + +int main () +{ + ALL_CONV_FLOAT (unsigned short _Fract, uhr); + ALL_CONV_FLOAT (unsigned _Fract, ur); + ALL_CONV_FLOAT (unsigned long _Fract, ulr); + ALL_CONV_FLOAT (unsigned long long _Fract, ullr); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/fixed-point/convert-float-3.c b/gcc/testsuite/gcc.dg/fixed-point/convert-float-3.c new file mode 100644 index 0000000000..9cad010912 --- /dev/null +++ b/gcc/testsuite/gcc.dg/fixed-point/convert-float-3.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -O0" } */ + +/* C99 6.3 Conversions. + + Check conversions involving fixed-point. */ + +extern void abort (void); + +#include "convert.h" + +int main () +{ + ALL_CONV_FLOAT (short _Accum, hk); + ALL_CONV_FLOAT (_Accum, k); + ALL_CONV_FLOAT (long _Accum, lk); + ALL_CONV_FLOAT (long long _Accum, llk); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/fixed-point/convert-float-4.c b/gcc/testsuite/gcc.dg/fixed-point/convert-float-4.c new file mode 100644 index 0000000000..c25a55c071 --- /dev/null +++ b/gcc/testsuite/gcc.dg/fixed-point/convert-float-4.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -O0" } */ + +/* C99 6.3 Conversions. + + Check conversions involving fixed-point. */ + +extern void abort (void); + +#include "convert.h" + +int main () +{ + ALL_CONV_FLOAT (unsigned short _Accum, uhk); + ALL_CONV_FLOAT (unsigned _Accum, uk); + ALL_CONV_FLOAT (unsigned long _Accum, ulk); + ALL_CONV_FLOAT (unsigned long long _Accum, ullk); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/fixed-point/convert-sat.c b/gcc/testsuite/gcc.dg/fixed-point/convert-sat.c new file mode 100644 index 0000000000..278aa173b6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/fixed-point/convert-sat.c @@ -0,0 +1,45 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -O0" } */ + +/* C99 6.3 Conversions. + + Check conversions involving fixed-point. */ + +extern void abort (void); + +#include "convert.h" + +int main () +{ + SAT_CONV1 (short _Accum, hk); + SAT_CONV1 (_Accum, k); + SAT_CONV1 (long _Accum, lk); + SAT_CONV1 (long long _Accum, llk); + + SAT_CONV2 (unsigned short _Accum, uhk); + SAT_CONV2 (unsigned _Accum, uk); + SAT_CONV2 (unsigned long _Accum, ulk); + SAT_CONV2 (unsigned long long _Accum, ullk); + + SAT_CONV3 (short _Fract, hr); + SAT_CONV3 (_Fract, r); + SAT_CONV3 (long _Fract, lr); + SAT_CONV3 (long long _Fract, llr); + + SAT_CONV4 (signed char); + SAT_CONV4 (short); + SAT_CONV4 (int); + SAT_CONV4 (long); + SAT_CONV4 (long long); + + SAT_CONV5 (unsigned char); + SAT_CONV5 (unsigned short); + SAT_CONV5 (unsigned int); + SAT_CONV5 (unsigned long); + SAT_CONV5 (unsigned long long); + + SAT_CONV6 (float); + SAT_CONV6 (double); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/fixed-point/convert.c b/gcc/testsuite/gcc.dg/fixed-point/convert.h index f4e373f2d6..e4e68157a7 100644 --- a/gcc/testsuite/gcc.dg/fixed-point/convert.c +++ b/gcc/testsuite/gcc.dg/fixed-point/convert.h @@ -1,11 +1,6 @@ -/* { dg-do run } */ -/* { dg-options "-std=gnu99 -O0" } */ - -/* C99 6.3 Conversions. - - Check conversions involving fixed-point. */ - -extern void abort (void); +/* Check conversions involving fixed-point. + * Break up use-site into into manageable parts so that even embedded + * targets with restrictive resources can run them. */ /* Fixed-point to fixed-point. */ #define CONV(TYPE1,POSTFIX1,TYPE2,POSTFIX2) \ @@ -131,7 +126,7 @@ extern void abort (void); CONV(_Sat TYPE, POSTFIX, unsigned _Accum, uk) \ CONV(_Sat TYPE, POSTFIX, unsigned long _Accum, ulk) \ CONV(_Sat TYPE, POSTFIX, unsigned long long _Accum, ullk) \ - CONV(TYPE, POSTFIX, _Sat short _Fract, hr) \ + CONV(TYPE, POSTFIX, _Sat short _Fract, hr) \ CONV(TYPE, POSTFIX, _Sat _Fract, r) \ CONV(TYPE, POSTFIX, _Sat long _Fract, lr) \ CONV(TYPE, POSTFIX, _Sat long long _Fract, llr) \ @@ -147,7 +142,7 @@ extern void abort (void); CONV(TYPE, POSTFIX, _Sat unsigned _Accum, uk) \ CONV(TYPE, POSTFIX, _Sat unsigned long _Accum, ulk) \ CONV(TYPE, POSTFIX, _Sat unsigned long long _Accum, ullk) \ - CONV_INT(TYPE, POSTFIX, signed char) \ + CONV_INT(TYPE, POSTFIX, signed char) \ CONV_INT(TYPE, POSTFIX, short) \ CONV_INT(TYPE, POSTFIX, int) \ CONV_INT(TYPE, POSTFIX, long) \ @@ -166,8 +161,10 @@ extern void abort (void); CONV_INT(_Sat TYPE, POSTFIX, unsigned short) \ CONV_INT(_Sat TYPE, POSTFIX, unsigned int) \ CONV_INT(_Sat TYPE, POSTFIX, unsigned long) \ - CONV_INT(_Sat TYPE, POSTFIX, unsigned long long) \ - CONV_FLOAT(TYPE, POSTFIX, float) \ + CONV_INT(_Sat TYPE, POSTFIX, unsigned long long) + +#define ALL_CONV_FLOAT(TYPE,POSTFIX) \ + CONV_FLOAT(TYPE, POSTFIX, float) \ CONV_FLOAT(TYPE, POSTFIX, double) \ CONV_FLOAT(_Sat TYPE, POSTFIX, float) \ CONV_FLOAT(_Sat TYPE, POSTFIX, double) @@ -360,73 +357,3 @@ extern void abort (void); CONV2(TYPE, -1.0, _Sat unsigned long _Fract, 0.0ulr) \ CONV2(TYPE, 1.0, _Sat unsigned long long _Fract, 1.0ullr) \ CONV2(TYPE, -1.0, _Sat unsigned long long _Fract, 0.0ullr) - -int main () -{ - ALL_CONV (short _Fract, hr); - ALL_CONV (_Fract, r); - ALL_CONV (long _Fract, lr); - ALL_CONV (long long _Fract, llr); - ALL_CONV (unsigned short _Fract, uhr); - ALL_CONV (unsigned _Fract, ur); - ALL_CONV (unsigned long _Fract, ulr); - ALL_CONV (unsigned long long _Fract, ullr); - ALL_CONV (short _Accum, hk); - ALL_CONV (_Accum, k); - ALL_CONV (long _Accum, lk); - ALL_CONV (long long _Accum, llk); - ALL_CONV (unsigned short _Accum, uhk); - ALL_CONV (unsigned _Accum, uk); - ALL_CONV (unsigned long _Accum, ulk); - ALL_CONV (unsigned long long _Accum, ullk); - - ALL_ACCUM_CONV (short _Accum, hk); - ALL_ACCUM_CONV (_Accum, k); - ALL_ACCUM_CONV (long _Accum, lk); - ALL_ACCUM_CONV (long long _Accum, llk); - ALL_ACCUM_CONV (unsigned short _Accum, uhk); - ALL_ACCUM_CONV (unsigned _Accum, uk); - ALL_ACCUM_CONV (unsigned long _Accum, ulk); - ALL_ACCUM_CONV (unsigned long long _Accum, ullk); - - NEG_CONV (short _Fract, hr); - NEG_CONV (_Fract, r); - NEG_CONV (long _Fract, lr); - NEG_CONV (long long _Fract, llr); - NEG_CONV (short _Accum, hk); - NEG_CONV (_Accum, k); - NEG_CONV (long _Accum, lk); - NEG_CONV (long long _Accum, llk); - - SAT_CONV1 (short _Accum, hk); - SAT_CONV1 (_Accum, k); - SAT_CONV1 (long _Accum, lk); - SAT_CONV1 (long long _Accum, llk); - - SAT_CONV2 (unsigned short _Accum, uhk); - SAT_CONV2 (unsigned _Accum, uk); - SAT_CONV2 (unsigned long _Accum, ulk); - SAT_CONV2 (unsigned long long _Accum, ullk); - - SAT_CONV3 (short _Fract, hr); - SAT_CONV3 (_Fract, r); - SAT_CONV3 (long _Fract, lr); - SAT_CONV3 (long long _Fract, llr); - - SAT_CONV4 (signed char); - SAT_CONV4 (short); - SAT_CONV4 (int); - SAT_CONV4 (long); - SAT_CONV4 (long long); - - SAT_CONV5 (unsigned char); - SAT_CONV5 (unsigned short); - SAT_CONV5 (unsigned int); - SAT_CONV5 (unsigned long); - SAT_CONV5 (unsigned long long); - - SAT_CONV6 (float); - SAT_CONV6 (double); - - return 0; -} diff --git a/gcc/testsuite/gcc.dg/fixed-point/fixed-point.exp b/gcc/testsuite/gcc.dg/fixed-point/fixed-point.exp index bdb241f48a..77e7b7201d 100644 --- a/gcc/testsuite/gcc.dg/fixed-point/fixed-point.exp +++ b/gcc/testsuite/gcc.dg/fixed-point/fixed-point.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1997, 2004, 2009 Free Software Foundation, Inc. +# Copyright (C) 1997-2014 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gcc/testsuite/gcc.dg/fixed-point/operator-bitwise.c b/gcc/testsuite/gcc.dg/fixed-point/operator-bitwise.c index 31aecf5585..6ba817dca6 100644 --- a/gcc/testsuite/gcc.dg/fixed-point/operator-bitwise.c +++ b/gcc/testsuite/gcc.dg/fixed-point/operator-bitwise.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-std=gnu99" } */ +/* { dg-options "-std=gnu99 -ftrack-macro-expansion=0" } */ /* C99 6.5.10: Bitwise AND operator. C99 6.5.11: Bitwise exclusive OR operator. diff --git a/gcc/testsuite/gcc.dg/fixed-point/view-convert-2.c b/gcc/testsuite/gcc.dg/fixed-point/view-convert-2.c new file mode 100644 index 0000000000..fbce5185e1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/fixed-point/view-convert-2.c @@ -0,0 +1,139 @@ +/* PR tree-optimization/56064 */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -O2" } */ + +extern void abort (void); +extern void exit (int); + +void test_k (void) +{ + _Accum a; + __INT32_TYPE__ i = -__INT32_MAX__; + + if (sizeof (a) != sizeof (i)) + return; + + __builtin_memcpy (&a, &i, sizeof (a)); + + if (a >= 0k) + abort(); +} + +void test_0k (void) +{ + _Accum a; + __INT32_TYPE__ i = 0; + + if (sizeof (a) != sizeof (i)) + return; + + __builtin_memcpy (&a, &i, sizeof (a)); + + if (a != 0k) + abort(); +} + + +void test_hr (void) +{ + short _Fract a; + __INT8_TYPE__ i = -__INT8_MAX__; + + if (sizeof (a) != sizeof (i)) + return; + + __builtin_memcpy (&a, &i, sizeof (a)); + + if (a >= 0hr) + abort(); +} + +void test_0hr (void) +{ + short _Fract a; + __INT8_TYPE__ i = 0; + + if (sizeof (a) != sizeof (i)) + return; + + __builtin_memcpy (&a, &i, sizeof (a)); + + if (a != 0hr) + abort(); +} + + +void test_si (void) +{ + _Accum a = __ACCUM_MIN__; + __INT32_TYPE__ i; + + if (sizeof (a) != sizeof (i)) + return; + + __builtin_memcpy (&i, &a, sizeof (i)); + + if (i >= 0) + abort(); +} + +void test_0si (void) +{ + _Accum a = 0; + __INT32_TYPE__ i; + + if (sizeof (a) != sizeof (i)) + return; + + __builtin_memcpy (&i, &a, sizeof (i)); + + if (i != 0) + abort(); +} + + +void test_qi (void) +{ + short _Fract a = __SFRACT_MIN__; + __INT8_TYPE__ i; + + if (sizeof (a) != sizeof (i)) + return; + + __builtin_memcpy (&i, &a, sizeof (i)); + + if (i >= 0) + abort(); +} + +void test_0qi (void) +{ + short _Fract a = 0hr; + __INT8_TYPE__ i; + + if (sizeof (a) != sizeof (i)) + return; + + __builtin_memcpy (&i, &a, sizeof (i)); + + if (i != 0) + abort(); +} + + +int main (void) +{ + test_hr(); + test_k(); + test_qi(); + test_si(); + + test_0hr(); + test_0k(); + test_0qi(); + test_0si(); + + exit (0); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/fixed-point/view-convert.c b/gcc/testsuite/gcc.dg/fixed-point/view-convert.c new file mode 100644 index 0000000000..d5d27b35e1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/fixed-point/view-convert.c @@ -0,0 +1,122 @@ +/* PR tree-optimization/56064 */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -O2 -fno-builtin-memcpy" } */ + +extern void abort (void); +extern void *memcpy (void*, const void*, __SIZE_TYPE__); + +#define f_pun_i(F, I, VAL) \ + { \ + I i1 = VAL; \ + I i2 = VAL; \ + F q1, q2; \ + memcpy (&q1, &i1, sizeof (I)); \ + __builtin_memcpy (&q2, &i2, sizeof (I)); \ + if (q1 != q2) \ + abort(); \ + } + +#define i_pun_f(I, F, VAL) \ + { \ + F q1 = VAL; \ + F q2 = VAL; \ + I i1, i2; \ + memcpy (&i1, &q1, sizeof (I)); \ + __builtin_memcpy (&i2, &q2, sizeof (I)); \ + if (i1 != i2) \ + abort(); \ + } + + +void __attribute__((noinline)) +test8 (void) +{ +#ifdef __INT8_TYPE__ + if (sizeof (__INT8_TYPE__) == sizeof (short _Fract)) + { +#define TEST(X) f_pun_i (short _Fract, __INT8_TYPE__, __INT8_C (X)) + TEST (123); + TEST (-123); +#undef TEST + +#define TEST(X) i_pun_f (__INT8_TYPE__, short _Fract, X ## hr) + TEST (0.1234); + TEST (-0.987); +#undef TEST + } +#endif /* __INT8_TYPE__ */ +} + + +void __attribute__((noinline)) +test16 (void) +{ +#ifdef __INT16_TYPE__ + + if (sizeof (__INT16_TYPE__) == sizeof (_Fract)) + { +#define TEST(X) f_pun_i (_Fract, __INT16_TYPE__, __INT16_C (X)) + TEST (0x4321); + TEST (-0x4321); + TEST (0x8000); +#undef TEST + +#define TEST(X) i_pun_f (__INT16_TYPE__, _Fract, X ## r) + TEST (0.12345); + TEST (-0.98765); +#undef TEST + } +#endif /* __INT16_TYPE__ */ +} + + +void __attribute__((noinline)) +test32 (void) +{ +#ifdef __INT32_TYPE__ + if (sizeof (__INT32_TYPE__) == sizeof (_Accum)) + { +#define TEST(X) f_pun_i (_Accum, __INT32_TYPE__, __INT32_C (X)) + TEST (0x76543219); + TEST (-0x76543219); + TEST (0x80000000); +#undef TEST + +#define TEST(X) i_pun_f (__INT32_TYPE__, _Accum, X ## k) + TEST (123.456789); + TEST (-123.456789); +#undef TEST + } +#endif /* __INT32_TYPE__ */ +} + + +void __attribute__((noinline)) +test64 (void) +{ +#ifdef __INT64_TYPE__ + if (sizeof (__INT64_TYPE__) == sizeof (long _Accum)) + { +#define TEST(X) f_pun_i (long _Accum, __INT64_TYPE__, __INT64_C (X)) + TEST (0x12345678abcdef01); + TEST (-0x12345678abcdef01); + TEST (0x8000000000000000); +#undef TEST + +#define TEST(X) i_pun_f (__INT64_TYPE__, long _Accum, X ## lk) + TEST (123.456789); + TEST (-123.456789); +#undef TEST + } +#endif /* __INT64_TYPE__ */ +} + +int main() +{ + test8(); + test16(); + test32(); + test64(); + + return 0; +} |