summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/s390
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.target/s390')
-rw-r--r--gcc/testsuite/gcc.target/s390/20020926-1.c14
-rw-r--r--gcc/testsuite/gcc.target/s390/20030123-1.c19
-rw-r--r--gcc/testsuite/gcc.target/s390/20030129-1.c37
-rw-r--r--gcc/testsuite/gcc.target/s390/20040305-1.c53
-rw-r--r--gcc/testsuite/gcc.target/s390/20041109-1.c21
-rw-r--r--gcc/testsuite/gcc.target/s390/20041216-1.c23
-rw-r--r--gcc/testsuite/gcc.target/s390/20050409-1.c18
-rw-r--r--gcc/testsuite/gcc.target/s390/20050524-1.c34
-rw-r--r--gcc/testsuite/gcc.target/s390/20050824-1.c34
-rw-r--r--gcc/testsuite/gcc.target/s390/20071212-1.c11
-rw-r--r--gcc/testsuite/gcc.target/s390/20090223-1.c60
-rw-r--r--gcc/testsuite/gcc.target/s390/frame-addr1.c53
-rw-r--r--gcc/testsuite/gcc.target/s390/frame-addr2.c50
-rw-r--r--gcc/testsuite/gcc.target/s390/pr20927.c23
-rw-r--r--gcc/testsuite/gcc.target/s390/pr24624.c67
-rw-r--r--gcc/testsuite/gcc.target/s390/pr27661.c25
-rw-r--r--gcc/testsuite/gcc.target/s390/pr36822.c16
-rw-r--r--gcc/testsuite/gcc.target/s390/pr42224.c36
-rw-r--r--gcc/testsuite/gcc.target/s390/return-addr1.c46
-rw-r--r--gcc/testsuite/gcc.target/s390/return-addr2.c45
-rw-r--r--gcc/testsuite/gcc.target/s390/s390.exp41
-rw-r--r--gcc/testsuite/gcc.target/s390/stackcheck1.c14
-rw-r--r--gcc/testsuite/gcc.target/s390/tf_to_di-1.c46
23 files changed, 786 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/s390/20020926-1.c b/gcc/testsuite/gcc.target/s390/20020926-1.c
new file mode 100644
index 000000000..aaa134276
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/20020926-1.c
@@ -0,0 +1,14 @@
+/* Make sure that LEGITIMIZE_ADDRESS is called to handle
+ negative displacements. */
+
+/* { dg-do compile { target { s390-*-* } } } */
+/* { dg-options "-O2 -mesa" } */
+
+int test (int *addr)
+{
+ return *(addr - 1);
+}
+
+/* { dg-final { scan-assembler "-4096" } } */
+/* { dg-final { scan-assembler-not "ahi" } } */
+
diff --git a/gcc/testsuite/gcc.target/s390/20030123-1.c b/gcc/testsuite/gcc.target/s390/20030123-1.c
new file mode 100644
index 000000000..96ac6f76c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/20030123-1.c
@@ -0,0 +1,19 @@
+/* This used to ICE due to a reload bug on s390*. */
+
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-omit-frame-pointer" } */
+
+extern void *alloca (__SIZE_TYPE__);
+
+void func (char *p);
+
+void test (void)
+{
+ char *p = alloca (4096);
+ long idx;
+
+ asm ("" : "=r" (idx) : : "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "12");
+
+ func (p + idx + 1);
+}
+
diff --git a/gcc/testsuite/gcc.target/s390/20030129-1.c b/gcc/testsuite/gcc.target/s390/20030129-1.c
new file mode 100644
index 000000000..1cbd8b482
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/20030129-1.c
@@ -0,0 +1,37 @@
+/* This used to ICE due to a reload bug on s390*. */
+
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+int f (unsigned int);
+void g (void *);
+
+void test (void *p, void *dummy)
+{
+ unsigned int flags = 0;
+
+ if (dummy)
+ g (dummy);
+
+ if (p)
+ flags |= 0x80000000;
+
+ asm volatile ("" : : : "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12");
+
+ if (dummy)
+ g (dummy);
+
+ if (p)
+ {
+ flags |= 0x20000000|0x80000000;
+
+ if (!f (0))
+ flags &= ~0x80000000;
+ }
+
+ f (flags);
+
+ if (dummy)
+ g (dummy);
+}
+
diff --git a/gcc/testsuite/gcc.target/s390/20040305-1.c b/gcc/testsuite/gcc.target/s390/20040305-1.c
new file mode 100644
index 000000000..a241f041c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/20040305-1.c
@@ -0,0 +1,53 @@
+
+/* The testcase failed due to corrupted alias information.
+ During the crossjump analyzing step the mem alias info of the
+ st instructions are merged and get copied during basic block
+ reordering which leads to an insn with wrong alias info.
+ The scheduler afterwards exchanges the mvc and st instructions
+ not recognizing the anti dependence. */
+/* { dg-do run } */
+/* { dg-options "-O3 -mtune=z990 -fno-inline" } */
+
+extern void exit (int);
+extern void abort (void);
+
+int f;
+int g;
+int h;
+
+int* x = &f;
+int* p1 = &g;
+int* p2 = &h;
+
+int
+foo(void)
+{
+
+ if (*x == 0)
+ {
+ x = p1; /* mvc - memory to memory */
+ p1 = (int*)0; /* st - register to memory */
+ return 1;
+ }
+ if (*x == 5)
+ {
+ f = 1;
+ g = 2;
+
+ p2 = (int*)0; /* st */
+ return 1;
+ }
+}
+
+int
+main (int argc, char** argv)
+{
+ foo ();
+
+ /* If the scheduler has exchanged the mvc and st instructions,
+ x is 0. The expected result is &g. */
+ if (x == &g)
+ exit (0);
+ else
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/s390/20041109-1.c b/gcc/testsuite/gcc.target/s390/20041109-1.c
new file mode 100644
index 000000000..bf768439c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/20041109-1.c
@@ -0,0 +1,21 @@
+/* This used to ICE due to a literal pool handling bug on s390x. */
+
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-omit-frame-pointer" } */
+
+static struct table { int x; } table[3];
+
+int test (void)
+{
+ struct table *t;
+
+ for (t = table; t < &table[3]; t++)
+ asm volatile ("" : : : "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "12");
+
+ for (t = table; t < &table[3]; t++)
+ if (t->x)
+ return 1;
+
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.target/s390/20041216-1.c b/gcc/testsuite/gcc.target/s390/20041216-1.c
new file mode 100644
index 000000000..492ee6c18
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/20041216-1.c
@@ -0,0 +1,23 @@
+/* This test case would get an unresolved symbol during link
+ because stabs referred to an optimized-away literal pool
+ entry. */
+
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-omit-frame-pointer -gstabs" } */
+
+int main (void)
+{
+ static char buf[4096];
+ char *p;
+
+ do
+ {
+ p = buf;
+ asm volatile ("" : : : "memory", "0", "1", "2", "3", "4", "5", "6",
+ "7", "8", "9", "10", "12");
+ }
+ while (*p);
+
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.target/s390/20050409-1.c b/gcc/testsuite/gcc.target/s390/20050409-1.c
new file mode 100644
index 000000000..4763afad3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/20050409-1.c
@@ -0,0 +1,18 @@
+/* This used to ICE due to a regmove problem on s390. */
+
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+
+extern void abort (void);
+extern void **alloc (void);
+
+void *test (void)
+{
+ void **p = alloc ();
+ if (!p) abort ();
+
+ __builtin_set_thread_pointer (p);
+ return *p;
+}
+
diff --git a/gcc/testsuite/gcc.target/s390/20050524-1.c b/gcc/testsuite/gcc.target/s390/20050524-1.c
new file mode 100644
index 000000000..7b94fd0f0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/20050524-1.c
@@ -0,0 +1,34 @@
+/* This test case used to abort due to a reload bug with
+ elimination offsets. */
+
+/* { dg-do run } */
+/* { dg-options "-O2 -mpacked-stack" } */
+
+extern void abort (void);
+
+double bar (double) __attribute__ ((noinline));
+double bar (double x) { return x; }
+
+double
+foo (int j, double f0, double f2, double f4, double f6, double x) __attribute__ ((noinline));
+
+double
+foo (int j, double f0, double f2, double f4, double f6, double x)
+{
+ if (j)
+ return bar (x) + 4.0;
+ else
+ return bar (x);
+}
+
+int
+main (void)
+{
+ if (foo (0, 0, 0, 0, 0, 10) != 10)
+ abort ();
+ if (foo (1, 0, 0, 0, 0, 10) != 14)
+ abort ();
+
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.target/s390/20050824-1.c b/gcc/testsuite/gcc.target/s390/20050824-1.c
new file mode 100644
index 000000000..c24e1e26f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/20050824-1.c
@@ -0,0 +1,34 @@
+/* Make sure that the S/390 specific shift_count_operand
+ predicate work properly. */
+
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+
+unsigned long long
+f (unsigned long long a, unsigned long b)
+{
+ asm ("" : : :
+#ifdef __s390x__
+ "r13", "r14",
+#endif
+ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
+ "r8", "r9", "r10", "r11", "r12");
+
+ return a << ((b + 3) & 63);
+}
+
+unsigned long long
+g (unsigned long long a, char **b , int c, int d, int e, int f)
+{
+ char buffer [4096];
+
+ *b = &buffer[0];
+
+ return a << ((unsigned long)&f & 63);
+}
+
+unsigned long long
+h (unsigned long long a, int b, int c, int d, int e, int f)
+{
+ return a << (((unsigned long)&f + 3));
+}
diff --git a/gcc/testsuite/gcc.target/s390/20071212-1.c b/gcc/testsuite/gcc.target/s390/20071212-1.c
new file mode 100644
index 000000000..e5d05ad41
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/20071212-1.c
@@ -0,0 +1,11 @@
+/* This used to fail due to bug in the On constraint causing a slgfi
+ to be emitted with an immediate not fitting into 32bit. */
+
+/* { dg-do compile } */
+/* { dg-options "-O3 -march=z9-109" } */
+
+long
+foo (long a)
+{
+ return a - (1ULL << 32);
+}
diff --git a/gcc/testsuite/gcc.target/s390/20090223-1.c b/gcc/testsuite/gcc.target/s390/20090223-1.c
new file mode 100644
index 000000000..443ccb9aa
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/20090223-1.c
@@ -0,0 +1,60 @@
+/* The RTL loop optimizer used to replace the output register of the
+ inline assembly with a pseudo although the variable is declared as
+ register asm ("0"). */
+
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+extern void abort (void);
+
+static unsigned char __attribute__ ((always_inline))
+mytoupper (unsigned char c)
+{
+ if (c >= 'a' && c <= 'z')
+ c -= 'a' - 'A';
+ return c;
+}
+
+static unsigned long __attribute__ ((always_inline))
+strlen (const char *s)
+{
+ register unsigned long r0 asm ("0");
+ const char *tmp = s;
+
+ asm (
+#ifdef __s390x__
+ " lghi %0, 0\n"
+#else
+ " lhi %0, 0\n"
+#endif
+ "0:srst %0,%1\n"
+ " jo 0b"
+ : "=d" (r0), "+a" (tmp)
+ :
+ :"cc");
+ return r0 - (unsigned long) s;
+}
+
+char boot_command_line[] = "this is a test";
+
+void __attribute__ ((noinline))
+foo (char *str)
+{
+ if (strcmp (str, "THIS IS A TEST") != 0)
+ abort ();
+}
+
+int
+main ()
+{
+ char upper_command_line[1024];
+ int i;
+
+ for (i = 0; i < strlen (boot_command_line); i++)
+ upper_command_line[i] = mytoupper (boot_command_line[i]);
+
+ upper_command_line[strlen (boot_command_line)] = 0;
+ foo (upper_command_line);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/s390/frame-addr1.c b/gcc/testsuite/gcc.target/s390/frame-addr1.c
new file mode 100644
index 000000000..fda419ff0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/frame-addr1.c
@@ -0,0 +1,53 @@
+/* builtin_frame_address(n) with n>0 has always been troublesome ...
+ especially when the S/390 packed stack layout comes into play. */
+
+/* { dg-do run } */
+/* { dg-options "-O3 -fno-optimize-sibling-calls -mbackchain -mpacked-stack -msoft-float" } */
+
+#ifdef __s390x__
+/* 64bit: 3 words to be saved: backchain, r14 and r15 */
+#define SAVE_AREA_SIZE 3*8
+#else
+/* 32bit: 4 words to be saved: backchain, r13, r14 and r15 */
+#define SAVE_AREA_SIZE 4*4
+#endif
+extern void abort(void);
+
+#define EXPAND_CHECK(n) \
+ void __attribute__((noinline)) \
+ foo1_##n (void *p) \
+ { \
+ if (p - __builtin_frame_address (n) != SAVE_AREA_SIZE) \
+ abort (); \
+ } \
+ void __attribute__((noinline)) \
+ foo2_##n (void *p) \
+ { \
+ if (p - __builtin_frame_address (n) != SAVE_AREA_SIZE) \
+ abort (); \
+ foo1_##n (__builtin_frame_address (n)); \
+ } \
+ void __attribute__((noinline)) \
+ foo3_##n () \
+ { \
+ foo2_##n (__builtin_frame_address (n)); \
+ } \
+ void __attribute__((noinline)) \
+ foo4_##n () \
+ { \
+ foo3_##n (); \
+ }
+
+EXPAND_CHECK (0)
+EXPAND_CHECK (1)
+EXPAND_CHECK (2)
+
+int
+main ()
+{
+ foo4_0 ();
+ foo4_1 ();
+ foo4_2 ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/s390/frame-addr2.c b/gcc/testsuite/gcc.target/s390/frame-addr2.c
new file mode 100644
index 000000000..f6f9687a0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/frame-addr2.c
@@ -0,0 +1,50 @@
+/* builtin_frame_address(n) with n>0 has always been troublesome. */
+
+/* { dg-do run } */
+/* { dg-options "-O3 -fno-optimize-sibling-calls -mbackchain" } */
+
+#ifdef __s390x__
+#define SAVE_AREA_SIZE 160
+#else
+#define SAVE_AREA_SIZE 96
+#endif
+extern void abort(void);
+
+#define EXPAND_CHECK(n) \
+ void __attribute__((noinline)) \
+ foo1_##n (void *p) \
+ { \
+ if (p - __builtin_frame_address (n) != SAVE_AREA_SIZE) \
+ abort (); \
+ } \
+ void __attribute__((noinline)) \
+ foo2_##n (void *p) \
+ { \
+ if (p - __builtin_frame_address (n) != SAVE_AREA_SIZE) \
+ abort (); \
+ foo1_##n (__builtin_frame_address (n)); \
+ } \
+ void __attribute__((noinline)) \
+ foo3_##n () \
+ { \
+ foo2_##n (__builtin_frame_address (n)); \
+ } \
+ void __attribute__((noinline)) \
+ foo4_##n () \
+ { \
+ foo3_##n (); \
+ }
+
+EXPAND_CHECK (0)
+EXPAND_CHECK (1)
+EXPAND_CHECK (2)
+
+int
+main ()
+{
+ foo4_0 ();
+ foo4_1 ();
+ foo4_2 ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/s390/pr20927.c b/gcc/testsuite/gcc.target/s390/pr20927.c
new file mode 100644
index 000000000..dbc990f15
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/pr20927.c
@@ -0,0 +1,23 @@
+/* This caused an ICE on s390x due to a reload inheritance bug. */
+
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+struct point { double x, y; };
+extern void use (struct point);
+
+void test (struct point *pc, struct point p1)
+{
+ struct point p0 = *pc;
+
+ if (p0.x == p1.x && p0.y == p1.y)
+ use (p0);
+
+ asm ("" : : : "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10");
+
+ p1.y -= p0.y;
+
+ use (p0);
+ use (p1);
+}
+
diff --git a/gcc/testsuite/gcc.target/s390/pr24624.c b/gcc/testsuite/gcc.target/s390/pr24624.c
new file mode 100644
index 000000000..bc2070c4b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/pr24624.c
@@ -0,0 +1,67 @@
+/* This used to ICE due to a backend problem on s390. */
+
+/* { dg-do compile } */
+/* { dg-options "-O1 -mpacked-stack" } */
+
+typedef unsigned int __u32;
+typedef struct
+{
+ volatile int counter;
+} __attribute__ ((aligned (4))) atomic_t;
+static __inline__ __attribute__ ((always_inline))
+ void atomic_inc (volatile atomic_t * v)
+{
+ (
+ {
+ typeof (v->counter) old_val, new_val;
+ __asm__ __volatile__ (
+ " l %0,0(%3)\n"
+ "0: lr %1,%0\n"
+ " ar %1,%4\n"
+ " cs %0,%1,0(%3)\n"
+ " jl 0b":
+ "=&d" (old_val), "=&d" (new_val), "=m" (((atomic_t *) (v))->counter):
+ "a" (v), "d" (1), "m" (((atomic_t *) (v))->counter):
+ "cc", "memory");
+ });
+}
+extern unsigned long volatile __attribute__ ((section (".data"))) jiffies;
+struct inet_peer
+{
+ unsigned long dtime;
+ atomic_t refcnt;
+};
+static volatile int peer_total;
+int inet_peer_threshold = 65536 + 128;
+int inet_peer_minttl = 120 * 100;
+int inet_peer_maxttl = 10 * 60 * 100;
+static int
+cleanup_once (unsigned long ttl)
+{
+ struct inet_peer *p;
+ if (p != ((void *) 0))
+ {
+ if (((
+ {
+ 1;}
+ ) && ((long) (jiffies) - (long) (p->dtime + ttl) < 0)))
+ {
+ return -1;
+ }
+ atomic_inc (&p->refcnt);
+ }
+}
+struct inet_peer *
+inet_getpeer (__u32 daddr, int create)
+{
+ int i;
+ int ttl;
+ if (peer_total >= inet_peer_threshold)
+ ttl = inet_peer_minttl;
+ else
+ ttl =
+ inet_peer_maxttl - (inet_peer_maxttl -
+ inet_peer_minttl) / 100 * peer_total /
+ inet_peer_threshold * 100;
+ for (i = 0; i < 30 && !cleanup_once (ttl); i++);
+}
diff --git a/gcc/testsuite/gcc.target/s390/pr27661.c b/gcc/testsuite/gcc.target/s390/pr27661.c
new file mode 100644
index 000000000..1ff6dcc7c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/pr27661.c
@@ -0,0 +1,25 @@
+/* This used to ICE on s390 due to a reload bug. */
+
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=z990 -ftracer" } */
+
+extern int memcmp (const void *s1, const void *s2, unsigned long n);
+extern int printf (__const char *__restrict __format, ...);
+
+struct test
+{
+ char tmp[4096];
+ char msgtype[2];
+};
+
+void test (struct test *testtb)
+{
+ if (testtb)
+ printf ("a");
+
+ if (memcmp(testtb->msgtype, "a", 2))
+ printf ("a");
+
+ printf ("b");
+}
+
diff --git a/gcc/testsuite/gcc.target/s390/pr36822.c b/gcc/testsuite/gcc.target/s390/pr36822.c
new file mode 100644
index 000000000..fb021f214
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/pr36822.c
@@ -0,0 +1,16 @@
+/* This used to ICE on s390 due to bug in the definition of the 'R'
+ constraint which replaced the 'm' constraint (together with 'T')
+ while adding z10 support. */
+
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+
+int boo()
+{
+ struct {
+ unsigned char pad[4096];
+ unsigned long bar;
+ } *foo;
+ asm volatile( "" : "=m" (*(unsigned long long*)(foo->bar))
+ : "a" (&foo->bar));
+}
diff --git a/gcc/testsuite/gcc.target/s390/pr42224.c b/gcc/testsuite/gcc.target/s390/pr42224.c
new file mode 100644
index 000000000..c1ccf28d5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/pr42224.c
@@ -0,0 +1,36 @@
+
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+
+typedef char* __char_ptr32 __attribute__ (( mode (SI) ));
+typedef __char_ptr32 *__char_ptr_char_ptr32 __attribute__ ((mode (SI)));
+
+void to_ptr32 (int x)
+{
+ __char_ptr32 ptr = (__char_ptr32) x;
+}
+
+void to_int (__char_ptr32 ptr)
+{
+ int x = (int) ptr;
+}
+
+__char_ptr_char_ptr32
+to_ptr32_ptr32 (char **ptr64)
+{
+ int argc;
+ __char_ptr_char_ptr32 short_argv;
+
+ for (argc=0; ptr64[argc]; argc++);
+
+ short_argv = (__char_ptr_char_ptr32) malloc32
+ (sizeof (__char_ptr32) * (argc + 1));
+
+ for (argc=0; ptr64[argc]; argc++)
+ short_argv[argc] = (__char_ptr32) strdup32 (ptr64[argc]);
+
+ short_argv[argc] = (__char_ptr32) 0;
+ return short_argv;
+
+}
+
diff --git a/gcc/testsuite/gcc.target/s390/return-addr1.c b/gcc/testsuite/gcc.target/s390/return-addr1.c
new file mode 100644
index 000000000..8872b89b7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/return-addr1.c
@@ -0,0 +1,46 @@
+/* builtin_return_address(n) with n>0 has always been troublesome ...
+ especially when the S/390 packed stack layout comes into play. */
+
+/* { dg-do run } */
+/* { dg-options "-O3 -fno-optimize-sibling-calls -mbackchain -mpacked-stack -msoft-float" } */
+
+void *addr1;
+
+extern void abort (void);
+
+void * __attribute__((noinline))
+foo1 ()
+{
+ addr1 = __builtin_return_address (2);
+}
+
+void * __attribute__((noinline))
+foo2 ()
+{
+ foo1 ();
+}
+
+void * __attribute__((noinline))
+foo3 ()
+{
+ foo2 ();
+}
+
+void __attribute__((noinline))
+bar ()
+{
+ void *addr2;
+
+ foo3 ();
+ asm volatile ("basr %0,0\n\t" : "=d" (addr2));
+ /* basr is two bytes in length. */
+ if (addr2 - addr1 != 2)
+ abort ();
+}
+
+int
+main ()
+{
+ bar();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/s390/return-addr2.c b/gcc/testsuite/gcc.target/s390/return-addr2.c
new file mode 100644
index 000000000..c94d05284
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/return-addr2.c
@@ -0,0 +1,45 @@
+/* builtin_return_address(n) with n>0 has always been troublesome. */
+
+/* { dg-do run } */
+/* { dg-options "-O3 -fno-optimize-sibling-calls -mbackchain" } */
+
+void *addr1;
+
+extern void abort (void);
+
+void * __attribute__((noinline))
+foo1 ()
+{
+ addr1 = __builtin_return_address (2);
+}
+
+void * __attribute__((noinline))
+foo2 ()
+{
+ foo1 ();
+}
+
+void * __attribute__((noinline))
+foo3 ()
+{
+ foo2 ();
+}
+
+void __attribute__((noinline))
+bar ()
+{
+ void *addr2;
+
+ foo3 ();
+ asm volatile ("basr %0,0\n\t" : "=d" (addr2));
+ /* basr is two bytes in length. */
+ if (addr2 - addr1 != 2)
+ abort ();
+}
+
+int
+main ()
+{
+ bar();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/s390/s390.exp b/gcc/testsuite/gcc.target/s390/s390.exp
new file mode 100644
index 000000000..d69330986
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/s390.exp
@@ -0,0 +1,41 @@
+# Copyright (C) 2007 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 a s390 target.
+if ![istarget s390*-*-*] 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/*.\[cS\]]] \
+ "" $DEFAULT_CFLAGS
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/gcc.target/s390/stackcheck1.c b/gcc/testsuite/gcc.target/s390/stackcheck1.c
new file mode 100644
index 000000000..ab46a92d7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/stackcheck1.c
@@ -0,0 +1,14 @@
+/* The automatically chosen stack guard value caused an ICE in that
+ case. */
+
+/* { dg-do compile } */
+/* { dg-options "-O2 -mstack-size=4096" } */
+
+extern void bar (char *);
+
+void
+foo ()
+{
+ char a[2500];
+ bar (a);
+} /* { dg-warning "more than half" } */
diff --git a/gcc/testsuite/gcc.target/s390/tf_to_di-1.c b/gcc/testsuite/gcc.target/s390/tf_to_di-1.c
new file mode 100644
index 000000000..d79e6f350
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/tf_to_di-1.c
@@ -0,0 +1,46 @@
+/* { dg-options "-O0 -mlong-double-128" } */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+void
+check_ll (long double ld, long long ll)
+{
+ if ((long long)ld != ll)
+ {
+ printf ("ld: %Lf expect: %lld result: %lld\n",
+ ld, ll, (long long)ld);
+ abort ();
+ }
+}
+
+void
+check_ull (long double ld, unsigned long long ull)
+{
+ if ((unsigned long long)ld != ull)
+ {
+ printf ("ld: %Lf expect: %llu result: %llu\n",
+ ld, ull, (unsigned long long)ld);
+ abort ();
+ }
+}
+
+int
+main ()
+{
+ const long long ll_max = (long long)((1ULL << 63) - 1);
+ const long long ll_min = -ll_max - 1;
+
+ check_ll (206.23253, 206LL);
+ check_ull (206.23253, 206ULL);
+ check_ll ((long double)ll_max, ll_max);
+ check_ull ((long double)ll_max, ll_max);
+ check_ll ((long double)ll_min, ll_min);
+ check_ll (0.0, 0);
+ check_ull (0.0, 0);
+ check_ll (-1.0, -1);
+ check_ll ((long double)0xffffffffffffffffULL, ll_max);
+ check_ull ((long double)0xffffffffffffffffULL, 0xffffffffffffffffULL);
+
+ return 0;
+}