summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/avr/torture
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2014-10-30 09:35:42 +0000
committer <>2015-01-09 11:51:27 +0000
commitc27a97d04853380f1e80525391b3f0d156ed4c84 (patch)
tree68ffaade7c605bc80cffa18360799c98a810976f /gcc/testsuite/gcc.target/avr/torture
parent6af3fdec2262dd94954acc5e426ef71cbd4521d3 (diff)
downloadgcc-tarball-c27a97d04853380f1e80525391b3f0d156ed4c84.tar.gz
Imported from /home/lorry/working-area/delta_gcc-tarball/gcc-4.9.2.tar.bz2.gcc-4.9.2
Diffstat (limited to 'gcc/testsuite/gcc.target/avr/torture')
-rw-r--r--gcc/testsuite/gcc.target/avr/torture/avr-torture.exp2
-rw-r--r--gcc/testsuite/gcc.target/avr/torture/builtins-3-absfx.c171
-rw-r--r--gcc/testsuite/gcc.target/avr/torture/builtins-4-roundfx.c164
-rw-r--r--gcc/testsuite/gcc.target/avr/torture/builtins-5-countlsfx.c82
-rw-r--r--gcc/testsuite/gcc.target/avr/torture/fix-types.h134
-rw-r--r--gcc/testsuite/gcc.target/avr/torture/pr57631.c17
-rw-r--r--gcc/testsuite/gcc.target/avr/torture/pr61055.c88
-rw-r--r--gcc/testsuite/gcc.target/avr/torture/pr61443.c134
-rw-r--r--gcc/testsuite/gcc.target/avr/torture/sat-hr-plus-minus.c98
-rw-r--r--gcc/testsuite/gcc.target/avr/torture/sat-k-plus-minus.c108
-rw-r--r--gcc/testsuite/gcc.target/avr/torture/sat-llk-plus-minus.c108
-rw-r--r--gcc/testsuite/gcc.target/avr/torture/sat-r-plus-minus.c107
-rw-r--r--gcc/testsuite/gcc.target/avr/torture/sat-uhr-plus-minus.c73
-rw-r--r--gcc/testsuite/gcc.target/avr/torture/sat-uk-plus-minus.c82
-rw-r--r--gcc/testsuite/gcc.target/avr/torture/sat-ullk-plus-minus.c82
-rw-r--r--gcc/testsuite/gcc.target/avr/torture/sat-ur-plus-minus.c82
-rw-r--r--gcc/testsuite/gcc.target/avr/torture/vals-hr.def12
-rw-r--r--gcc/testsuite/gcc.target/avr/torture/vals-k.def32
-rw-r--r--gcc/testsuite/gcc.target/avr/torture/vals-llk.def32
-rw-r--r--gcc/testsuite/gcc.target/avr/torture/vals-r.def30
-rw-r--r--gcc/testsuite/gcc.target/avr/torture/vals-uhr.def13
-rw-r--r--gcc/testsuite/gcc.target/avr/torture/vals-uk.def23
-rw-r--r--gcc/testsuite/gcc.target/avr/torture/vals-ullk.def20
-rw-r--r--gcc/testsuite/gcc.target/avr/torture/vals-ur.def17
24 files changed, 1710 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.target/avr/torture/avr-torture.exp b/gcc/testsuite/gcc.target/avr/torture/avr-torture.exp
index 61cd3197fb..3e5fdfbd42 100644
--- a/gcc/testsuite/gcc.target/avr/torture/avr-torture.exp
+++ b/gcc/testsuite/gcc.target/avr/torture/avr-torture.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2008 Free Software Foundation, Inc.
+# Copyright (C) 2008-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.target/avr/torture/builtins-3-absfx.c b/gcc/testsuite/gcc.target/avr/torture/builtins-3-absfx.c
new file mode 100644
index 0000000000..a8bde2952d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/torture/builtins-3-absfx.c
@@ -0,0 +1,171 @@
+/* { dg-options "-std=gnu99" } */
+/* { dg-do run } */
+
+#include <stdfix.h>
+
+extern void abort (void);
+
+short fract test1_hr (short fract x)
+{
+ return abshr (x);
+}
+
+fract test1_r (fract x)
+{
+ return absr (x);
+}
+
+long fract test1_lr (long fract x)
+{
+ return abslr (x);
+}
+
+long long fract test1_llr (long long fract x)
+{
+ return absllr (x);
+}
+
+short accum test1_hk (short accum x)
+{
+ return abshk (x);
+}
+
+accum test1_k (accum x)
+{
+ return absk (x);
+}
+
+long accum test1_lk (long accum x)
+{
+ return abslk (x);
+}
+
+long long accum test1_llk (long long accum x)
+{
+ return absllk (x);
+}
+
+
+short fract test2_hr (void)
+{
+ return abshr (-0.12hr);
+}
+
+fract test2_r (void)
+{
+ return absr (-0.12r);
+}
+
+long fract test2_lr (void)
+{
+ return abslr (-0.12lr);
+}
+
+long long fract test2_llr (void)
+{
+ return absllr (-0.123456llr);
+}
+
+short accum test2_hk (void)
+{
+ return abshk (-221.12hk);
+}
+
+accum test2_k (void)
+{
+ return absk (-4321.12k);
+}
+
+long accum test2_lk (void)
+{
+ return abslk (-4321.12lk);
+}
+
+long long accum test2_llk (void)
+{
+ return absllk (-4321.12llk);
+}
+
+#define TEST1(VAL,FX) \
+ if (abs ## FX (-VAL ## FX -v) != VAL ## FX + v) \
+ abort(); \
+ if (abs ## FX (-VAL ## FX -v) != abs ## FX (VAL ## FX + v)) \
+ abort();
+
+#define TEST2(VAL,FX) \
+ if (abs ## FX (-VAL ## FX) != VAL ## FX) \
+ abort(); \
+ if (abs ## FX (-VAL ## FX) != abs ## FX (VAL ## FX)) \
+ abort();
+
+const __flash short fract volatile v = 0.33hr;
+const __flash short fract volatile z = 0hr;
+
+void test1 (void)
+{
+ TEST1 (0.123, hr);
+ TEST1 (0.123, r);
+ TEST1 (0.1234567, lr);
+ TEST1 (0.1234567, llr);
+
+ TEST1 (223.123, hk);
+ TEST1 (12345.123, k);
+ TEST1 (12342345.123, lk);
+ TEST1 (12345.123, llk);
+}
+
+
+void test2 (void)
+{
+ TEST2 (0.123, hr);
+ TEST2 (0.123, r);
+ TEST2 (0.1234567, lr);
+ TEST2 (0.1234567, llr);
+
+ TEST2 (223.123, hk);
+ TEST2 (12345.123, k);
+ TEST2 (12342345.123, lk);
+ TEST2 (12345.123, llk);
+}
+
+#define MINMAX(T,FX) \
+ { \
+ int_ ## FX ## _t imin \
+ = (int_ ## FX ## _t) 1 << (8 * sizeof (int_ ## FX ## _t) -1); \
+ int_ ## FX ## _t imax = ~imin; \
+ T fmin = FX ## bits (imin); \
+ T fmax = FX ## bits (imax); \
+ \
+ if (abs ## FX (fmin) != fmax) \
+ abort(); \
+ if (abs ## FX (fmin) != abs ## FX (fmax)) \
+ abort(); \
+ if (abs ## FX (fmin + z) != fmax + z) \
+ abort(); \
+ if (abs ## FX (fmin - z) != abs ## FX (fmax + z)) \
+ abort(); \
+ }
+
+void test3 (void)
+{
+ MINMAX (short fract, hr);
+ MINMAX (fract, r);
+ MINMAX (long fract, lr);
+ MINMAX (long long fract, llr);
+
+ MINMAX (short accum, hk);
+ MINMAX (accum, k);
+ MINMAX (long accum, lk);
+ MINMAX (long long accum, llk);
+}
+
+
+int main (void)
+{
+ test1();
+ test2();
+ test3();
+
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.target/avr/torture/builtins-4-roundfx.c b/gcc/testsuite/gcc.target/avr/torture/builtins-4-roundfx.c
new file mode 100644
index 0000000000..46e915a6c8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/torture/builtins-4-roundfx.c
@@ -0,0 +1,164 @@
+/* { dg-options "-std=gnu99" } */
+/* { dg-do run } */
+
+#include <stdfix.h>
+
+extern void abort (void);
+
+typedef short _Fract fx_hr_t;
+typedef _Fract fx_r_t;
+typedef long _Fract fx_lr_t;
+typedef long long _Fract fx_llr_t;
+
+typedef unsigned short _Fract fx_uhr_t;
+typedef unsigned _Fract fx_ur_t;
+typedef unsigned long _Fract fx_ulr_t;
+typedef unsigned long long _Fract fx_ullr_t;
+
+typedef short _Accum fx_hk_t;
+typedef _Accum fx_k_t;
+typedef long _Accum fx_lk_t;
+typedef long long _Accum fx_llk_t;
+
+typedef unsigned short _Accum fx_uhk_t;
+typedef unsigned _Accum fx_uk_t;
+typedef unsigned long _Accum fx_ulk_t;
+typedef unsigned long long _Accum fx_ullk_t;
+
+
+typedef unsigned char int_uhr_t;
+typedef unsigned int int_ur_t;
+typedef unsigned long int_ulr_t;
+typedef unsigned long long int_ullr_t;
+
+typedef unsigned int int_uhk_t;
+typedef unsigned long int_uk_t;
+typedef unsigned long long int_ulk_t;
+typedef unsigned long long int_ullk_t;
+
+
+#define DEFTEST1(T,FX) \
+ T test1_##FX (T x, int rp) \
+ { \
+ return round##FX (x, rp); \
+ } \
+ \
+ unsigned T test1_u##FX (unsigned T x, int rp) \
+ { \
+ return roundu##FX (x, rp); \
+ }
+
+DEFTEST1 (short fract, hr)
+DEFTEST1 (fract, r)
+DEFTEST1 (long fract, lr)
+DEFTEST1 (long long fract, llr)
+
+DEFTEST1 (short accum, hk)
+DEFTEST1 (accum, k)
+
+DEFTEST1 (long accum, lk)
+DEFTEST1 (long long accum, llk)
+
+
+#define TEST2(FX, RP, VAL, ROUND) \
+ { \
+ if (round##FX (FX##bits (VAL), RP) != FX##bits (ROUND)) \
+ abort(); \
+ fx_##FX##_t (*f)(fx_##FX##_t,int) = round##FX; \
+ asm ("" : "+r" (f)); \
+ if (f (FX##bits (VAL), RP) != FX##bits (ROUND)) \
+ abort(); \
+ }
+
+static void test2hr (void)
+{
+ TEST2 (hr, 1, 0x7f, 0x7f);
+ TEST2 (hr, 2, 0x70, 0x7f);
+ TEST2 (hr, 3, 0x78, 0x7f);
+ TEST2 (hr, 4, 0x7f, 0x7f);
+
+ TEST2 (uhr, 1, 0x7f, 0x80);
+ TEST2 (uhr, 2, 0x7f, 0x80);
+ TEST2 (uhr, 3, 0x7f, 0x80);
+ TEST2 (uhr, 4, 0x7f, 0x80);
+}
+
+void test2k (void)
+{
+ TEST2 (k, 1, 0x7fffff00, 0x7fffffff);
+ TEST2 (k, 2, 0x7ffffff0, 0x7fffffff);
+ TEST2 (k, 2, 0x7ffff000, 0x7fffffff);
+ TEST2 (k, 3, 0x7ffff000, 0x7ffff000);
+ TEST2 (k, 3, 0x7ffff800, 0x7fffffff);
+ TEST2 (k, 3, 0x7ffff7ff, 0x7ffff000);
+ TEST2 (k, 4, 0x7ffff7ff, 0x7ffff800);
+
+ TEST2 (uk, 1, 0x7fffffff, 1ul << 31);
+ TEST2 (uk, 2, 0x7fffffff, 1ul << 31);
+ TEST2 (uk, 3, 0x7fffffff, 1ul << 31);
+ TEST2 (uk, 4, 0x7fffffff, 1ul << 31);
+}
+
+#define DEFTEST3(FX, FBIT) \
+ void test3##FX (void) \
+ { \
+ TEST2 (FX, FBIT-1, 0b01100, 0b01100); \
+ TEST2 (FX, FBIT-2, 0b01100, 0b01100); \
+ TEST2 (FX, FBIT-3, 0b01100, 0b10000); \
+ TEST2 (FX, FBIT-4, 0b01100, 0b10000); \
+ TEST2 (FX, FBIT-5, 0b01100, 0); \
+ \
+ if (FX##bits ((int_##FX##_t) -1) > 0) \
+ return; \
+ \
+ TEST2 (FX, FBIT-1, -0b01100, -0b01100); \
+ TEST2 (FX, FBIT-2, -0b01100, -0b01100); \
+ TEST2 (FX, FBIT-3, -0b01100, -0b01000); \
+ TEST2 (FX, FBIT-4, -0b01100, -0b10000); \
+ TEST2 (FX, FBIT-5, -0b01100, -0b00000); \
+ }
+
+DEFTEST3 (hr, SFRACT_FBIT)
+DEFTEST3 (r, FRACT_FBIT)
+DEFTEST3 (lr, LFRACT_FBIT)
+
+DEFTEST3 (uhr, USFRACT_FBIT)
+DEFTEST3 (ur, UFRACT_FBIT)
+DEFTEST3 (ulr, ULFRACT_FBIT)
+
+DEFTEST3 (hk, SACCUM_FBIT)
+DEFTEST3 (k, ACCUM_FBIT)
+DEFTEST3 (lk, LACCUM_FBIT)
+DEFTEST3 (llk, LLACCUM_FBIT)
+
+DEFTEST3 (uhk, USACCUM_FBIT)
+DEFTEST3 (uk, UACCUM_FBIT)
+DEFTEST3 (ulk, ULACCUM_FBIT)
+DEFTEST3 (ullk, ULLACCUM_FBIT)
+
+int main (void)
+{
+ test2hr();
+ test2k();
+
+ test3hr();
+ test3r();
+ test3lr();
+
+ test3uhr();
+ test3ur();
+ test3ulr();
+
+ test3hk();
+ test3k();
+ test3lk();
+ test3llk();
+
+ test3uhk();
+ test3uk();
+ test3ulk();
+ test3ullk();
+
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.target/avr/torture/builtins-5-countlsfx.c b/gcc/testsuite/gcc.target/avr/torture/builtins-5-countlsfx.c
new file mode 100644
index 0000000000..b0ff5e3d48
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/torture/builtins-5-countlsfx.c
@@ -0,0 +1,82 @@
+/* { dg-options "-std=gnu99" } */
+/* { dg-do run } */
+
+#include <stdfix.h>
+
+extern void abort (void);
+
+#define DEFTEST1(T,FX) \
+ int test1_##FX (T x) \
+ { \
+ return countls##FX (x); \
+ } \
+ \
+ int test1_u##FX (unsigned T x) \
+ { \
+ return countlsu##FX (x); \
+ }
+
+DEFTEST1 (short fract, hr)
+DEFTEST1 (fract, r)
+DEFTEST1 (long fract, lr)
+DEFTEST1 (long long fract, llr)
+
+DEFTEST1 (short accum, hk)
+DEFTEST1 (accum, k)
+DEFTEST1 (long accum, lk)
+DEFTEST1 (long long accum, llk)
+
+
+#define TEST2P(FX, VAL, DD) \
+ { \
+ if (countls##FX (FX##bits (VAL)) != 8 * sizeof (0##FX) - DD) \
+ abort(); \
+ \
+ if (countlsu##FX (u##FX##bits (VAL)) != 8 * sizeof (0u##FX) + 1 - DD) \
+ abort(); \
+ }
+
+
+#define TEST2M(FX, VAL, DD) \
+ { \
+ if (countls##FX (FX##bits (VAL)) != 8 * sizeof (0##FX) - (DD)) \
+ abort(); \
+ \
+ if (countlsu##FX (u##FX##bits (VAL)) != 0) \
+ abort(); \
+ }
+
+
+#define TEST2PX(VAL, DD) \
+ TEST2P (hr, VAL, DD); \
+ TEST2P (r, VAL, DD); \
+ TEST2P (lr, VAL, DD); \
+ \
+ TEST2P (hk, VAL, DD); \
+ TEST2P (k, VAL, DD); \
+ TEST2P (lk, VAL, DD); \
+ TEST2P (llk, VAL, DD)
+
+#define TEST2MX(VAL, DD) \
+ TEST2M (hr, VAL, DD); \
+ TEST2M (r, VAL, DD); \
+ TEST2M (lr, VAL, DD); \
+ \
+ TEST2M (hk, VAL, DD); \
+ TEST2M (k, VAL, DD); \
+ TEST2M (lk, VAL, DD); \
+ TEST2M (llk, VAL, DD)
+
+
+int main (void)
+{
+ TEST2PX (1, 2);
+ TEST2PX (2, 3);
+ TEST2PX (3, 3);
+
+ TEST2MX (-1, 1);
+ TEST2MX (-2, 2);
+ TEST2MX (-3, 3);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/avr/torture/fix-types.h b/gcc/testsuite/gcc.target/avr/torture/fix-types.h
new file mode 100644
index 0000000000..f6a2aeb6fa
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/torture/fix-types.h
@@ -0,0 +1,134 @@
+typedef __INT8_TYPE__ int_hr_t;
+typedef __UINT8_TYPE__ int_uhr_t;
+
+typedef __INT16_TYPE__ int_hk_t;
+typedef __UINT16_TYPE__ int_uhk_t;
+typedef __INT16_TYPE__ int_r_t;
+typedef __UINT16_TYPE__ int_ur_t;
+
+typedef __INT32_TYPE__ int_k_t;
+typedef __UINT32_TYPE__ int_uk_t;
+typedef __INT32_TYPE__ int_lr_t;
+typedef __UINT32_TYPE__ int_ulr_t;
+
+typedef __INT64_TYPE__ int_lk_t;
+typedef __UINT64_TYPE__ int_ulk_t;
+typedef __INT64_TYPE__ int_llr_t;
+typedef __UINT64_TYPE__ int_ullr_t;
+typedef __INT64_TYPE__ int_llk_t;
+typedef __UINT64_TYPE__ int_ullk_t;
+
+typedef __INT16_TYPE__ xint_hr_t;
+typedef __UINT16_TYPE__ xint_uhr_t;
+
+typedef __INT32_TYPE__ xint_hk_t;
+typedef __UINT32_TYPE__ xint_uhk_t;
+typedef __INT32_TYPE__ xint_r_t;
+typedef __UINT32_TYPE__ xint_ur_t;
+
+typedef __INT64_TYPE__ xint_k_t;
+typedef __UINT64_TYPE__ xint_uk_t;
+typedef __INT64_TYPE__ xint_lr_t;
+typedef __UINT64_TYPE__ xint_ulr_t;
+
+#define INThr_MAX __INT8_MAX__
+#define INThr_MIN (-__INT8_MAX__-1)
+#define INTuhr_MAX __UINT8_MAX__
+
+#define INTr_MAX __INT16_MAX__
+#define INTr_MIN (-__INT16_MAX__-1)
+#define INTur_MAX __UINT16_MAX__
+
+#define INThk_MAX __INT16_MAX__
+#define INThk_MIN (-__INT16_MAX__-1)
+#define INTuhk_MAX __UINT16_MAX__
+
+#define INTlr_MAX __INT32_MAX__
+#define INTlr_MIN (-__INT32_MAX__-1)
+#define INTulr_MAX __UINT32_MAX__
+
+#define INTk_MAX __INT32_MAX__
+#define INTk_MIN (-__INT32_MAX__-1)
+#define INTuk_MAX __UINT32_MAX__
+
+#define INTlk_MAX __INT64_MAX__
+#define INTlk_MIN (-__INT64_MAX__-1)
+#define INTulk_MAX __UINT64_MAX__
+
+#define INTllk_MAX __INT64_MAX__
+#define INTllk_MIN (-__INT64_MAX__-1)
+#define INTullk_MAX __UINT64_MAX__
+
+#define SS_FUN(NAME, OP, T, FX) \
+ T __attribute__((noinline,noclone)) \
+ NAME##_##FX (T fa, T fb) \
+ { \
+ int_##FX##_t ia; \
+ int_##FX##_t ib; \
+ xint_##FX##_t ic; \
+ __builtin_memcpy (&ia, &fa, sizeof (ia)); \
+ __builtin_memcpy (&ib, &fb, sizeof (ib)); \
+ ic = (xint_##FX##_t) ia OP ib; \
+ if (ic > INT##FX##_MAX) \
+ ic = INT##FX##_MAX; \
+ else if (ic < INT##FX##_MIN) \
+ ic = INT##FX##_MIN; \
+ ia = (int_##FX##_t) ic; \
+ __builtin_memcpy (&fa, &ia, sizeof (ia)); \
+ return fa; \
+ }
+
+#define US_FUN(NAME, OP, T, FX) \
+ T __attribute__((noinline,noclone)) \
+ NAME##_##FX (T fa, T fb) \
+ { \
+ int_##FX##_t ia; \
+ int_##FX##_t ib; \
+ xint_##FX##_t ic; \
+ __builtin_memcpy (&ia, &fa, sizeof (ia)); \
+ __builtin_memcpy (&ib, &fb, sizeof (ib)); \
+ ic = (xint_##FX##_t) ia OP ib; \
+ if (ic > INT##FX##_MAX) \
+ ic = INT##FX##_MAX; \
+ else if (ic < 0) \
+ ic = 0; \
+ ia = (int_##FX##_t) ic; \
+ __builtin_memcpy (&fa, &ia, sizeof (ia)); \
+ return fa; \
+ }
+
+#define SS_LFUN(NAME, OP, T, FX, CMP) \
+ T __attribute__((noinline,noclone)) \
+ NAME##_##FX (T fa, T fb) \
+ { \
+ int_##FX##_t ia; \
+ int_##FX##_t ib; \
+ int_##FX##_t ic; \
+ __builtin_memcpy (&ia, &fa, sizeof (ia)); \
+ __builtin_memcpy (&ib, &fb, sizeof (ib)); \
+ ic = (int_##FX##_t) ia OP ib; \
+ if (ic < ia && ib CMP 0) \
+ ic = INT##FX##_MAX; \
+ else if (ic > ia && 0 CMP ib) \
+ ic = INT##FX##_MIN; \
+ __builtin_memcpy (&fa, &ic, sizeof (ic)); \
+ return fa; \
+ }
+
+#define US_LFUN(NAME, OP, T, FX, CMP) \
+ T __attribute__((noinline,noclone)) \
+ NAME##_##FX (T fa, T fb) \
+ { \
+ int_##FX##_t ia; \
+ int_##FX##_t ib; \
+ int_##FX##_t ic; \
+ __builtin_memcpy (&ia, &fa, sizeof (ia)); \
+ __builtin_memcpy (&ib, &fb, sizeof (ib)); \
+ ic = (int_##FX##_t) ia OP ib; \
+ if (ia CMP ic && 1 CMP 0) \
+ ic = INT##FX##_MAX; \
+ if (ia CMP ic && 0 CMP 1) \
+ ic = 0; \
+ __builtin_memcpy (&fa, &ic, sizeof (ic)); \
+ return fa; \
+ }
diff --git a/gcc/testsuite/gcc.target/avr/torture/pr57631.c b/gcc/testsuite/gcc.target/avr/torture/pr57631.c
new file mode 100644
index 0000000000..ecefbfc81b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/torture/pr57631.c
@@ -0,0 +1,17 @@
+/* PR target/57631 */
+/* { dg-do compile } */
+
+void __attribute__((signal)) func1 (void) __asm ("__vector1");
+void func1 (void)
+{
+}
+
+void __attribute__((signal)) func2 (void) __asm ("__vecto1");
+void func2 (void) /* { dg-warning "misspelled signal handler" } */
+{
+}
+
+void __attribute__((signal)) __vector_3 (void) __asm ("__vecto1");
+void __vector_3 (void) /* { dg-warning "misspelled signal handler" } */
+{
+}
diff --git a/gcc/testsuite/gcc.target/avr/torture/pr61055.c b/gcc/testsuite/gcc.target/avr/torture/pr61055.c
new file mode 100644
index 0000000000..9dd1f427d0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/torture/pr61055.c
@@ -0,0 +1,88 @@
+/* { dg-do run } */
+/* { dg-options { -fno-peephole2 } } */
+
+#include <stdlib.h>
+
+typedef __UINT16_TYPE__ uint16_t;
+typedef __INT16_TYPE__ int16_t;
+typedef __UINT8_TYPE__ uint8_t;
+
+uint8_t __attribute__((noinline,noclone))
+fun_inc (uint8_t c0)
+{
+ register uint8_t c asm ("r15") = c0;
+
+ /* Force target value into R15 (lower register) */
+ asm ("" : "+l" (c));
+
+ c++;
+ if (c >= 0x80)
+ c = 0;
+
+ asm ("" : "+l" (c));
+
+ return c;
+}
+
+uint8_t __attribute__((noinline,noclone))
+fun_dec (uint8_t c0)
+{
+ register uint8_t c asm ("r15") = c0;
+
+ /* Force target value into R15 (lower register) */
+ asm ("" : "+l" (c));
+
+ c--;
+ if (c < 0x80)
+ c = 0;
+
+ asm ("" : "+l" (c));
+
+ return c;
+}
+
+
+uint8_t __attribute__((noinline,noclone))
+fun_neg (uint8_t c0)
+{
+ register uint8_t c asm ("r15") = c0;
+
+ c = -c;
+ if (c >= 0x80)
+ c = 0;
+
+ return c;
+}
+
+uint16_t __attribute__((noinline,noclone))
+fun_adiw (uint16_t c0)
+{
+ register uint16_t c asm ("r24") = c0;
+
+ /* Force target value into R24 (for ADIW) */
+ asm ("" : "+r" (c));
+
+ c += 2;
+ if (c >= 0x8000)
+ c = 0;
+
+ asm ("" : "+r" (c));
+
+ return c;
+}
+
+
+int main()
+{
+ if (fun_inc (0x7f) != 0)
+ abort();
+
+ if (fun_neg (0x80) != 0)
+ abort();
+
+ if (fun_adiw (0x7ffe) != 0)
+ abort();
+
+ exit (0);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/avr/torture/pr61443.c b/gcc/testsuite/gcc.target/avr/torture/pr61443.c
new file mode 100644
index 0000000000..12c6bca666
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/torture/pr61443.c
@@ -0,0 +1,134 @@
+/* { dg-do run } */
+/* { dg-options "-std=gnu99" } */
+
+#include <stdlib.h>
+#include <stdarg.h>
+
+#define NC __attribute__((noinline,noclone))
+
+void NC vfun (char n, ...)
+{
+ va_list ap;
+
+ va_start (ap, n);
+
+ switch (n)
+ {
+ default:
+ abort();
+ case 1:
+ if (11 != va_arg (ap, int))
+ abort();
+ break;
+ case 2:
+ if (2222 != va_arg (ap, int))
+ abort();
+ break;
+ case 3:
+ if (333333 != va_arg (ap, __int24))
+ abort();
+ break;
+ case 4:
+ if (44444444 != va_arg (ap, long))
+ abort();
+ break;
+ case 8:
+ if (8888888888888888 != va_arg (ap, long long))
+ abort();
+ break;
+ }
+
+ va_end (ap);
+}
+
+
+void NC boo_qi (const __flash char *p)
+{
+ vfun (1, *p);
+}
+
+void NC boox_qi (const __memx char *p)
+{
+ vfun (1, *p);
+}
+
+void NC boo_hi (const __flash int *p)
+{
+ vfun (2, *p);
+}
+
+void NC boox_hi (const __memx int *p)
+{
+ vfun (2, *p);
+}
+
+void NC boo_psi (const __flash __int24 *p)
+{
+ vfun (3, *p);
+}
+
+void NC boox_psi (const __memx __int24 *p)
+{
+ vfun (3, *p);
+}
+
+void NC boo_si (const __flash long *p)
+{
+ vfun (4, *p);
+}
+
+void NC boox_si (const __memx long *p)
+{
+ vfun (4, *p);
+}
+
+void NC boo_di (const __flash long long *p)
+{
+ vfun (8, *p);
+}
+
+void NC boox_di (const __memx long long *p)
+{
+ vfun (8, *p);
+}
+
+const __flash char f_qi = 11;
+const __flash int f_hi = 2222;
+const __flash __int24 f_psi = 333333;
+const __flash long f_si = 44444444;
+const __flash long long f_di = 8888888888888888;
+
+const __memx char x_qi = 11;
+const __memx int x_hi = 2222;
+const __memx __int24 x_psi = 333333;
+const __memx long x_si = 44444444;
+const __memx long long x_di = 8888888888888888;
+
+char r_qi = 11;
+int r_hi = 2222;
+__int24 r_psi = 333333;
+long r_si = 44444444;
+long long r_di = 8888888888888888;
+
+int main (void)
+{
+ boo_qi (&f_qi);
+ boo_hi (&f_hi);
+ boo_psi (&f_psi);
+ boo_si (&f_si);
+ boo_di (&f_di);
+
+ boox_qi (&x_qi);
+ boox_hi (&x_hi);
+ boox_psi (&x_psi);
+ boox_si (&x_si);
+ boox_di (&x_di);
+
+ boox_qi (&r_qi);
+ boox_hi (&r_hi);
+ boox_psi (&r_psi);
+ boox_si (&r_si);
+ boox_di (&r_di);
+
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.target/avr/torture/sat-hr-plus-minus.c b/gcc/testsuite/gcc.target/avr/torture/sat-hr-plus-minus.c
new file mode 100644
index 0000000000..1e6215e4f4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/torture/sat-hr-plus-minus.c
@@ -0,0 +1,98 @@
+/* { dg-do run } */
+/* { dg-options "-std=gnu99 -fwrapv" } */
+
+#include "fix-types.h"
+
+extern void abort (void);
+extern void exit (int);
+
+typedef short _Fract fx_t;
+typedef short _Sat _Fract satfx_t;
+typedef char intfx_t;
+
+SS_FUN (ss_add, +, fx_t, hr)
+SS_FUN (ss_sub, -, fx_t, hr)
+
+#define VAL(N, X) \
+ __attribute__((noinline,noclone)) \
+ satfx_t ss_add2_##N (satfx_t a) \
+ { \
+ return ss_add_hr (a, X##P##-##7hr); \
+ } \
+ __attribute__((noinline,noclone)) \
+ satfx_t ss_add_##N (satfx_t a) \
+ { \
+ return a + X##P##-##7hr; \
+ } \
+ __attribute__((noinline,noclone)) \
+ satfx_t ss_sub2_##N (satfx_t a) \
+ { \
+ return ss_sub_hr (a, X##P##-##7hr); \
+ } \
+ __attribute__((noinline,noclone)) \
+ satfx_t ss_sub_##N (satfx_t a) \
+ { \
+ return a - X##P##-##7hr; \
+ }
+#include "vals-hr.def"
+#undef VAL
+
+__attribute__((noinline,noclone))
+satfx_t ss_add2_99 (satfx_t a)
+{
+ return ss_add_hr (a, __FRACT_MIN__);
+}
+
+__attribute__((noinline,noclone))
+satfx_t ss_add_99 (satfx_t a)
+{
+ return a + __FRACT_MIN__;
+}
+
+__attribute__((noinline,noclone))
+satfx_t ss_sub2_99 (satfx_t a)
+{
+ return ss_sub_hr (a, __FRACT_MIN__);
+}
+
+__attribute__((noinline,noclone))
+satfx_t ss_sub_99 (satfx_t a)
+{
+ return a - __FRACT_MIN__;
+}
+
+
+satfx_t (* __flash const fun[])(satfx_t) =
+{
+#define VAL(N, X) \
+ ss_add_##N, ss_add2_##N, \
+ ss_sub_##N, ss_sub2_##N,
+#include "vals-hr.def"
+ VAL (99,)
+#undef VAL
+};
+
+
+const volatile __flash intfx_t vals[] =
+ {
+ 0, 1, 2, 0x7f, 0x80, 0x81, 0xff,
+ 0x40, 0x3e, 0x3f, 0xbf, 0xc0, 0xc1
+ };
+
+int main (void)
+{
+ for (unsigned int i = 0; i < sizeof (vals) / sizeof (*vals); i++)
+ {
+ satfx_t a, f1, f2;
+ intfx_t val = vals[i];
+ __builtin_memcpy (&a, &val, sizeof (satfx_t));
+ for (unsigned int f = 0; f < sizeof (fun) / sizeof (*fun); f += 2)
+ {
+ if (fun[f](a) != fun[f+1](a))
+ abort();
+ }
+ }
+
+ exit (0);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/avr/torture/sat-k-plus-minus.c b/gcc/testsuite/gcc.target/avr/torture/sat-k-plus-minus.c
new file mode 100644
index 0000000000..8a26ffeeb3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/torture/sat-k-plus-minus.c
@@ -0,0 +1,108 @@
+/* { dg-do run } */
+/* { dg-options "-std=gnu99 -fwrapv" } */
+
+#include "fix-types.h"
+
+extern void abort (void);
+extern void exit (int);
+
+typedef _Accum fx_t;
+typedef _Sat _Accum satfx_t;
+typedef long intfx_t;
+
+SS_FUN (ss_add, +, fx_t, k)
+SS_FUN (ss_sub, -, fx_t, k)
+
+#define VAL(N, X) \
+ __attribute__((noinline,noclone)) \
+ satfx_t ss_add2_##N (satfx_t a) \
+ { \
+ return ss_add_k (a, X##P##-##16k); \
+ } \
+ __attribute__((noinline,noclone)) \
+ satfx_t ss_add_##N (satfx_t a) \
+ { \
+ return a + X##P##-##16k; \
+ } \
+ __attribute__((noinline,noclone)) \
+ satfx_t ss_sub2_##N (satfx_t a) \
+ { \
+ return ss_sub_k (a, X##P##-##16k); \
+ } \
+ __attribute__((noinline,noclone)) \
+ satfx_t ss_sub_##N (satfx_t a) \
+ { \
+ return a - X##P##-##16k; \
+ }
+#include "vals-k.def"
+#undef VAL
+
+__attribute__((noinline,noclone))
+satfx_t ss_add2_99 (satfx_t a)
+{
+ return ss_add_k (a, __ACCUM_MIN__);
+}
+
+__attribute__((noinline,noclone))
+satfx_t ss_add_99 (satfx_t a)
+{
+ return a + __ACCUM_MIN__;
+}
+
+__attribute__((noinline,noclone))
+satfx_t ss_sub2_99 (satfx_t a)
+{
+ return ss_sub_k (a, __ACCUM_MIN__);
+}
+
+__attribute__((noinline,noclone))
+satfx_t ss_sub_99 (satfx_t a)
+{
+ return a - __ACCUM_MIN__;
+}
+
+
+satfx_t (* __flash const fun[])(satfx_t) =
+{
+#define VAL(N, X) \
+ ss_add_##N, ss_add2_##N, \
+ ss_sub_##N, ss_sub2_##N,
+#include "vals-k.def"
+ VAL (99,)
+#undef VAL
+};
+
+
+const volatile __flash intfx_t vals[] =
+ {
+ 0, -1, 1, -2, 2, -127, -128, -129,
+ 0x7f, 0x80, 0x81, 0x100,
+ 0x40000000, 0x3e800000, 0x3f800000,
+ 0x7ffffffe, 0x7fffffff, 0x7f800000,
+ 0x7f7f7f7f, 0x7f810080, 0x7f008000,
+ 0x7f000001,
+ 0x80000000, 0x80000001, 0x80808080,
+ 0x80810000, 0x80ffffff, 0x80fffffe,
+ 0x81000000, 0x81800000, 0x81800000,
+ 0xff000000, 0xffffff01, 0xffffff80,
+ 0xffffff7f, 0xff80ff80
+ };
+
+
+int main (void)
+{
+ for (unsigned int i = 0; i < sizeof (vals) / sizeof (*vals); i++)
+ {
+ satfx_t a, f1, f2;
+ intfx_t val = vals[i];
+ __builtin_memcpy (&a, &val, sizeof (satfx_t));
+ for (unsigned int f = 0; f < sizeof (fun) / sizeof (*fun); f += 2)
+ {
+ if (fun[f](a) != fun[f+1](a))
+ abort();
+ }
+ }
+
+ exit (0);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/avr/torture/sat-llk-plus-minus.c b/gcc/testsuite/gcc.target/avr/torture/sat-llk-plus-minus.c
new file mode 100644
index 0000000000..e81cbb187e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/torture/sat-llk-plus-minus.c
@@ -0,0 +1,108 @@
+/* { dg-do run } */
+/* { dg-options "-std=gnu99 -fwrapv" } */
+
+#include "fix-types.h"
+
+extern void abort (void);
+extern void exit (int);
+
+typedef long long _Accum fx_t;
+typedef long long _Sat _Accum satfx_t;
+typedef long long intfx_t;
+
+SS_LFUN (ss_add, +, fx_t, llk, >)
+SS_LFUN (ss_sub, -, fx_t, llk, <)
+
+#define VAL(N, X) \
+ __attribute__((noinline,noclone)) \
+ satfx_t ss_add2_##N (satfx_t a) \
+ { \
+ return ss_add_llk (a, X##P##-##48llk); \
+ } \
+ __attribute__((noinline,noclone)) \
+ satfx_t ss_add_##N (satfx_t a) \
+ { \
+ return a + X##P##-##48llk; \
+ } \
+ __attribute__((noinline,noclone)) \
+ satfx_t ss_sub2_##N (satfx_t a) \
+ { \
+ return ss_sub_llk (a, X##P##-##48llk); \
+ } \
+ __attribute__((noinline,noclone)) \
+ satfx_t ss_sub_##N (satfx_t a) \
+ { \
+ return a - X##P##-##48llk; \
+ }
+#include "vals-llk.def"
+#undef VAL
+
+__attribute__((noinline,noclone))
+satfx_t ss_add2_99 (satfx_t a)
+{
+ return ss_add_llk (a, __LLACCUM_MIN__);
+}
+
+__attribute__((noinline,noclone))
+satfx_t ss_add_99 (satfx_t a)
+{
+ return a + __LLACCUM_MIN__;
+}
+
+__attribute__((noinline,noclone))
+satfx_t ss_sub2_99 (satfx_t a)
+{
+ return ss_sub_llk (a, __LLACCUM_MIN__);
+}
+
+__attribute__((noinline,noclone))
+satfx_t ss_sub_99 (satfx_t a)
+{
+ return a - __LLACCUM_MIN__;
+}
+
+
+satfx_t (* __flash const fun[])(satfx_t) =
+{
+#define VAL(N, X) \
+ ss_add_##N, ss_add2_##N, \
+ ss_sub_##N, ss_sub2_##N,
+#include "vals-llk.def"
+ VAL (99,)
+#undef VAL
+};
+
+
+const volatile __flash intfx_t vals[] =
+ {
+ 0, -1, 1, -2, 2, -127, -128, -129,
+ 0x7f, 0x80, 0x81, 0x100,
+ 0x4000000000000000, 0x3e80000000000000, 0x3f80000000000000,
+ 0x7ffffffffffffffe, 0x7fffffffffffffff, 0x7f80000000000000,
+ 0x7f7f7f7f7f7f7f7f, 0x7f81000000000080, 0x7f00000080000000,
+ 0x7f00000000000001,
+ 0x8000000000000000, 0x8000000000000001, 0x8080808080808080,
+ 0x8081000000000000, 0x80ffffffffffffff, 0x80fffffffffffffe,
+ 0x8100000000000000, 0x8180000000000000, 0x818000000000000,
+ 0xff00000000000000, 0xffffffffffffff01, 0xffffffffffffff80,
+ 0xffffffffffffff7f, 0xff80ff80ff80ff80
+ };
+
+
+int main (void)
+{
+ for (unsigned int i = 0; i < sizeof (vals) / sizeof (*vals); i++)
+ {
+ satfx_t a, f1, f2;
+ intfx_t val = vals[i];
+ __builtin_memcpy (&a, &val, sizeof (satfx_t));
+ for (unsigned int f = 0; f < sizeof (fun) / sizeof (*fun); f += 2)
+ {
+ if (fun[f](a) != fun[f+1](a))
+ abort();
+ }
+ }
+
+ exit (0);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/avr/torture/sat-r-plus-minus.c b/gcc/testsuite/gcc.target/avr/torture/sat-r-plus-minus.c
new file mode 100644
index 0000000000..e59bcf655a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/torture/sat-r-plus-minus.c
@@ -0,0 +1,107 @@
+/* { dg-do run } */
+/* { dg-options "-std=gnu99 -fwrapv" } */
+
+#include "fix-types.h"
+
+extern void abort (void);
+extern void exit (int);
+
+typedef _Fract fx_t;
+typedef _Sat _Fract satfx_t;
+typedef int intfx_t;
+
+SS_FUN (ss_add, +, fx_t, r)
+SS_FUN (ss_sub, -, fx_t, r)
+
+#define VAL(N, X) \
+ __attribute__((noinline,noclone)) \
+ satfx_t ss_add2_##N (satfx_t a) \
+ { \
+ return ss_add_r (a, X##P##-##15r); \
+ } \
+ __attribute__((noinline,noclone)) \
+ satfx_t ss_add_##N (satfx_t a) \
+ { \
+ return a + X##P##-##15r; \
+ } \
+ __attribute__((noinline,noclone)) \
+ satfx_t ss_sub2_##N (satfx_t a) \
+ { \
+ return ss_sub_r (a, X##P##-##15r); \
+ } \
+ __attribute__((noinline,noclone)) \
+ satfx_t ss_sub_##N (satfx_t a) \
+ { \
+ return a - X##P##-##15r; \
+ }
+#include "vals-r.def"
+#undef VAL
+
+__attribute__((noinline,noclone))
+satfx_t ss_add2_99 (satfx_t a)
+{
+ return ss_add_r (a, __FRACT_MIN__);
+}
+
+__attribute__((noinline,noclone))
+satfx_t ss_add_99 (satfx_t a)
+{
+ return a + __FRACT_MIN__;
+}
+
+__attribute__((noinline,noclone))
+satfx_t ss_sub2_99 (satfx_t a)
+{
+ return ss_sub_r (a, __FRACT_MIN__);
+}
+
+__attribute__((noinline,noclone))
+satfx_t ss_sub_99 (satfx_t a)
+{
+ return a - __FRACT_MIN__;
+}
+
+
+satfx_t (* __flash const fun[])(satfx_t) =
+{
+#define VAL(N, X) \
+ ss_add_##N, ss_add2_##N, \
+ ss_sub_##N, ss_sub2_##N,
+#include "vals-r.def"
+ VAL (99,)
+#undef VAL
+};
+
+
+const volatile __flash intfx_t vals[] =
+ {
+ 0, -1, 1, -2, 2, -127, -128, -129,
+ 0x7f, 0x80, 0x81, 0x100,
+ 0x4000, 0x3e80, 0x3f80,
+ 0x7ffe, 0x7fff,
+ 0x7f7f, 0x7f81, 0x7f80,
+ 0x7f01,
+ 0x8000, 0x8001, 0x8080,
+ 0x8081, 0x80ff, 0x80fe,
+ 0x8100, 0x8180, 0x817f,
+ 0xff00, 0xff01, 0xff01,
+ 0xff7f, 0xff80
+ };
+
+int main (void)
+{
+ for (unsigned int i = 0; i < sizeof (vals) / sizeof (*vals); i++)
+ {
+ satfx_t a, f1, f2;
+ intfx_t val = vals[i];
+ __builtin_memcpy (&a, &val, sizeof (satfx_t));
+ for (unsigned int f = 0; f < sizeof (fun) / sizeof (*fun); f += 2)
+ {
+ if (fun[f](a) != fun[f+1](a))
+ abort();
+ }
+ }
+
+ exit (0);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/avr/torture/sat-uhr-plus-minus.c b/gcc/testsuite/gcc.target/avr/torture/sat-uhr-plus-minus.c
new file mode 100644
index 0000000000..6dd191f7ac
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/torture/sat-uhr-plus-minus.c
@@ -0,0 +1,73 @@
+/* { dg-do run } */
+/* { dg-options "-std=gnu99 -fwrapv" } */
+
+#include "fix-types.h"
+
+extern void abort (void);
+extern void exit (int);
+
+typedef unsigned short _Fract fx_t;
+typedef unsigned short _Sat _Fract satfx_t;
+typedef unsigned char intfx_t;
+
+US_LFUN (us_add, +, fx_t, uhr, >)
+US_LFUN (us_sub, -, fx_t, uhr, <)
+
+#define VAL(N, X) \
+ __attribute__((noinline,noclone)) \
+ satfx_t us_add2_##N (satfx_t a) \
+ { \
+ return us_add_uhr (a, X##P##-##8uhr); \
+ } \
+ __attribute__((noinline,noclone)) \
+ satfx_t us_add_##N (satfx_t a) \
+ { \
+ return a + X##P##-##8uhr; \
+ } \
+ __attribute__((noinline,noclone)) \
+ satfx_t us_sub2_##N (satfx_t a) \
+ { \
+ return us_sub_uhr (a, X##P##-##8uhr); \
+ } \
+ __attribute__((noinline,noclone)) \
+ satfx_t us_sub_##N (satfx_t a) \
+ { \
+ return a - X##P##-##8uhr; \
+ }
+#include "vals-uhr.def"
+#undef VAL
+
+satfx_t (* __flash const fun[])(satfx_t) =
+{
+#define VAL(N, X) \
+ us_add_##N, us_add2_##N, \
+ us_sub_##N, us_sub2_##N,
+#include "vals-uhr.def"
+#undef VAL
+};
+
+
+const volatile __flash intfx_t vals[] =
+ {
+ 0, 1, 2, 0x7f, 0x80, 0x81, 0xff,
+ 0x40, 0x3e, 0x3f, 0xbf, 0xc0, 0xc1
+ };
+
+
+int main (void)
+{
+ for (unsigned int i = 0; i < sizeof (vals) / sizeof (*vals); i++)
+ {
+ satfx_t a, f1, f2;
+ intfx_t val = vals[i];
+ __builtin_memcpy (&a, &val, sizeof (satfx_t));
+ for (unsigned int f = 0; f < sizeof (fun) / sizeof (*fun); f += 2)
+ {
+ if (fun[f](a) != fun[f+1](a))
+ abort();
+ }
+ }
+
+ exit (0);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/avr/torture/sat-uk-plus-minus.c b/gcc/testsuite/gcc.target/avr/torture/sat-uk-plus-minus.c
new file mode 100644
index 0000000000..c9a7cd6ba4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/torture/sat-uk-plus-minus.c
@@ -0,0 +1,82 @@
+/* { dg-do run } */
+/* { dg-options "-std=gnu99 -fwrapv" } */
+
+#include "fix-types.h"
+
+extern void abort (void);
+extern void exit (int);
+
+typedef unsigned _Accum fx_t;
+typedef unsigned _Sat _Accum satfx_t;
+typedef unsigned long intfx_t;
+
+US_LFUN (us_add, +, fx_t, uk, >)
+US_LFUN (us_sub, -, fx_t, uk, <)
+
+#define VAL(N, X) \
+ __attribute__((noinline,noclone)) \
+ satfx_t us_add2_##N (satfx_t a) \
+ { \
+ return us_add_uk (a, X##P##-##16uk); \
+ } \
+ __attribute__((noinline,noclone)) \
+ satfx_t us_add_##N (satfx_t a) \
+ { \
+ return a + X##P##-##16uk; \
+ } \
+ __attribute__((noinline,noclone)) \
+ satfx_t us_sub2_##N (satfx_t a) \
+ { \
+ return us_sub_uk (a, X##P##-##16uk); \
+ } \
+ __attribute__((noinline,noclone)) \
+ satfx_t us_sub_##N (satfx_t a) \
+ { \
+ return a - X##P##-##16uk; \
+ }
+#include "vals-uk.def"
+#undef VAL
+
+satfx_t (* __flash const fun[])(satfx_t) =
+{
+#define VAL(N, X) \
+ us_add_##N, us_add2_##N, \
+ us_sub_##N, us_sub2_##N,
+#include "vals-uk.def"
+#undef VAL
+};
+
+
+const volatile __flash intfx_t vals[] =
+ {
+ 0, -1, 1, -2, 2, -127, -128, -129,
+ 0x7f, 0x80, 0x81, 0x100,
+ 0x40000000, 0x3e800000, 0x3f800000,
+ 0x7ffffffe, 0x7fffffff, 0x7f800000,
+ 0x7f7f7f7f, 0x7f810080, 0x7f008000,
+ 0x7f000001,
+ 0x80000000, 0x80000001, 0x80808080,
+ 0x80810000, 0x80ffffff, 0x80fffffe,
+ 0x81000000, 0x81800000, 0x81800000,
+ 0xff000000, 0xffffff01, 0xffffff80,
+ 0xffffff7f, 0xff80ff80
+ };
+
+
+int main (void)
+{
+ for (unsigned int i = 0; i < sizeof (vals) / sizeof (*vals); i++)
+ {
+ satfx_t a, f1, f2;
+ intfx_t val = vals[i];
+ __builtin_memcpy (&a, &val, sizeof (satfx_t));
+ for (unsigned int f = 0; f < sizeof (fun) / sizeof (*fun); f += 2)
+ {
+ if (fun[f](a) != fun[f+1](a))
+ abort();
+ }
+ }
+
+ exit (0);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/avr/torture/sat-ullk-plus-minus.c b/gcc/testsuite/gcc.target/avr/torture/sat-ullk-plus-minus.c
new file mode 100644
index 0000000000..22ebb8af50
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/torture/sat-ullk-plus-minus.c
@@ -0,0 +1,82 @@
+/* { dg-do run } */
+/* { dg-options "-std=gnu99 -fwrapv" } */
+
+#include "fix-types.h"
+
+extern void abort (void);
+extern void exit (int);
+
+typedef unsigned long long _Accum fx_t;
+typedef unsigned long long _Sat _Accum satfx_t;
+typedef unsigned long long intfx_t;
+
+US_LFUN (us_add, +, fx_t, ullk, >)
+US_LFUN (us_sub, -, fx_t, ullk, <)
+
+#define VAL(N, X) \
+ __attribute__((noinline,noclone)) \
+ satfx_t us_add2_##N (satfx_t a) \
+ { \
+ return us_add_ullk (a, X##P##-##48ullk); \
+ } \
+ __attribute__((noinline,noclone)) \
+ satfx_t us_add_##N (satfx_t a) \
+ { \
+ return a + X##P##-##48ullk; \
+ } \
+ __attribute__((noinline,noclone)) \
+ satfx_t us_sub2_##N (satfx_t a) \
+ { \
+ return us_sub_ullk (a, X##P##-##48ullk); \
+ } \
+ __attribute__((noinline,noclone)) \
+ satfx_t us_sub_##N (satfx_t a) \
+ { \
+ return a - X##P##-##48ullk; \
+ }
+#include "vals-ullk.def"
+#undef VAL
+
+satfx_t (* __flash const fun[])(satfx_t) =
+{
+#define VAL(N, X) \
+ us_add_##N, us_add2_##N, \
+ us_sub_##N, us_sub2_##N,
+#include "vals-ullk.def"
+#undef VAL
+};
+
+
+const volatile __flash intfx_t vals[] =
+ {
+ 0, -1, 1, -2, 2, -127, -128, -129,
+ 0x7f, 0x80, 0x81, 0x100,
+ 0x4000000000000000, 0x3e80000000000000, 0x3f80000000000000,
+ 0x7ffffffffffffffe, 0x7fffffffffffffff, 0x7f80000000000000,
+ 0x7f7f7f7f7f7f7f7f, 0x7f81000000000080, 0x7f00000080000000,
+ 0x7f00000000000001,
+ 0x8000000000000000, 0x8000000000000001, 0x8080808080808080,
+ 0x8081000000000000, 0x80ffffffffffffff, 0x80fffffffffffffe,
+ 0x8100000000000000, 0x8180000000000000, 0x818000000000000,
+ 0xff00000000000000, 0xffffffffffffff01, 0xffffffffffffff80,
+ 0xffffffffffffff7f, 0xff80ff80ff80ff80
+ };
+
+
+int main (void)
+{
+ for (unsigned int i = 0; i < sizeof (vals) / sizeof (*vals); i++)
+ {
+ satfx_t a, f1, f2;
+ intfx_t val = vals[i];
+ __builtin_memcpy (&a, &val, sizeof (satfx_t));
+ for (unsigned int f = 0; f < sizeof (fun) / sizeof (*fun); f += 2)
+ {
+ if (fun[f](a) != fun[f+1](a))
+ abort();
+ }
+ }
+
+ exit (0);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/avr/torture/sat-ur-plus-minus.c b/gcc/testsuite/gcc.target/avr/torture/sat-ur-plus-minus.c
new file mode 100644
index 0000000000..bc3c0bbcd9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/torture/sat-ur-plus-minus.c
@@ -0,0 +1,82 @@
+/* { dg-do run } */
+/* { dg-options "-std=gnu99 -fwrapv" } */
+
+#include "fix-types.h"
+
+extern void abort (void);
+extern void exit (int);
+
+typedef unsigned _Fract fx_t;
+typedef unsigned _Sat _Fract satfx_t;
+typedef unsigned int intfx_t;
+
+US_LFUN (us_add, +, fx_t, ur, >)
+US_LFUN (us_sub, -, fx_t, ur, <)
+
+#define VAL(N, X) \
+ __attribute__((noinline,noclone)) \
+ satfx_t us_add2_##N (satfx_t a) \
+ { \
+ return us_add_ur (a, X##P##-##16ur); \
+ } \
+ __attribute__((noinline,noclone)) \
+ satfx_t us_add_##N (satfx_t a) \
+ { \
+ return a + X##P##-##16ur; \
+ } \
+ __attribute__((noinline,noclone)) \
+ satfx_t us_sub2_##N (satfx_t a) \
+ { \
+ return us_sub_ur (a, X##P##-##16ur); \
+ } \
+ __attribute__((noinline,noclone)) \
+ satfx_t us_sub_##N (satfx_t a) \
+ { \
+ return a - X##P##-##16ur; \
+ }
+#include "vals-ur.def"
+#undef VAL
+
+satfx_t (* __flash const fun[])(satfx_t) =
+{
+#define VAL(N, X) \
+ us_add_##N, us_add2_##N, \
+ us_sub_##N, us_sub2_##N,
+#include "vals-ur.def"
+#undef VAL
+};
+
+
+const volatile __flash intfx_t vals[] =
+ {
+ 0, -1, 1, -2, 2, -127, -128, -129,
+ 0x7f, 0x80, 0x81, 0x100,
+ 0x4000, 0x3e80, 0x3f80,
+ 0x7ffe, 0x7fff,
+ 0x7f7f, 0x7f81, 0x7f80,
+ 0x7f01,
+ 0x8000, 0x8001, 0x8080,
+ 0x8081, 0x80ff, 0x80fe,
+ 0x8100, 0x8180, 0x817f,
+ 0xff00, 0xff01, 0xff01,
+ 0xff7f, 0xff80
+ };
+
+
+int main (void)
+{
+ for (unsigned int i = 0; i < sizeof (vals) / sizeof (*vals); i++)
+ {
+ satfx_t a, f1, f2;
+ intfx_t val = vals[i];
+ __builtin_memcpy (&a, &val, sizeof (satfx_t));
+ for (unsigned int f = 0; f < sizeof (fun) / sizeof (*fun); f += 2)
+ {
+ if (fun[f](a) != fun[f+1](a))
+ abort();
+ }
+ }
+
+ exit (0);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/avr/torture/vals-hr.def b/gcc/testsuite/gcc.target/avr/torture/vals-hr.def
new file mode 100644
index 0000000000..f6619c2ff5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/torture/vals-hr.def
@@ -0,0 +1,12 @@
+VAL (01, 0x0)
+VAL (02, 0x1)
+VAL (03, 0x3f)
+VAL (04,-0x3f)
+VAL (07, 0x40)
+VAL (08,-0x40)
+VAL (10,-0x1)
+VAL (12, 0x3f)
+VAL (13,-0x3f)
+VAL (14, 0x7f)
+VAL (15,-0x7f)
+
diff --git a/gcc/testsuite/gcc.target/avr/torture/vals-k.def b/gcc/testsuite/gcc.target/avr/torture/vals-k.def
new file mode 100644
index 0000000000..a490c69b36
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/torture/vals-k.def
@@ -0,0 +1,32 @@
+VAL (01, 0x0)
+VAL (02, 0x1)
+VAL (03, 0x3f)
+VAL (04, 0x80)
+VAL (05, -0x1)
+VAL (06, -0x3f)
+VAL (07, 0x40000000)
+VAL (08,-0x40000000)
+
+VAL (10,-0x7fffffff)
+VAL (11, 0x7fffffff)
+VAL (12, 0x7f800000)
+VAL (13,-0x7f800000)
+VAL (14, 0x7f800001)
+VAL (15,-0x7f800001)
+VAL (16, 0x7f7f7f7f)
+VAL (17,-0x7f7f7f7f)
+VAL (18, 0x7f808080)
+VAL (19,-0x7f808080)
+VAL (20, 0x3e800000)
+VAL (21,-0x3e800000)
+VAL (22, 0x3f800000)
+VAL (23,-0x3f800000)
+VAL (24, 0x400000)
+VAL (25,-0x400000)
+VAL (26, 0x3f000000)
+VAL (27,-0x3f000000)
+VAL (28, 0xffff00)
+VAL (29,-0xffff00)
+VAL (30, 0x00ff00ff)
+VAL (31,-0x00ff00ff)
+
diff --git a/gcc/testsuite/gcc.target/avr/torture/vals-llk.def b/gcc/testsuite/gcc.target/avr/torture/vals-llk.def
new file mode 100644
index 0000000000..726a7ebed3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/torture/vals-llk.def
@@ -0,0 +1,32 @@
+VAL (01, 0x0)
+VAL (02, 0x1)
+VAL (03, 0x3f)
+VAL (04, 0x80)
+VAL (05, -0x1)
+VAL (06, -0x3f)
+VAL (07, 0x4000000000000000)
+VAL (08,-0x4000000000000000)
+
+VAL (10,-0x7fffffffffffffff)
+VAL (11, 0x7fffffffffffffff)
+VAL (12, 0x7f80000000000000)
+VAL (13,-0x7f80000000000000)
+VAL (14, 0x7f80000000000001)
+VAL (15,-0x7f80000000000001)
+VAL (16, 0x7f7f7f7f7f7f7f7f)
+VAL (17,-0x7f7f7f7f7f7f7f7f)
+VAL (18, 0x7f80808080808000)
+VAL (19,-0x7f80808080808000)
+VAL (20, 0x3e80000000000000)
+VAL (21,-0x3e80000000000000)
+VAL (22, 0x3f80000000000000)
+VAL (23,-0x3f80000000000000)
+VAL (24, 0x40000000000000)
+VAL (25,-0x40000000000000)
+VAL (26, 0x3f000000000000)
+VAL (27,-0x3f000000000000)
+VAL (28, 0xffffff00)
+VAL (29,-0xffffff00)
+VAL (30, 0x00ff00ff00ff00ff)
+VAL (31,-0x00ff00ff00ff00ff)
+
diff --git a/gcc/testsuite/gcc.target/avr/torture/vals-r.def b/gcc/testsuite/gcc.target/avr/torture/vals-r.def
new file mode 100644
index 0000000000..0c5f83f7d0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/torture/vals-r.def
@@ -0,0 +1,30 @@
+VAL (01, 0x0)
+VAL (02, 0x1)
+VAL (03, 0x3f)
+VAL (04, 0x80)
+VAL (05, -0x1)
+VAL (06, -0x3f)
+VAL (07, 0x4000)
+VAL (08,-0x4000)
+
+VAL (10,-0x7fff)
+VAL (11, 0x7fff)
+VAL (12, 0x7f80)
+VAL (13,-0x7f80)
+VAL (14, 0x7f81)
+VAL (15,-0x7f81)
+VAL (16, 0x7f7f)
+VAL (17,-0x7f7f)
+VAL (18, 0x7f80)
+VAL (19,-0x7f80)
+VAL (20, 0x3e80)
+VAL (21,-0x3e80)
+VAL (22, 0x3f80)
+VAL (23,-0x3f80)
+VAL (24, 0x40)
+VAL (25,-0x40)
+VAL (26, 0x3f00)
+VAL (27,-0x3f00)
+VAL (30, 0x00ff)
+VAL (31,-0x00ff)
+
diff --git a/gcc/testsuite/gcc.target/avr/torture/vals-uhr.def b/gcc/testsuite/gcc.target/avr/torture/vals-uhr.def
new file mode 100644
index 0000000000..71441567ca
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/torture/vals-uhr.def
@@ -0,0 +1,13 @@
+VAL (01, 0x0)
+VAL (02, 0x1)
+VAL (03, 0x3f)
+VAL (07, 0x40)
+VAL (08, 0xc0)
+VAL (10, 0xc1)
+VAL (12, 0xff)
+VAL (14, 0x7f)
+VAL (16, 0x81)
+VAL (20, 0xbf)
+
+VAL (99, 0x80)
+
diff --git a/gcc/testsuite/gcc.target/avr/torture/vals-uk.def b/gcc/testsuite/gcc.target/avr/torture/vals-uk.def
new file mode 100644
index 0000000000..3e212836f4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/torture/vals-uk.def
@@ -0,0 +1,23 @@
+VAL (01, 0x0)
+VAL (02, 0x1)
+VAL (03, 0x3f)
+VAL (04, 0x80)
+VAL (07, 0x40000000)
+VAL (08, 0xc0000000)
+VAL (10, 0x7fffffff)
+VAL (12, 0x7f800000)
+VAL (14, 0x7f800001)
+VAL (16, 0x7f7f7f7f)
+VAL (18, 0x7f808000)
+VAL (20, 0x3e800000)
+VAL (22, 0x3f800000)
+VAL (24, 0x40000000)
+VAL (26, 0x3f000000)
+VAL (28, 0xffff00)
+VAL (30, 0x00ff00ff)
+VAL (31, 0xff00ff00)
+VAL (32, 0x10000000)
+VAL (33, 0xff000000)
+
+VAL (99, 0x80000000)
+
diff --git a/gcc/testsuite/gcc.target/avr/torture/vals-ullk.def b/gcc/testsuite/gcc.target/avr/torture/vals-ullk.def
new file mode 100644
index 0000000000..620182be64
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/torture/vals-ullk.def
@@ -0,0 +1,20 @@
+VAL (01, 0x0)
+VAL (02, 0x1)
+VAL (03, 0x3f)
+VAL (04, 0x80)
+VAL (07, 0x4000000000000000)
+VAL (08, 0x4000000000000000)
+VAL (10, 0x7fffffffffffffff)
+VAL (12, 0x7f80000000000000)
+VAL (14, 0x7f80000000000001)
+VAL (16, 0x7f7f7f7f7f7f7f7f)
+VAL (18, 0x7f80808080808000)
+VAL (20, 0x3e80000000000000)
+VAL (22, 0x3f80000000000000)
+VAL (24, 0x40000000000000)
+VAL (26, 0x3f000000000000)
+VAL (28, 0xffffff00)
+VAL (30, 0x00ff00ff00ff00ff)
+
+VAL (99, 0x8000000000000000)
+
diff --git a/gcc/testsuite/gcc.target/avr/torture/vals-ur.def b/gcc/testsuite/gcc.target/avr/torture/vals-ur.def
new file mode 100644
index 0000000000..d6ea8f1c50
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/torture/vals-ur.def
@@ -0,0 +1,17 @@
+VAL (01, 0x0)
+VAL (02, 0x1)
+VAL (03, 0x3f)
+VAL (04, 0x80)
+VAL (07, 0x4000)
+VAL (08, 0xc000)
+VAL (10, 0x7fff)
+VAL (12, 0x7f80)
+VAL (14, 0x7f81)
+VAL (16, 0x7f7f)
+VAL (20, 0x3e80)
+VAL (22, 0x3f80)
+VAL (26, 0x3f00)
+VAL (32, 0x100)
+
+VAL (99, 0x8000)
+