aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/avr
diff options
context:
space:
mode:
authorBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
committerBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
commit1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch)
treec607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/gcc/testsuite/gcc.target/avr
parent283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff)
downloadtoolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.target/avr')
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/avr.exp41
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/exit-abort.h8
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/pr46779-1.c51
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/pr46779-2.c51
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/pr58545.c23
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/progmem-error-1.c5
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/progmem-error-1.cpp5
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/progmem-warning-1.c7
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/progmem.h25
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-1-0.c6
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-1-1.c6
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-1-g.c6
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-1-x.c6
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-1.h83
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-2-0.c6
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-2-1.c6
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-2-g.c6
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-2-x.c9
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-2.h106
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/avr-torture.exp64
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/builtin_insert_bits-1.c97
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/builtin_insert_bits-2.c94
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/builtins-1.c38
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/builtins-2.c46
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/builtins-3-absfx.c171
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/builtins-4-roundfx.c164
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/builtins-5-countlsfx.c82
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/builtins-error.c11
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/fix-types.h134
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/int24-mul.c86
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/pr39633.c25
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/pr41885.c123
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/pr51374-1.c15
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/pr51782-1.c51
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/pr57631.c17
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/progmem-1.c30
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/progmem-1.cpp2
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/sat-hr-plus-minus.c98
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/sat-k-plus-minus.c108
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/sat-llk-plus-minus.c108
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/sat-r-plus-minus.c107
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/sat-uhr-plus-minus.c73
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/sat-uk-plus-minus.c82
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/sat-ullk-plus-minus.c82
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/sat-ur-plus-minus.c82
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/trivial.c15
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/vals-hr.def12
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/vals-k.def32
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/vals-llk.def32
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/vals-r.def30
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/vals-uhr.def13
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/vals-uk.def23
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/vals-ullk.def20
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/torture/vals-ur.def17
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/avr/trivial.c15
55 files changed, 2655 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/avr.exp b/gcc-4.9/gcc/testsuite/gcc.target/avr/avr.exp
new file mode 100644
index 000000000..86a541a09
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/avr.exp
@@ -0,0 +1,41 @@
+# 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
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Exit immediately if this isn't an AVR target.
+if ![istarget avr-*-*] then {
+ return
+}
+
+# Load support procs.
+load_lib gcc-dg.exp
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_CFLAGS
+if ![info exists DEFAULT_CFLAGS] then {
+ set DEFAULT_CFLAGS " -ansi -pedantic-errors"
+}
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{\[cCS\],cpp}]] \
+ "" $DEFAULT_CFLAGS
+
+# All done.
+dg-finish
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/exit-abort.h b/gcc-4.9/gcc/testsuite/gcc.target/avr/exit-abort.h
new file mode 100644
index 000000000..cf7df203a
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/exit-abort.h
@@ -0,0 +1,8 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+ extern void exit (int);
+ extern void abort (void);
+#ifdef __cplusplus
+}
+#endif
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/pr46779-1.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/pr46779-1.c
new file mode 100644
index 000000000..24522f175
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/pr46779-1.c
@@ -0,0 +1,51 @@
+/* { dg-do run } */
+/* { dg-options "-Os -fsplit-wide-types" } */
+
+/* This testcase should uncover bugs like
+ PR46779
+ PR45291
+ PR41894
+
+ The inline asm just serves to direct y into the Y register.
+ Otherwise, it is hard to write a "stable" test case that
+ also fails with slight variations in source code, middle- resp.
+ backend.
+
+ The problem is that Y is also the frame-pointer, and
+ avr.c:avr_hard_regno_mode_ok disallows QI to get in Y-reg.
+ However, the y.a = 0 generates a
+ (set (subreg:QI (reg:HI pseudo)) ...)
+ where pseudo gets allocated to Y.
+
+ Reload fails to generate the right spill.
+*/
+
+#include <stdlib.h>
+
+struct S
+{
+ unsigned char a, b;
+} ab = {12, 34};
+
+void yoo (struct S y)
+{
+ __asm volatile ("ldi %B0, 56" : "+y" (y));
+ y.a = 0;
+ __asm volatile ("; y = %0" : "+y" (y));
+ ab = y;
+}
+
+int main ()
+{
+ yoo (ab);
+
+ if (ab.a != 0)
+ abort();
+
+ if (ab.b != 56)
+ abort();
+
+ exit (0);
+
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/pr46779-2.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/pr46779-2.c
new file mode 100644
index 000000000..682070b5e
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/pr46779-2.c
@@ -0,0 +1,51 @@
+/* { dg-do run } */
+/* { dg-options "-Os -fno-split-wide-types" } */
+
+/* This testcase should uncover bugs like
+ PR46779
+ PR45291
+ PR41894
+
+ The inline asm just serves to direct y into the Y register.
+ Otherwise, it is hard to write a "stable" test case that
+ also fails with slight variations in source code, middle- resp.
+ backend.
+
+ The problem is that Y is also the frame-pointer, and
+ avr.c:avr_hard_regno_mode_ok disallows QI to get in Y-reg.
+ However, the y.a = 0 generates a
+ (set (subreg:QI (reg:HI pseudo)) ...)
+ where pseudo gets allocated to Y.
+
+ Reload fails to generate the right spill.
+*/
+
+#include <stdlib.h>
+
+struct S
+{
+ unsigned char a, b;
+} ab = {12, 34};
+
+void yoo (struct S y)
+{
+ __asm volatile ("ldi %B0, 56" : "+y" (y));
+ y.a = 0;
+ __asm volatile ("; y = %0" : "+y" (y));
+ ab = y;
+}
+
+int main ()
+{
+ yoo (ab);
+
+ if (ab.a != 0)
+ abort();
+
+ if (ab.b != 56)
+ abort();
+
+ exit (0);
+
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/pr58545.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/pr58545.c
new file mode 100644
index 000000000..d1b8461f7
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/pr58545.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-Os -mmcu=atmega8" } */
+
+typedef unsigned char uint8_t;
+typedef unsigned int uint16_t;
+
+extern uint8_t f1 (const uint8_t*);
+extern void f2 (uint8_t*, uint8_t);
+
+void func (uint16_t parameter, uint8_t *addr, uint8_t data)
+{
+ uint8_t status;
+
+ status = f1 (addr + 8);
+
+ addr++;
+
+ if (*addr == parameter + 8)
+ *addr = parameter;
+
+ f2 (addr, data);
+ f2 (addr + 8, status + 1);
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/progmem-error-1.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/progmem-error-1.c
new file mode 100644
index 000000000..cf53cc8e9
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/progmem-error-1.c
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+
+#include "progmem.h"
+
+char str[] PROGMEM = "Hallo"; /* { dg-error "must be const" } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/progmem-error-1.cpp b/gcc-4.9/gcc/testsuite/gcc.target/avr/progmem-error-1.cpp
new file mode 100644
index 000000000..934b93c15
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/progmem-error-1.cpp
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+
+#include "progmem.h"
+
+char str[] PROGMEM = "Hallo"; /* { dg-error "must be const" "" { target avr-*-* } 1 } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/progmem-warning-1.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/progmem-warning-1.c
new file mode 100644
index 000000000..67af05fe5
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/progmem-warning-1.c
@@ -0,0 +1,7 @@
+/* PR target/34734 */
+/* { dg-do compile } */
+/* { dg-options "-Wuninitialized" } */
+
+#include "progmem.h"
+
+const char c PROGMEM; /* { dg-warning "uninitialized variable 'c' put into program memory area" } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/progmem.h b/gcc-4.9/gcc/testsuite/gcc.target/avr/progmem.h
new file mode 100644
index 000000000..17bb77153
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/progmem.h
@@ -0,0 +1,25 @@
+#define PROGMEM __attribute__((progmem))
+
+#define PSTR(s) \
+ (__extension__({ \
+ static const char __c[] PROGMEM = (s); \
+ &__c[0];}))
+
+#ifdef __AVR_HAVE_LPMX__
+#define pgm_read_char(addr) \
+ (__extension__({ \
+ unsigned int __addr16 = (unsigned int)(addr); \
+ char __result; \
+ __asm__ ("lpm %0, %a1" \
+ : "=r" (__result) : "z" (__addr16)); \
+ __result; }))
+#else
+#define pgm_read_char(addr) \
+ (__extension__({ \
+ unsigned int __addr16 = (unsigned int)(addr); \
+ char __result; \
+ __asm__ ("lpm" "\n\t" \
+ "mov %0, r0" \
+ : "=r" (__result) : "z" (__addr16)); \
+ __result; }))
+#endif
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-1-0.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-1-0.c
new file mode 100644
index 000000000..880654201
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-1-0.c
@@ -0,0 +1,6 @@
+/* { dg-options "-std=gnu99" } */
+/* { dg-do run } */
+
+#define __as __flash
+
+#include "addr-space-1.h"
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-1-1.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-1-1.c
new file mode 100644
index 000000000..137526527
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-1-1.c
@@ -0,0 +1,6 @@
+/* { dg-options "-std=gnu99 -Tavr51-flash1.x" } */
+/* { dg-do run } */
+
+#define __as __flash1
+
+#include "addr-space-1.h"
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-1-g.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-1-g.c
new file mode 100644
index 000000000..60feca145
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-1-g.c
@@ -0,0 +1,6 @@
+/* { dg-options "-std=gnu99" } */
+/* { dg-do run } */
+
+#define __as
+
+#include "addr-space-1.h"
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-1-x.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-1-x.c
new file mode 100644
index 000000000..0b3c43a4b
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-1-x.c
@@ -0,0 +1,6 @@
+/* { dg-options "-std=gnu99" } */
+/* { dg-do run } */
+
+#define __as __memx
+
+#include "addr-space-1.h"
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-1.h b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-1.h
new file mode 100644
index 000000000..322a5b8b3
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-1.h
@@ -0,0 +1,83 @@
+#include <stdlib.h>
+#include <string.h>
+
+typedef struct
+{
+ char i1;
+ short i2;
+ long i4;
+ long long i8;
+ char str[2][10];
+} a_t;
+
+const __as a_t A =
+ {
+ 12, 345, 678910, 1234567891011ll,
+ {
+ "xxx..xxx",
+ "yyy..yyy"
+ }
+ };
+
+const __as volatile a_t V =
+ {
+ 12+1, 345+1, 678910+1, 1234567891011ll+1,
+ {
+ "XXX..XXX",
+ "YYY..YYY"
+ }
+ };
+
+a_t A2;
+volatile a_t V2;
+
+int main (void)
+{
+ if (A.i1 != 12
+ || A.i1 != V.i1 -1)
+ abort();
+
+ if (A.i2 != 345
+ || A.i2 != V.i2 -1)
+ abort();
+
+ if (A.i4 != 678910
+ || A.i4 != V.i4 -1)
+ abort();
+
+ if (A.i8 != 1234567891011ll
+ || A.i8 != V.i8 -1)
+ abort();
+
+ A2 = A;
+ V2 = V;
+
+ if (A2.i1 != 12
+ || A2.i1 != V2.i1 -1)
+ abort();
+
+ if (A2.i2 != 345
+ || A2.i2 != V2.i2 -1)
+ abort();
+
+ if (A2.i4 != 678910
+ || A2.i4 != V2.i4 -1)
+ abort();
+
+ if (A2.i8 != 1234567891011ll
+ || A2.i8 != V2.i8 -1)
+ abort();
+
+ if (strcmp (A2.str[0], "xxx..xxx"))
+ abort();
+ if (strcmp (A2.str[1], "yyy..yyy"))
+ abort();
+
+ if (strcmp ((const char*) V2.str[0], "XXX..XXX"))
+ abort();
+ if (strcmp ((const char*) V2.str[1], "YYY..YYY"))
+ abort();
+
+ exit (0);
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-2-0.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-2-0.c
new file mode 100644
index 000000000..d5d4f92a9
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-2-0.c
@@ -0,0 +1,6 @@
+/* { dg-options "-std=gnu99" } */
+/* { dg-do run } */
+
+#define __as __flash
+
+#include "addr-space-2.h"
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-2-1.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-2-1.c
new file mode 100644
index 000000000..c8041f7d1
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-2-1.c
@@ -0,0 +1,6 @@
+/* { dg-options "-std=gnu99 -Tavr51-flash1.x" } */
+/* { dg-do run } */
+
+#define __as __flash1
+
+#include "addr-space-2.h"
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-2-g.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-2-g.c
new file mode 100644
index 000000000..ad0b2b841
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-2-g.c
@@ -0,0 +1,6 @@
+/* { dg-options "-std=gnu99" } */
+/* { dg-do run } */
+
+#define __as
+
+#include "addr-space-2.h"
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-2-x.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-2-x.c
new file mode 100644
index 000000000..846cca47d
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-2-x.c
@@ -0,0 +1,9 @@
+/* { dg-options "-std=gnu99 -Wa,--no-warn" } */
+/* { dg-do run } */
+
+/* --no-warn because: "assembling 24-bit address needs binutils extension"
+ see binutils PR13503. */
+
+#define __as __memx
+
+#include "addr-space-2.h"
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-2.h b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-2.h
new file mode 100644
index 000000000..c95a1631a
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/addr-space-2.h
@@ -0,0 +1,106 @@
+extern void exit (int);
+extern void abort (void);
+
+typedef struct T
+{
+ char val;
+ const __as struct T *l, *r;
+} tree;
+
+/*
+ abcd
+ / \
+ ab cd
+ / \ / \
+ a b c d
+*/
+
+const __as tree a = { 'a', 0, 0 };
+const __as tree b = { 'b', 0, 0 };
+const __as tree c = { 'c', 0, 0 };
+const __as tree d = { 'd', 0, 0 };
+
+const __as tree ab = { 'A', &a, &b };
+const __as tree cd = { 'C', &c, &d };
+
+const __as tree abcd = { '*', &ab, &cd };
+
+static void
+test1 (void)
+{
+ if (abcd.val != '*')
+ abort();
+
+ if (abcd.l->val != 'A')
+ abort();
+ if (abcd.r->val != 'C')
+ abort();
+
+ if (abcd.l->l->val != 'a')
+ abort();
+ if (abcd.l->r->val != 'b')
+ abort();
+ if (abcd.r->l->val != 'c')
+ abort();
+ if (abcd.r->r->val != 'd')
+ abort();
+}
+
+static void
+test2 (const __as tree *t)
+{
+ if (t->val != '*')
+ abort();
+
+ if (t->l->val != 'A')
+ abort();
+ if (t->r->val != 'C')
+ abort();
+
+ if (t->l->l->val != 'a')
+ abort();
+ if (t->l->r->val != 'b')
+ abort();
+ if (t->r->l->val != 'c')
+ abort();
+ if (t->r->r->val != 'd')
+ abort();
+}
+
+static void
+test3 (const __as tree *pt)
+{
+ tree t = *pt;
+
+ if (t.val != '*')
+ abort();
+
+ if (t.l->val != 'A')
+ abort();
+ if (t.r->val != 'C')
+ abort();
+
+ if (t.l->l->val != 'a')
+ abort();
+ if (t.l->r->val != 'b')
+ abort();
+ if (t.r->l->val != 'c')
+ abort();
+ if (t.r->r->val != 'd')
+ abort();
+}
+
+int main (void)
+{
+ const __as tree *t = &abcd;
+ test1();
+ test2 (&abcd);
+ test3 (&abcd);
+
+ __asm ("" : "+r" (t));
+ test2 (t);
+ test3 (t);
+
+ exit (0);
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/avr-torture.exp b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/avr-torture.exp
new file mode 100644
index 000000000..3e5fdfbd4
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/avr-torture.exp
@@ -0,0 +1,64 @@
+# 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
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# GCC testsuite that uses the `gcc-dg.exp' driver, looping over
+# optimization options.
+
+# Exit immediately if this isn't a AVR target.
+if { ![istarget avr-*-*] } then {
+ return
+}
+
+# Load support procs.
+load_lib gcc-dg.exp
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_CFLAGS
+if ![info exists DEFAULT_CFLAGS] then {
+ set DEFAULT_CFLAGS " -ansi -pedantic-errors"
+}
+
+# Initialize `dg'.
+dg-init
+
+ set AVR_TORTURE_OPTIONS [list \
+ { -O0 } \
+ { -O1 } \
+ { -O2 } \
+ { -Os -flto } \
+ { -O2 -mcall-prologues } \
+ { -O2 -fdata-sections } \
+ { -O2 -fmerge-all-constants } \
+ { -Os -fomit-frame-pointer } \
+ { -Os -fomit-frame-pointer -finline-functions } \
+ { -O3 -g } \
+ { -Os -mcall-prologues} ]
+
+
+#Initialize use of torture lists.
+torture-init
+
+set-torture-options $AVR_TORTURE_OPTIONS
+
+
+# Main loop.
+gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{\[cS\],cpp}]] $DEFAULT_CFLAGS
+
+# Finalize use of torture lists.
+torture-finish
+
+# All done.
+dg-finish
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/builtin_insert_bits-1.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/builtin_insert_bits-1.c
new file mode 100644
index 000000000..fe20c9163
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/builtin_insert_bits-1.c
@@ -0,0 +1,97 @@
+/* { dg-do run } */
+
+#include <stdlib.h>
+
+#define MASK_F(M) \
+ (0 \
+ | ((0xf == (0xf & ((M) >> (4*0)))) ? (1 << 0) : 0) \
+ | ((0xf == (0xf & ((M) >> (4*1)))) ? (1 << 1) : 0) \
+ | ((0xf == (0xf & ((M) >> (4*2)))) ? (1 << 2) : 0) \
+ | ((0xf == (0xf & ((M) >> (4*3)))) ? (1 << 3) : 0) \
+ | ((0xf == (0xf & ((M) >> (4*4)))) ? (1 << 4) : 0) \
+ | ((0xf == (0xf & ((M) >> (4*5)))) ? (1 << 5) : 0) \
+ | ((0xf == (0xf & ((M) >> (4*6)))) ? (1 << 6) : 0) \
+ | ((0xf == (0xf & ((M) >> (4*7)))) ? (1 << 7) : 0) \
+ | 0)
+
+#define MASK_0_7(M) \
+ (0 \
+ | ((8 > (0xf & ((M) >> (4*0)))) ? (1 << 0) : 0) \
+ | ((8 > (0xf & ((M) >> (4*1)))) ? (1 << 1) : 0) \
+ | ((8 > (0xf & ((M) >> (4*2)))) ? (1 << 2) : 0) \
+ | ((8 > (0xf & ((M) >> (4*3)))) ? (1 << 3) : 0) \
+ | ((8 > (0xf & ((M) >> (4*4)))) ? (1 << 4) : 0) \
+ | ((8 > (0xf & ((M) >> (4*5)))) ? (1 << 5) : 0) \
+ | ((8 > (0xf & ((M) >> (4*6)))) ? (1 << 6) : 0) \
+ | ((8 > (0xf & ((M) >> (4*7)))) ? (1 << 7) : 0) \
+ | 0)
+
+#define INSERT_BITS(M,B,V) \
+ (__extension__({ \
+ unsigned char _n, _r = 0; \
+ _n = 0xf & (M >> (4*0)); if (_n<8) _r |= (!!(B & (1 << _n))) << 0; \
+ _n = 0xf & (M >> (4*1)); if (_n<8) _r |= (!!(B & (1 << _n))) << 1; \
+ _n = 0xf & (M >> (4*2)); if (_n<8) _r |= (!!(B & (1 << _n))) << 2; \
+ _n = 0xf & (M >> (4*3)); if (_n<8) _r |= (!!(B & (1 << _n))) << 3; \
+ _n = 0xf & (M >> (4*4)); if (_n<8) _r |= (!!(B & (1 << _n))) << 4; \
+ _n = 0xf & (M >> (4*5)); if (_n<8) _r |= (!!(B & (1 << _n))) << 5; \
+ _n = 0xf & (M >> (4*6)); if (_n<8) _r |= (!!(B & (1 << _n))) << 6; \
+ _n = 0xf & (M >> (4*7)); if (_n<8) _r |= (!!(B & (1 << _n))) << 7; \
+ (unsigned char) ((V) & MASK_F(M)) | _r; \
+ }))
+
+#define MASK_USED(M) (MASK_F(M) | MASK_0_7(M))
+
+#define TEST2(M,B,V) \
+ do { \
+ __asm volatile (";" #M); \
+ r1 = MASK_USED (M) \
+ & __builtin_avr_insert_bits (M,B,V); \
+ r2 = INSERT_BITS (M,B,V); \
+ if (r1 != r2) \
+ abort (); \
+ } while(0)
+
+#define TEST1(M,X) \
+ do { \
+ TEST2 (M,X,0x00); TEST2 (M,0x00,X); \
+ TEST2 (M,X,0xff); TEST2 (M,0xff,X); \
+ TEST2 (M,X,0xaa); TEST2 (M,0xaa,X); \
+ TEST2 (M,X,0xcc); TEST2 (M,0xcc,X); \
+ TEST2 (M,X,0x96); TEST2 (M,0x96,X); \
+ } while(0)
+
+
+
+void test8 (void)
+{
+ unsigned char r1, r2;
+ unsigned char ib;
+
+ static const unsigned char V[] =
+ {
+ 0, 0xaa, 0xcc, 0xf0, 0xff, 0x5b, 0x4d
+ };
+
+ for (ib = 0; ib < sizeof (V) / sizeof (*V); ib++)
+ {
+ unsigned char b = V[ib];
+
+ TEST1 (0x76543210, b);
+ TEST1 (0x3210ffff, b);
+ TEST1 (0x67452301, b);
+ TEST1 (0xf0f1f2f3, b);
+ TEST1 (0xff10ff54, b);
+ TEST1 (0x01234567, b);
+ TEST1 (0xff765f32, b);
+ }
+}
+
+/****************************************************************/
+
+int main()
+{
+ test8();
+
+ exit(0);
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/builtin_insert_bits-2.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/builtin_insert_bits-2.c
new file mode 100644
index 000000000..06cafd6af
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/builtin_insert_bits-2.c
@@ -0,0 +1,94 @@
+/* { dg-do run } */
+
+#include <stdlib.h>
+
+#define MASK_F(M) \
+ (0 \
+ | ((0xf == (0xf & ((M) >> (4*0)))) ? (1 << 0) : 0) \
+ | ((0xf == (0xf & ((M) >> (4*1)))) ? (1 << 1) : 0) \
+ | ((0xf == (0xf & ((M) >> (4*2)))) ? (1 << 2) : 0) \
+ | ((0xf == (0xf & ((M) >> (4*3)))) ? (1 << 3) : 0) \
+ | ((0xf == (0xf & ((M) >> (4*4)))) ? (1 << 4) : 0) \
+ | ((0xf == (0xf & ((M) >> (4*5)))) ? (1 << 5) : 0) \
+ | ((0xf == (0xf & ((M) >> (4*6)))) ? (1 << 6) : 0) \
+ | ((0xf == (0xf & ((M) >> (4*7)))) ? (1 << 7) : 0) \
+ | 0)
+
+#define MASK_0_7(M) \
+ (0 \
+ | ((8 > (0xf & ((M) >> (4*0)))) ? (1 << 0) : 0) \
+ | ((8 > (0xf & ((M) >> (4*1)))) ? (1 << 1) : 0) \
+ | ((8 > (0xf & ((M) >> (4*2)))) ? (1 << 2) : 0) \
+ | ((8 > (0xf & ((M) >> (4*3)))) ? (1 << 3) : 0) \
+ | ((8 > (0xf & ((M) >> (4*4)))) ? (1 << 4) : 0) \
+ | ((8 > (0xf & ((M) >> (4*5)))) ? (1 << 5) : 0) \
+ | ((8 > (0xf & ((M) >> (4*6)))) ? (1 << 6) : 0) \
+ | ((8 > (0xf & ((M) >> (4*7)))) ? (1 << 7) : 0) \
+ | 0)
+
+#define INSERT_BITS(M,B,V) \
+ (__extension__({ \
+ unsigned char _n, _r = 0; \
+ _n = 0xf & (M >> (4*0)); if (_n<8) _r |= (!!(B & (1 << _n))) << 0; \
+ _n = 0xf & (M >> (4*1)); if (_n<8) _r |= (!!(B & (1 << _n))) << 1; \
+ _n = 0xf & (M >> (4*2)); if (_n<8) _r |= (!!(B & (1 << _n))) << 2; \
+ _n = 0xf & (M >> (4*3)); if (_n<8) _r |= (!!(B & (1 << _n))) << 3; \
+ _n = 0xf & (M >> (4*4)); if (_n<8) _r |= (!!(B & (1 << _n))) << 4; \
+ _n = 0xf & (M >> (4*5)); if (_n<8) _r |= (!!(B & (1 << _n))) << 5; \
+ _n = 0xf & (M >> (4*6)); if (_n<8) _r |= (!!(B & (1 << _n))) << 6; \
+ _n = 0xf & (M >> (4*7)); if (_n<8) _r |= (!!(B & (1 << _n))) << 7; \
+ (unsigned char) ((V) & MASK_F(M)) | _r; \
+ }))
+
+#define MASK_USED(M) (MASK_F(M) | MASK_0_7(M))
+
+#define TEST2(M,B,V) \
+ do { \
+ __asm volatile (";" #M); \
+ r1 = MASK_USED (M) \
+ & __builtin_avr_insert_bits (M,B,V); \
+ r2 = INSERT_BITS (M,B,V); \
+ if (r1 != r2) \
+ abort (); \
+ } while(0)
+
+void test8 (void)
+{
+ unsigned char r1, r2;
+ unsigned char ib, iv;
+
+ static const unsigned char V[] =
+ {
+ 0, 0xaa, 0xcc, 0xf0, 0xff, 0x5b, 0x4d
+ };
+
+ for (ib = 0; ib < sizeof (V) / sizeof (*V); ib++)
+ {
+ unsigned char b = V[ib];
+
+ for (iv = 0; iv < sizeof (V) / sizeof (*V); iv++)
+ {
+ unsigned char v = V[iv];
+
+ TEST2 (0x76543210, b, v);
+ TEST2 (0xffffffff, b, v);
+ TEST2 (0x3210ffff, b, v);
+ TEST2 (0x67452301, b, v);
+ TEST2 (0xf0f1f2f3, b, v);
+ TEST2 (0xff10ff54, b, v);
+ TEST2 (0x0765f321, b, v);
+ TEST2 (0x11223344, b, v);
+ TEST2 (0x01234567, b, v);
+ TEST2 (0xff7765f3, b, v);
+ }
+ }
+}
+
+/****************************************************************/
+
+int main()
+{
+ test8();
+
+ exit(0);
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/builtins-1.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/builtins-1.c
new file mode 100644
index 000000000..1fa3aaaae
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/builtins-1.c
@@ -0,0 +1,38 @@
+/* { dg-do compile } */
+
+void nop (void) { __builtin_avr_nop (); }
+void sei (void) { __builtin_avr_sei (); }
+void cli (void) { __builtin_avr_cli (); }
+void wdr (void) { __builtin_avr_wdr (); }
+void sleep (void) { __builtin_avr_sleep (); }
+
+char fmul (char a, char b) { return __builtin_avr_fmul (a, b); }
+char fmuls (char a, char b) { return __builtin_avr_fmuls (a, b); }
+char fmulsu (char a, char b) { return __builtin_avr_fmulsu (a, b); }
+
+char swap1 (char a)
+{
+ return __builtin_avr_swap (a+1);
+}
+
+char swap2 (char a)
+{
+ return __builtin_avr_swap (__builtin_avr_swap (a+1));
+}
+
+char swap15 (void)
+{
+ return __builtin_avr_swap (15);
+}
+
+void delay0 (void) { __builtin_avr_delay_cycles (0); }
+void delay1 (void) { __builtin_avr_delay_cycles (1); }
+void delay2 (void) { __builtin_avr_delay_cycles (2); }
+void delay3 (void) { __builtin_avr_delay_cycles (3); }
+
+void delay_1 (void) { __builtin_avr_delay_cycles (44); }
+void delay_2 (void) { __builtin_avr_delay_cycles (0x1234); }
+void delay_3 (void) { __builtin_avr_delay_cycles (0x123456); }
+void delay_4 (void) { __builtin_avr_delay_cycles (-1ul); }
+
+/* { dg-final { scan-assembler-not "__builtin_avr_" } } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/builtins-2.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/builtins-2.c
new file mode 100644
index 000000000..ae207d9a9
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/builtins-2.c
@@ -0,0 +1,46 @@
+/* { dg-options "-std=gnu99 -Tavr51-flash1.x" } */
+/* { dg-do run } */
+
+#include <stdlib.h>
+#include "../progmem.h"
+
+int volatile a;
+
+void f1 (void)
+{
+ __builtin_avr_sei ();
+ __builtin_avr_cli ();
+ __builtin_avr_wdr ();
+ __builtin_avr_sleep ();
+ __builtin_avr_nop ();
+ a = __builtin_avr_swap (a);
+ a = __builtin_avr_fmul (1,a);
+ a = __builtin_avr_fmuls (1,a);
+ a = __builtin_avr_fmulsu (1,a);
+ a = __builtin_avr_insert_bits (0x1f2f5364, a, a);
+}
+
+const __flash char c0 = 1;
+const __flash1 char c1 = 1;
+
+int main (void)
+{
+ const __memx void *p;
+
+ f1();
+ __builtin_avr_delay_cycles (1000);
+
+ p = &c0;
+ if (__builtin_avr_flash_segment (p) != 0)
+ abort();
+
+ p = &c1;
+ if (__builtin_avr_flash_segment (p) != 1)
+ abort();
+
+ if (__builtin_avr_flash_segment ("p") != -1)
+ abort();
+
+ exit (0);
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/builtins-3-absfx.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/builtins-3-absfx.c
new file mode 100644
index 000000000..a8bde2952
--- /dev/null
+++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.target/avr/torture/builtins-4-roundfx.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/builtins-4-roundfx.c
new file mode 100644
index 000000000..46e915a6c
--- /dev/null
+++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.target/avr/torture/builtins-5-countlsfx.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/builtins-5-countlsfx.c
new file mode 100644
index 000000000..b0ff5e3d4
--- /dev/null
+++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.target/avr/torture/builtins-error.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/builtins-error.c
new file mode 100644
index 000000000..692b8afd8
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/builtins-error.c
@@ -0,0 +1,11 @@
+/* { dg-do assemble } */
+
+char insert (long a)
+{
+ return __builtin_avr_insert_bits (15.3f+a, 0, 0); /* { dg-error "expects a compile time" } */
+}
+
+void delay (long a)
+{
+ __builtin_avr_delay_cycles (a); /* { dg-error "expects a compile time" } */
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/fix-types.h b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/fix-types.h
new file mode 100644
index 000000000..f6a2aeb6f
--- /dev/null
+++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.target/avr/torture/int24-mul.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/int24-mul.c
new file mode 100644
index 000000000..c85d93277
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/int24-mul.c
@@ -0,0 +1,86 @@
+/* { dg-do run } */
+/* { dg-options "-w" } */
+
+#include <stdlib.h>
+
+const __flash __int24 vals[] =
+ {
+ 0, 1, 2, 3, -1, -2, -3, 0xff, 0x100, 0x101,
+ 0xffL * 0xff, 0xfffL * 0xfff, 0x101010L, 0xaaaaaaL
+ };
+
+void test_u (void)
+{
+ unsigned int i;
+ unsigned long la, lb, lc;
+ __uint24 a, b, c;
+
+ int S = sizeof (vals) / sizeof (*vals);
+
+ for (i = 0; i < 500; i++)
+ {
+ if (i < S*S)
+ {
+ a = vals[i / S];
+ b = vals[i % S];
+ }
+ else
+ {
+ if (i & 1)
+ a += 0x7654321L;
+ else
+ b += 0x5fe453L;
+ }
+
+ c = a * b;
+
+ la = a;
+ lb = b;
+ lc = 0xffffff & (la * lb);
+
+ if (c != lc)
+ abort();
+ }
+}
+
+#define TEST_N_U(A1,A2,B) \
+ do { \
+ if ((0xffffff & (A1*B)) != A2*B) \
+ abort(); \
+ } while (0)
+
+void test_nu (void)
+{
+ unsigned long la;
+ unsigned int i;
+ int S = sizeof (vals) / sizeof (*vals);
+ __uint24 a;
+
+ for (i = 0; i < 500; i++)
+ {
+ a = i < S
+ ? vals[i % S]
+ : a + 0x7654321;
+
+ la = a;
+
+ TEST_N_U (la, a, 2);
+ TEST_N_U (la, a, 3);
+ TEST_N_U (la, a, 4);
+ TEST_N_U (la, a, 5);
+ TEST_N_U (la, a, 15);
+ TEST_N_U (la, a, 16);
+ TEST_N_U (la, a, 128);
+ TEST_N_U (la, a, 0x1000);
+ }
+}
+
+int main (void)
+{
+ test_u();
+ test_nu();
+
+ exit(0);
+
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/pr39633.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/pr39633.c
new file mode 100644
index 000000000..c5f5b0450
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/pr39633.c
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+
+#include <stdlib.h>
+
+char c = 42;
+
+void __attribute__((noinline,noclone))
+pr39633 (char a)
+{
+ a >>= 7;
+ if (a)
+ c = a;
+}
+
+int main()
+{
+ pr39633 (6);
+
+ if (c != 42)
+ abort();
+
+ exit(0);
+
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/pr41885.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/pr41885.c
new file mode 100644
index 000000000..f46bc5a75
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/pr41885.c
@@ -0,0 +1,123 @@
+/* { dg-options "-w -std=c99 -fno-inline" } */
+/* { dg-do run } */
+
+#include <limits.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+
+uint16_t rotl_16a (uint16_t x)
+{
+ return (x << 8) | (x >> 8);
+}
+uint16_t rotl_16b (short dummy, uint16_t x)
+{
+ return (x << 8) | (x >> 8);
+}
+
+uint32_t rotl_32a (uint32_t x)
+{
+ return (x << 8) | (x >> 24);
+}
+uint32_t rotl_32b (short dummy, uint32_t x)
+{
+ return (x << 8) | (x >> 24);
+}
+uint32_t rotl_32c (short dummy, uint32_t x)
+{
+ return (x << 16) | (x >> 16);
+}
+uint32_t rotl_32d (short dummy, uint32_t x)
+{
+ return (x << 24) | (x >> 8);
+}
+uint32_t rotl_32e (long dummy, uint32_t x)
+{
+ return (x << 24) | (x >> 8);
+}
+
+uint64_t rotl_64 (uint64_t x)
+{
+ return (x << 56) | (x >> 8);
+}
+
+uint64_t rotl_64a (short dummy, uint64_t x)
+{
+ return (x << 56) | (x >> 8);
+}
+uint64_t rotl_64b (short dummy, uint64_t x)
+{
+ return (x << 48) | (x >> 16);
+}
+uint64_t rotl_64c (short dummy, uint64_t x)
+{
+ return (x << 40) | (x >> 24);
+}
+uint64_t rotl_64d (short dummy, uint64_t x)
+{
+ return (x << 32) | (x >> 32);
+}
+uint64_t rotl_64e (short dummy, uint64_t x)
+{
+ return (x << 24) | (x >> 40);
+}
+uint64_t rotl_64f (short dummy, uint64_t x)
+{
+ return (x << 16) | (x >> 48);
+}
+uint64_t rotl_64g (short dummy, uint64_t x)
+{
+ return (x << 8) | (x >> 56);
+}
+uint64_t rotl_64h (long dummy, uint64_t x)
+{
+ return (x << 16) | (x >> 48);
+}
+
+
+
+
+int main (void)
+{
+ if (rotl_16a(0x1234) != 0x3412)
+ abort();
+ if (rotl_16b(0xAA55,0x1234) != 0x3412)
+ abort();
+
+uint32_t num32 = 0x12345678;
+
+ if (rotl_32a(num32) != 0x34567812)
+ abort();
+ if (rotl_32b(0xAA55,num32) != 0x34567812)
+ abort();
+ if (rotl_32c(0xAA55,num32) != 0x56781234)
+ abort();
+ if (rotl_32d(0xAA55,num32) != 0x78123456)
+ abort();
+ if (rotl_32e(0x1122AA55,num32) != 0x78123456)
+ abort();
+
+uint64_t num = 0x123456789ABCDEF0ULL;
+
+ if (rotl_64(num) != 0xF0123456789ABCDEULL)
+ abort();
+ if (rotl_64a(0xAA55,num) != 0xF0123456789ABCDEULL)
+ abort();
+ if (rotl_64b(0xAA55,num) != 0xDEF0123456789ABCULL)
+ abort();
+ if (rotl_64c(0xAA55,num) != 0xBCDEF0123456789AULL)
+ abort();
+ if (rotl_64d(0xAA55,num) != 0x9ABCDEF012345678ULL)
+ abort();
+ if (rotl_64e(0xAA55,num) != 0x789ABCDEF0123456ULL)
+ abort();
+ if (rotl_64f(0xAA55,num) != 0x56789ABCDEF01234ULL)
+ abort();
+ if (rotl_64g(0xAA55,num) != 0x3456789ABCDEF012ULL)
+ abort();
+ if (rotl_64h(0x1122AA55,num) != 0x56789ABCDEF01234ULL)
+ abort();
+
+ exit (0);
+}
+
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/pr51374-1.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/pr51374-1.c
new file mode 100644
index 000000000..9c98ea5f8
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/pr51374-1.c
@@ -0,0 +1,15 @@
+/* PR rtl-optimization/51374 */
+/* { dg-do compile } */
+
+void vector_18 (void)
+{
+ extern char slot;
+ unsigned char status = (*(volatile unsigned char*) 0x2B);
+ unsigned char data = (*(volatile unsigned char*) 0x2C);
+
+ if (status & 0x10)
+ slot = 0;
+}
+
+/* { dg-final { scan-assembler-not "\tsbic " } } */
+/* { dg-final { scan-assembler-not "\tsbis " } } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/pr51782-1.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/pr51782-1.c
new file mode 100644
index 000000000..ff0f9d45f
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/pr51782-1.c
@@ -0,0 +1,51 @@
+/* PR middle-end/51782 */
+/* { dg-do run } */
+/* { dg-options { "-std=gnu99" } } */
+
+#include <stdlib.h>
+
+struct R { char r; };
+struct RGB { char r,g,b; };
+
+__flash const struct R r1 = { 12 };
+__flash const struct RGB r3 = { 23, 56, 78 };
+
+char __attribute__((noinline,noclone))
+read1_bug (const __flash struct R *s)
+{
+ struct R t = *s;
+ return t.r;
+}
+
+char __attribute__((noinline,noclone))
+read1_ok (const __flash struct R *s)
+{
+ return s->r;
+}
+
+char __attribute__((noinline,noclone))
+read3_bug (const __flash struct RGB *s)
+{
+ struct RGB t = *s;
+ return t.r + t.g + t.b;
+}
+
+char __attribute__((noinline,noclone))
+read3_ok (const __flash struct RGB *s)
+{
+ return s->r + s->g + s->b;
+}
+
+__flash const struct R * volatile p1 = &r1;
+__flash const struct RGB * volatile p3 = &r3;
+
+int main (void)
+{
+ if (read1_bug (p1) != read1_ok (p1))
+ abort();
+
+ if (read3_bug (p3) != read3_ok (p3))
+ abort();
+
+ exit (0);
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/pr57631.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/pr57631.c
new file mode 100644
index 000000000..ecefbfc81
--- /dev/null
+++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.target/avr/torture/progmem-1.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/progmem-1.c
new file mode 100644
index 000000000..790c676c9
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/progmem-1.c
@@ -0,0 +1,30 @@
+/* { dg-do run } */
+
+#include "../exit-abort.h"
+#include "../progmem.h"
+
+const char strA[] PROGMEM = "@A";
+const char strc PROGMEM = 'c';
+
+unsigned int volatile s = 2;
+
+int main()
+{
+ char c;
+
+ c = pgm_read_char (&strA[s-1]);
+ if (c != 'A')
+ abort();
+
+ c = pgm_read_char (&PSTR ("@@B")[s]);
+ if (c != 'B')
+ abort();
+
+ c = pgm_read_char (&strc);
+ if (c != 'c')
+ abort();
+
+ exit (0);
+
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/progmem-1.cpp b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/progmem-1.cpp
new file mode 100644
index 000000000..a1df9e78e
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/progmem-1.cpp
@@ -0,0 +1,2 @@
+/* { dg-do run } */
+#include "progmem-1.c"
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/sat-hr-plus-minus.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/sat-hr-plus-minus.c
new file mode 100644
index 000000000..1e6215e4f
--- /dev/null
+++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.target/avr/torture/sat-k-plus-minus.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/sat-k-plus-minus.c
new file mode 100644
index 000000000..8a26ffeeb
--- /dev/null
+++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.target/avr/torture/sat-llk-plus-minus.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/sat-llk-plus-minus.c
new file mode 100644
index 000000000..e81cbb187
--- /dev/null
+++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.target/avr/torture/sat-r-plus-minus.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/sat-r-plus-minus.c
new file mode 100644
index 000000000..e59bcf655
--- /dev/null
+++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.target/avr/torture/sat-uhr-plus-minus.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/sat-uhr-plus-minus.c
new file mode 100644
index 000000000..6dd191f7a
--- /dev/null
+++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.target/avr/torture/sat-uk-plus-minus.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/sat-uk-plus-minus.c
new file mode 100644
index 000000000..c9a7cd6ba
--- /dev/null
+++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.target/avr/torture/sat-ullk-plus-minus.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/sat-ullk-plus-minus.c
new file mode 100644
index 000000000..22ebb8af5
--- /dev/null
+++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.target/avr/torture/sat-ur-plus-minus.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/sat-ur-plus-minus.c
new file mode 100644
index 000000000..bc3c0bbcd
--- /dev/null
+++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.target/avr/torture/trivial.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/trivial.c
new file mode 100644
index 000000000..f1beecb1e
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/trivial.c
@@ -0,0 +1,15 @@
+/* { dg-do run } */
+
+#include <stdio.h>
+
+#define PROGMEM __attribute__((__progmem__))
+
+const char PROGMEM a1 = 0x12;
+const int PROGMEM a2 = 0x2345;
+const long PROGMEM a3 = 0x12345678;
+
+int main(void)
+{
+ printf ("Hello World\n");
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/vals-hr.def b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/vals-hr.def
new file mode 100644
index 000000000..f6619c2ff
--- /dev/null
+++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.target/avr/torture/vals-k.def b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/vals-k.def
new file mode 100644
index 000000000..a490c69b3
--- /dev/null
+++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.target/avr/torture/vals-llk.def b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/vals-llk.def
new file mode 100644
index 000000000..726a7ebed
--- /dev/null
+++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.target/avr/torture/vals-r.def b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/vals-r.def
new file mode 100644
index 000000000..0c5f83f7d
--- /dev/null
+++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.target/avr/torture/vals-uhr.def b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/vals-uhr.def
new file mode 100644
index 000000000..71441567c
--- /dev/null
+++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.target/avr/torture/vals-uk.def b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/vals-uk.def
new file mode 100644
index 000000000..3e212836f
--- /dev/null
+++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.target/avr/torture/vals-ullk.def b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/vals-ullk.def
new file mode 100644
index 000000000..620182be6
--- /dev/null
+++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.target/avr/torture/vals-ur.def b/gcc-4.9/gcc/testsuite/gcc.target/avr/torture/vals-ur.def
new file mode 100644
index 000000000..d6ea8f1c5
--- /dev/null
+++ b/gcc-4.9/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)
+
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/avr/trivial.c b/gcc-4.9/gcc/testsuite/gcc.target/avr/trivial.c
new file mode 100644
index 000000000..f1beecb1e
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/avr/trivial.c
@@ -0,0 +1,15 @@
+/* { dg-do run } */
+
+#include <stdio.h>
+
+#define PROGMEM __attribute__((__progmem__))
+
+const char PROGMEM a1 = 0x12;
+const int PROGMEM a2 = 0x2345;
+const long PROGMEM a3 = 0x12345678;
+
+int main(void)
+{
+ printf ("Hello World\n");
+ return 0;
+}