diff options
author | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
---|---|---|
committer | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
commit | 1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch) | |
tree | c607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/gcc/testsuite/gcc.dg/torture | |
parent | 283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff) | |
download | toolchain_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.dg/torture')
652 files changed, 25633 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/20080716-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/20080716-1.c new file mode 100644 index 000000000..91fcd2b00 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/20080716-1.c @@ -0,0 +1,58 @@ +/* { dg-do run } */ +/* { dg-require-effective-target lp64 } */ + +typedef unsigned long size_t; +struct tree_base +{ + int code; +}; +struct tree_decl_minimal +{ + struct tree_base base; + const char *name; +}; +typedef union tree_node { + struct tree_base base; + struct tree_decl_minimal decl_minimal; +} *tree; +struct tree_overload +{ + struct tree_base common; + tree function; +}; +typedef struct VEC_tree_base { unsigned num; unsigned alloc; tree vec[1]; } VEC_tree_base; +typedef struct VEC_tree_gc { VEC_tree_base base; } VEC_tree_gc; +static __inline__ unsigned VEC_tree_base_length (const VEC_tree_base *vec_) +{ return vec_ ? vec_->num : 0; } +static __inline__ int VEC_tree_base_iterate (const VEC_tree_base *vec_, unsigned ix_, tree *ptr) +{ + if (vec_ && ix_ < vec_->num) { *ptr = vec_->vec[ix_]; return 1; } else { *ptr = 0; return 0; } +} +extern void abort (void); +void __attribute__((noinline)) foo (size_t x) +{ + if (x != 18446744073709551614UL) + abort (); +} +void +resort_type_method_vec (VEC_tree_gc *method_vec) +{ + int len = (VEC_tree_base_length(((method_vec) ? &(method_vec)->base : 0))); + size_t slot; + tree fn; + + for (slot = 2; + (VEC_tree_base_iterate(((method_vec) ? &(method_vec)->base : 0),slot,&(fn))); + ++slot) + if (!(((((((fn)->base.code) == 225) ? (((struct tree_overload*)(fn))->function) : (fn)))->decl_minimal.name))) + break; + + if (len - slot > 1) + foo (len - slot); +} + +int main () +{ + resort_type_method_vec ((void *)0); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/20090618-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/20090618-1.c new file mode 100644 index 000000000..8b601d62c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/20090618-1.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */ + +extern void abort (void); + +struct X { int *p; int *q; }; + +int foo(void) +{ + int i = 0, j = 1; + struct X x, y; + int **p; + y.p = &i; + x.q = &j; + p = __builtin_mempcpy (&x, &y, sizeof (int *)); + return **p; +} + +int main() +{ + if (foo() != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/20110713-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/20110713-1.c new file mode 100644 index 000000000..aa446af59 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/20110713-1.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target ilp32 } */ + +void * +test (unsigned long long x, unsigned long long y) +{ + return (void *) (unsigned int) (x / y); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/20110718-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/20110718-1.c new file mode 100644 index 000000000..ccabbd914 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/20110718-1.c @@ -0,0 +1,23 @@ +/* { dg-do run } */ + +extern void abort (void); +struct X { +#if (__SIZEOF_LONG__ != __SIZEOF_INT__) && (__SIZEOF_LONG__ == 8) + unsigned long i : 33; +#else + unsigned long i; +#endif +}; +unsigned long __attribute__((noinline)) +foo (struct X *p) +{ + return ~p->i; +} +int main() +{ + struct X x; + x.i = -1; + if (foo (&x) != 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/20110719-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/20110719-1.c new file mode 100644 index 000000000..7797e08ad --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/20110719-1.c @@ -0,0 +1,10 @@ +extern void abort (void); +int i; +int main() +{ + int b = i != 0; + int c = ~b; + if (c != -1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/20131115-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/20131115-1.c new file mode 100644 index 000000000..edb05f04c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/20131115-1.c @@ -0,0 +1,38 @@ +/* { dg-do run } */ + +struct S { int i; }; +__attribute__((const, noinline, noclone)) +struct S foo (int x) +{ + struct S s; + s.i = x; + return s; +} + +int a[2048], b[2048], c[2048], d[2048]; +struct S e[2048]; + +__attribute__((noinline, noclone)) void +bar (void) +{ + int i; + for (i = 0; i < 1024; i++) + { + e[i] = foo (i); + a[i+2] = a[i] + a[i+1]; + b[10] = b[10] + i; + c[i] = c[2047 - i]; + d[i] = d[i + 1]; + } +} + +int +main () +{ + int i; + bar (); + for (i = 0; i < 1024; i++) + if (e[i].i != i) + __builtin_abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/20131122-0.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/20131122-0.c new file mode 100644 index 000000000..42d92faed --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/20131122-0.c @@ -0,0 +1,34 @@ +/* { dg-do run } */ + +extern int memcmp (const void *, const void *, __SIZE_TYPE__); +extern void abort (void); + +void __attribute__ ((noinline)) +f (long *s, long *t, int len1, int len2) +{ + int i, j; + + j = 2; + for (i = len1 - 1; i >= 0; i--) + { + s[j--] = (i < len2 ? t[i] : t[len2 - 1] < 0 ? -1 : 0); + if (j < 0) + break; + } +} + +long s[3]; +long t[3]; + +int +main (void) +{ + t[0] = 1; + t[1] = 2; + t[2] = 3; + f (s, t, 3, 3); + if (memcmp (s, t, sizeof (s)) != 0) + abort (); + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/Wsizeof-pointer-memaccess1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/Wsizeof-pointer-memaccess1.c new file mode 100644 index 000000000..8d01bc616 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/Wsizeof-pointer-memaccess1.c @@ -0,0 +1,712 @@ +/* Test -Wsizeof-pointer-memaccess warnings. */ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ +/* Test just twice, once with -O0 non-fortified, once with -O2 fortified. */ +/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ + +typedef __SIZE_TYPE__ size_t; +extern void *memset (void *, int, size_t); +extern void *memcpy (void *__restrict, const void *__restrict, size_t); +extern void *memmove (void *__restrict, const void *__restrict, size_t); +extern int memcmp (const void *, const void *, size_t); +extern char *strncpy (char *__restrict, const char *__restrict, size_t); +extern char *strncat (char *__restrict, const char *__restrict, size_t); +extern char *stpncpy (char *__restrict, const char *__restrict, size_t); +extern char *strndup (const char *, size_t); +extern int strncmp (const char *, const char *, size_t); +extern int strncasecmp (const char *, const char *, size_t); + +#ifdef __OPTIMIZE__ +# define bos(ptr) __builtin_object_size (ptr, 1) +# define bos0(ptr) __builtin_object_size (ptr, 0) + +__attribute__((__always_inline__, __gnu_inline__, __artificial__)) +extern inline void * +memset (void *dest, int c, size_t len) +{ + return __builtin___memset_chk (dest, c, len, bos0 (dest)); +} + +__attribute__((__always_inline__, __gnu_inline__, __artificial__)) +extern inline void * +memcpy (void *__restrict dest, const void *__restrict src, size_t len) +{ + return __builtin___memcpy_chk (dest, src, len, bos0 (dest)); +} + +__attribute__((__always_inline__, __gnu_inline__, __artificial__)) +extern inline void * +memmove (void *dest, const void *src, size_t len) +{ + return __builtin___memmove_chk (dest, src, len, bos0 (dest)); +} + +__attribute__((__always_inline__, __gnu_inline__, __artificial__)) +extern inline char * +strncpy (char *__restrict dest, const char *__restrict src, size_t len) +{ + return __builtin___strncpy_chk (dest, src, len, bos (dest)); +} + +__attribute__((__always_inline__, __gnu_inline__, __artificial__)) +extern inline char * +strncat (char *dest, const char *src, size_t len) +{ + return __builtin___strncat_chk (dest, src, len, bos (dest)); +} + +__attribute__((__always_inline__, __gnu_inline__, __artificial__)) +extern inline char * +stpncpy (char *__restrict dest, const char *__restrict src, size_t len) +{ + return __builtin___stpncpy_chk (dest, src, len, bos (dest)); +} +#endif + +struct A { short a, b; int c, d; long e, f; }; +typedef struct A TA; +typedef struct A *PA; +typedef TA *PTA; +struct B {}; +typedef struct B TB; +typedef struct B *PB; +typedef TB *PTB; +typedef int X[3][3][3]; + +int +f1 (void *x, int z) +{ + struct A a, *pa1 = &a; + TA *pa2 = &a; + PA pa3 = &a; + PTA pa4 = &a; + memset (&a, 0, sizeof (&a)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */ + memset (pa1, 0, sizeof (pa1)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + memset (pa2, 0, sizeof pa2); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + memset (pa3, 0, sizeof (pa3)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + memset (pa4, 0, sizeof pa4); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + memset (pa1, 0, sizeof (struct A *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + memset (pa2, 0, sizeof (PTA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + memset (pa3, 0, sizeof (PA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + memset (pa4, 0, sizeof (__typeof (pa4))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + + memcpy (&a, x, sizeof (&a)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */ + memcpy (pa1, x, sizeof (pa1)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + memcpy (pa2, x, sizeof pa2); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + memcpy (pa3, x, sizeof (pa3)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + memcpy (pa4, x, sizeof pa4); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + memcpy (pa1, x, sizeof (struct A *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + memcpy (pa2, x, sizeof (PTA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + memcpy (pa3, x, sizeof (PA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + memcpy (pa4, x, sizeof (__typeof (pa4))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + + memcpy (x, &a, sizeof (&a)); /* { dg-warning "call is the same expression as the source; did you mean to remove the addressof" } */ + memcpy (x, pa1, sizeof (pa1)); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + memcpy (x, pa2, sizeof pa2); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + memcpy (x, pa3, sizeof (pa3)); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + memcpy (x, pa4, sizeof pa4); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + memcpy (x, pa1, sizeof (struct A *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */ + memcpy (x, pa2, sizeof (PTA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */ + memcpy (x, pa3, sizeof (PA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */ + memcpy (x, pa4, sizeof (__typeof (pa4))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */ + + memmove (&a, x, sizeof (&a)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */ + memmove (pa1, x, sizeof (pa1)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + memmove (pa2, x, sizeof pa2); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + memmove (pa3, x, sizeof (pa3)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + memmove (pa4, x, sizeof pa4); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + memmove (pa1, x, sizeof (struct A *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + memmove (pa2, x, sizeof (PTA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + memmove (pa3, x, sizeof (PA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + memmove (pa4, x, sizeof (__typeof (pa4)));/* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + + memmove (x, &a, sizeof (&a)); /* { dg-warning "call is the same expression as the source; did you mean to remove the addressof" } */ + memmove (x, pa1, sizeof (pa1)); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + memmove (x, pa2, sizeof pa2); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + memmove (x, pa3, sizeof (pa3)); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + memmove (x, pa4, sizeof pa4); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + memmove (x, pa1, sizeof (struct A *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */ + memmove (x, pa2, sizeof (PTA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */ + memmove (x, pa3, sizeof (PA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */ + memmove (x, pa4, sizeof (__typeof (pa4)));/* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */ + + z += memcmp (&a, x, sizeof (&a)); /* { dg-warning "call is the same expression as the first source; did you mean to remove the addressof" } */ + z += memcmp (pa1, x, sizeof (pa1)); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */ + z += memcmp (pa2, x, sizeof pa2); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */ + z += memcmp (pa3, x, sizeof (pa3)); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */ + z += memcmp (pa4, x, sizeof pa4); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */ + z += memcmp (pa1, x, sizeof (struct A *));/* { dg-warning "call is the same pointer type \[^\n\r\]* as the first source; expected \[^\n\r\]* or an explicit length" } */ + z += memcmp (pa2, x, sizeof (PTA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the first source; expected \[^\n\r\]* or an explicit length" } */ + z += memcmp (pa3, x, sizeof (PA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the first source; expected \[^\n\r\]* or an explicit length" } */ + + z += memcmp (x, &a, sizeof (&a)); /* { dg-warning "call is the same expression as the second source; did you mean to remove the addressof" } */ + z += memcmp (x, pa1, sizeof (pa1)); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */ + z += memcmp (x, pa2, sizeof pa2); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */ + z += memcmp (x, pa3, sizeof (pa3)); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */ + z += memcmp (x, pa4, sizeof pa4); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */ + z += memcmp (x, pa1, sizeof (struct A *));/* { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" } */ + z += memcmp (x, pa2, sizeof (PTA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" } */ + z += memcmp (x, pa3, sizeof (PA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" } */ + + /* These are correct, no warning. */ + memset (&a, 0, sizeof a); + memset (&a, 0, sizeof (a)); + memset (&a, 0, sizeof (struct A)); + memset (&a, 0, sizeof (const struct A)); + memset (&a, 0, sizeof (volatile struct A)); + memset (&a, 0, sizeof (volatile const struct A)); + memset (&a, 0, sizeof (TA)); + memset (&a, 0, sizeof (__typeof (*&a))); + memset (pa1, 0, sizeof (*pa1)); + memset (pa2, 0, sizeof (*pa3)); + memset (pa3, 0, sizeof (__typeof (*pa3))); + /* These are probably broken, but obfuscated, no warning. */ + memset ((void *) &a, 0, sizeof (&a)); + memset ((char *) &a, 0, sizeof (&a)); + memset (&a, 0, sizeof (&a) + 0); + memset (&a, 0, 0 + sizeof (&a)); + + /* These are correct, no warning. */ + memcpy (&a, x, sizeof a); + memcpy (&a, x, sizeof (a)); + memcpy (&a, x, sizeof (struct A)); + memcpy (&a, x, sizeof (const struct A)); + memcpy (&a, x, sizeof (volatile struct A)); + memcpy (&a, x, sizeof (volatile const struct A)); + memcpy (&a, x, sizeof (TA)); + memcpy (&a, x, sizeof (__typeof (*&a))); + memcpy (pa1, x, sizeof (*pa1)); + memcpy (pa2, x, sizeof (*pa3)); + memcpy (pa3, x, sizeof (__typeof (*pa3))); + /* These are probably broken, but obfuscated, no warning. */ + memcpy ((void *) &a, x, sizeof (&a)); + memcpy ((char *) &a, x, sizeof (&a)); + memcpy (&a, x, sizeof (&a) + 0); + memcpy (&a, x, 0 + sizeof (&a)); + + /* These are correct, no warning. */ + memcpy (x, &a, sizeof a); + memcpy (x, &a, sizeof (a)); + memcpy (x, &a, sizeof (struct A)); + memcpy (x, &a, sizeof (const struct A)); + memcpy (x, &a, sizeof (volatile struct A)); + memcpy (x, &a, sizeof (volatile const struct A)); + memcpy (x, &a, sizeof (TA)); + memcpy (x, &a, sizeof (__typeof (*&a))); + memcpy (x, pa1, sizeof (*pa1)); + memcpy (x, pa2, sizeof (*pa3)); + memcpy (x, pa3, sizeof (__typeof (*pa3))); + /* These are probably broken, but obfuscated, no warning. */ + memcpy (x, (void *) &a, sizeof (&a)); + memcpy (x, (char *) &a, sizeof (&a)); + memcpy (x, &a, sizeof (&a) + 0); + memcpy (x, &a, 0 + sizeof (&a)); + + /* These are correct, no warning. */ + memmove (&a, x, sizeof a); + memmove (&a, x, sizeof (a)); + memmove (&a, x, sizeof (struct A)); + memmove (&a, x, sizeof (const struct A)); + memmove (&a, x, sizeof (volatile struct A)); + memmove (&a, x, sizeof (volatile const struct A)); + memmove (&a, x, sizeof (TA)); + memmove (&a, x, sizeof (__typeof (*&a))); + memmove (pa1, x, sizeof (*pa1)); + memmove (pa2, x, sizeof (*pa3)); + memmove (pa3, x, sizeof (__typeof (*pa3))); + /* These are probably broken, but obfuscated, no warning. */ + memmove ((void *) &a, x, sizeof (&a)); + memmove ((char *) &a, x, sizeof (&a)); + memmove (&a, x, sizeof (&a) + 0); + memmove (&a, x, 0 + sizeof (&a)); + + /* These are correct, no warning. */ + memmove (x, &a, sizeof a); + memmove (x, &a, sizeof (a)); + memmove (x, &a, sizeof (struct A)); + memmove (x, &a, sizeof (const struct A)); + memmove (x, &a, sizeof (volatile struct A)); + memmove (x, &a, sizeof (volatile const struct A)); + memmove (x, &a, sizeof (TA)); + memmove (x, &a, sizeof (__typeof (*&a))); + memmove (x, pa1, sizeof (*pa1)); + memmove (x, pa2, sizeof (*pa3)); + memmove (x, pa3, sizeof (__typeof (*pa3))); + /* These are probably broken, but obfuscated, no warning. */ + memmove (x, (void *) &a, sizeof (&a)); + memmove (x, (char *) &a, sizeof (&a)); + memmove (x, &a, sizeof (&a) + 0); + memmove (x, &a, 0 + sizeof (&a)); + + /* These are correct, no warning. */ + z += memcmp (&a, x, sizeof a); + z += memcmp (&a, x, sizeof (a)); + z += memcmp (&a, x, sizeof (struct A)); + z += memcmp (&a, x, sizeof (const struct A)); + z += memcmp (&a, x, sizeof (volatile struct A)); + z += memcmp (&a, x, sizeof (volatile const struct A)); + z += memcmp (&a, x, sizeof (TA)); + z += memcmp (&a, x, sizeof (__typeof (*&a))); + z += memcmp (pa1, x, sizeof (*pa1)); + z += memcmp (pa2, x, sizeof (*pa3)); + z += memcmp (pa3, x, sizeof (__typeof (*pa3))); + /* These are probably broken, but obfuscated, no warning. */ + z += memcmp ((void *) &a, x, sizeof (&a)); + z += memcmp ((char *) &a, x, sizeof (&a)); + z += memcmp (&a, x, sizeof (&a) + 0); + z += memcmp (&a, x, 0 + sizeof (&a)); + + /* These are correct, no warning. */ + z += memcmp (x, &a, sizeof a); + z += memcmp (x, &a, sizeof (a)); + z += memcmp (x, &a, sizeof (struct A)); + z += memcmp (x, &a, sizeof (const struct A)); + z += memcmp (x, &a, sizeof (volatile struct A)); + z += memcmp (x, &a, sizeof (volatile const struct A)); + z += memcmp (x, &a, sizeof (TA)); + z += memcmp (x, &a, sizeof (__typeof (*&a))); + z += memcmp (x, pa1, sizeof (*pa1)); + z += memcmp (x, pa2, sizeof (*pa3)); + z += memcmp (x, pa3, sizeof (__typeof (*pa3))); + /* These are probably broken, but obfuscated, no warning. */ + z += memcmp (x, (void *) &a, sizeof (&a)); + z += memcmp (x, (char *) &a, sizeof (&a)); + z += memcmp (x, &a, sizeof (&a) + 0); + z += memcmp (x, &a, 0 + sizeof (&a)); + + return z; +} + +int +f2 (void *x, int z) +{ + struct B b, *pb1 = &b; + TB *pb2 = &b; + PB pb3 = &b; + PTB pb4 = &b; + memset (&b, 0, sizeof (&b)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */ + memset (pb1, 0, sizeof (pb1)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + memset (pb2, 0, sizeof pb2); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + memset (pb3, 0, sizeof (pb3)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + memset (pb4, 0, sizeof pb4); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + memset (pb1, 0, sizeof (struct B *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + memset (pb2, 0, sizeof (PTB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + memset (pb3, 0, sizeof (PB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + memset (pb4, 0, sizeof (__typeof (pb4))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + + memcpy (&b, x, sizeof (&b)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */ + memcpy (pb1, x, sizeof (pb1)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + memcpy (pb2, x, sizeof pb2); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + memcpy (pb3, x, sizeof (pb3)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + memcpy (pb4, x, sizeof pb4); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + memcpy (pb1, x, sizeof (struct B *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + memcpy (pb2, x, sizeof (PTB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + memcpy (pb3, x, sizeof (PB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + memcpy (pb4, x, sizeof (__typeof (pb4))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + + memcpy (x, &b, sizeof (&b)); /* { dg-warning "call is the same expression as the source; did you mean to remove the addressof" } */ + memcpy (x, pb1, sizeof (pb1)); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + memcpy (x, pb2, sizeof pb2); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + memcpy (x, pb3, sizeof (pb3)); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + memcpy (x, pb4, sizeof pb4); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + memcpy (x, pb1, sizeof (struct B *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */ + memcpy (x, pb2, sizeof (PTB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */ + memcpy (x, pb3, sizeof (PB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */ + memcpy (x, pb4, sizeof (__typeof (pb4))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */ + + memmove (&b, x, sizeof (&b)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */ + memmove (pb1, x, sizeof (pb1)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + memmove (pb2, x, sizeof pb2); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + memmove (pb3, x, sizeof (pb3)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + memmove (pb4, x, sizeof pb4); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + memmove (pb1, x, sizeof (struct B *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + memmove (pb2, x, sizeof (PTB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + memmove (pb3, x, sizeof (PB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + memmove (pb4, x, sizeof (__typeof (pb4)));/* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + + memmove (x, &b, sizeof (&b)); /* { dg-warning "call is the same expression as the source; did you mean to remove the addressof" } */ + memmove (x, pb1, sizeof (pb1)); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + memmove (x, pb2, sizeof pb2); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + memmove (x, pb3, sizeof (pb3)); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + memmove (x, pb4, sizeof pb4); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + memmove (x, pb1, sizeof (struct B *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */ + memmove (x, pb2, sizeof (PTB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */ + memmove (x, pb3, sizeof (PB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */ + memmove (x, pb4, sizeof (__typeof (pb4)));/* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */ + + z += memcmp (&b, x, sizeof (&b)); /* { dg-warning "call is the same expression as the first source; did you mean to remove the addressof" } */ + z += memcmp (pb1, x, sizeof (pb1)); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */ + z += memcmp (pb2, x, sizeof pb2); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */ + z += memcmp (pb3, x, sizeof (pb3)); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */ + z += memcmp (pb4, x, sizeof pb4); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */ + z += memcmp (pb1, x, sizeof (struct B *));/* { dg-warning "call is the same pointer type \[^\n\r\]* as the first source; expected \[^\n\r\]* or an explicit length" } */ + z += memcmp (pb2, x, sizeof (PTB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the first source; expected \[^\n\r\]* or an explicit length" } */ + z += memcmp (pb3, x, sizeof (PB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the first source; expected \[^\n\r\]* or an explicit length" } */ + + z += memcmp (x, &b, sizeof (&b)); /* { dg-warning "call is the same expression as the second source; did you mean to remove the addressof" } */ + z += memcmp (x, pb1, sizeof (pb1)); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */ + z += memcmp (x, pb2, sizeof pb2); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */ + z += memcmp (x, pb3, sizeof (pb3)); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */ + z += memcmp (x, pb4, sizeof pb4); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */ + z += memcmp (x, pb1, sizeof (struct B *));/* { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" } */ + z += memcmp (x, pb2, sizeof (PTB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" } */ + z += memcmp (x, pb3, sizeof (PB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" } */ + + /* These are correct, no warning. */ + memset (&b, 0, sizeof b); + memset (&b, 0, sizeof (b)); + memset (&b, 0, sizeof (struct B)); + memset (&b, 0, sizeof (const struct B)); + memset (&b, 0, sizeof (volatile struct B)); + memset (&b, 0, sizeof (volatile const struct B)); + memset (&b, 0, sizeof (TB)); + memset (&b, 0, sizeof (__typeof (*&b))); + memset (pb1, 0, sizeof (*pb1)); + memset (pb2, 0, sizeof (*pb3)); + memset (pb3, 0, sizeof (__typeof (*pb3))); + /* These are probably broken, but obfuscated, no warning. */ + memset ((void *) &b, 0, sizeof (&b)); + memset ((char *) &b, 0, sizeof (&b)); + memset (&b, 0, sizeof (&b) + 0); + memset (&b, 0, 0 + sizeof (&b)); + + /* These are correct, no warning. */ + memcpy (&b, x, sizeof b); + memcpy (&b, x, sizeof (b)); + memcpy (&b, x, sizeof (struct B)); + memcpy (&b, x, sizeof (const struct B)); + memcpy (&b, x, sizeof (volatile struct B)); + memcpy (&b, x, sizeof (volatile const struct B)); + memcpy (&b, x, sizeof (TB)); + memcpy (&b, x, sizeof (__typeof (*&b))); + memcpy (pb1, x, sizeof (*pb1)); + memcpy (pb2, x, sizeof (*pb3)); + memcpy (pb3, x, sizeof (__typeof (*pb3))); + /* These are probably broken, but obfuscated, no warning. */ + memcpy ((void *) &b, x, sizeof (&b)); + memcpy ((char *) &b, x, sizeof (&b)); + memcpy (&b, x, sizeof (&b) + 0); + memcpy (&b, x, 0 + sizeof (&b)); + + /* These are correct, no warning. */ + memcpy (x, &b, sizeof b); + memcpy (x, &b, sizeof (b)); + memcpy (x, &b, sizeof (struct B)); + memcpy (x, &b, sizeof (const struct B)); + memcpy (x, &b, sizeof (volatile struct B)); + memcpy (x, &b, sizeof (volatile const struct B)); + memcpy (x, &b, sizeof (TB)); + memcpy (x, &b, sizeof (__typeof (*&b))); + memcpy (x, pb1, sizeof (*pb1)); + memcpy (x, pb2, sizeof (*pb3)); + memcpy (x, pb3, sizeof (__typeof (*pb3))); + /* These are probably broken, but obfuscated, no warning. */ + memcpy (x, (void *) &b, sizeof (&b)); + memcpy (x, (char *) &b, sizeof (&b)); + memcpy (x, &b, sizeof (&b) + 0); + memcpy (x, &b, 0 + sizeof (&b)); + + /* These are correct, no warning. */ + memmove (&b, x, sizeof b); + memmove (&b, x, sizeof (b)); + memmove (&b, x, sizeof (struct B)); + memmove (&b, x, sizeof (const struct B)); + memmove (&b, x, sizeof (volatile struct B)); + memmove (&b, x, sizeof (volatile const struct B)); + memmove (&b, x, sizeof (TB)); + memmove (&b, x, sizeof (__typeof (*&b))); + memmove (pb1, x, sizeof (*pb1)); + memmove (pb2, x, sizeof (*pb3)); + memmove (pb3, x, sizeof (__typeof (*pb3))); + /* These are probably broken, but obfuscated, no warning. */ + memmove ((void *) &b, x, sizeof (&b)); + memmove ((char *) &b, x, sizeof (&b)); + memmove (&b, x, sizeof (&b) + 0); + memmove (&b, x, 0 + sizeof (&b)); + + /* These are correct, no warning. */ + memmove (x, &b, sizeof b); + memmove (x, &b, sizeof (b)); + memmove (x, &b, sizeof (struct B)); + memmove (x, &b, sizeof (const struct B)); + memmove (x, &b, sizeof (volatile struct B)); + memmove (x, &b, sizeof (volatile const struct B)); + memmove (x, &b, sizeof (TB)); + memmove (x, &b, sizeof (__typeof (*&b))); + memmove (x, pb1, sizeof (*pb1)); + memmove (x, pb2, sizeof (*pb3)); + memmove (x, pb3, sizeof (__typeof (*pb3))); + /* These are probably broken, but obfuscated, no warning. */ + memmove (x, (void *) &b, sizeof (&b)); + memmove (x, (char *) &b, sizeof (&b)); + memmove (x, &b, sizeof (&b) + 0); + memmove (x, &b, 0 + sizeof (&b)); + + /* These are correct, no warning. */ + z += memcmp (&b, x, sizeof b); + z += memcmp (&b, x, sizeof (b)); + z += memcmp (&b, x, sizeof (struct B)); + z += memcmp (&b, x, sizeof (const struct B)); + z += memcmp (&b, x, sizeof (volatile struct B)); + z += memcmp (&b, x, sizeof (volatile const struct B)); + z += memcmp (&b, x, sizeof (TB)); + z += memcmp (&b, x, sizeof (__typeof (*&b))); + z += memcmp (pb1, x, sizeof (*pb1)); + z += memcmp (pb2, x, sizeof (*pb3)); + z += memcmp (pb3, x, sizeof (__typeof (*pb3))); + /* These are probably broken, but obfuscated, no warning. */ + z += memcmp ((void *) &b, x, sizeof (&b)); + z += memcmp ((char *) &b, x, sizeof (&b)); + z += memcmp (&b, x, sizeof (&b) + 0); + z += memcmp (&b, x, 0 + sizeof (&b)); + + /* These are correct, no warning. */ + z += memcmp (x, &b, sizeof b); + z += memcmp (x, &b, sizeof (b)); + z += memcmp (x, &b, sizeof (struct B)); + z += memcmp (x, &b, sizeof (const struct B)); + z += memcmp (x, &b, sizeof (volatile struct B)); + z += memcmp (x, &b, sizeof (volatile const struct B)); + z += memcmp (x, &b, sizeof (TB)); + z += memcmp (x, &b, sizeof (__typeof (*&b))); + z += memcmp (x, pb1, sizeof (*pb1)); + z += memcmp (x, pb2, sizeof (*pb3)); + z += memcmp (x, pb3, sizeof (__typeof (*pb3))); + /* These are probably broken, but obfuscated, no warning. */ + z += memcmp (x, (void *) &b, sizeof (&b)); + z += memcmp (x, (char *) &b, sizeof (&b)); + z += memcmp (x, &b, sizeof (&b) + 0); + z += memcmp (x, &b, 0 + sizeof (&b)); + + return z; +} + +int +f3 (void *x, char *y, int z, X w) +{ + unsigned char *y1 = (unsigned char *) __builtin_alloca (z + 16); + char buf1[7]; + signed char buf2[z + 32]; + long buf3[17]; + int *buf4[9]; + signed char *y2 = buf2; + char c; + char *y3; + memset (y, 0, sizeof (y)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */ + memset (y1, 0, sizeof (y1)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */ + memset (y2, 0, sizeof (y2)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */ + memset (&c, 0, sizeof (&c)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */ + memset (w, 0, sizeof w); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + + memcpy (y, x, sizeof (y)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */ + memcpy (y1, x, sizeof (y1)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */ + memcpy (y2, x, sizeof (y2)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */ + memcpy (&c, x, sizeof (&c)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */ + memcpy (w, x, sizeof w); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + + memcpy (x, y, sizeof (y)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */ + memcpy (x, y1, sizeof (y1)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */ + memcpy (x, y2, sizeof (y2)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */ + memcpy (x, &c, sizeof (&c)); /* { dg-warning "call is the same expression as the source; did you mean to remove the addressof" } */ + memcpy (x, w, sizeof w); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + + memmove (y, x, sizeof (y)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */ + memmove (y1, x, sizeof (y1)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */ + memmove (y2, x, sizeof (y2)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */ + memmove (&c, x, sizeof (&c)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */ + memmove (w, x, sizeof w); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + + memmove (x, y, sizeof (y)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */ + memmove (x, y1, sizeof (y1)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */ + memmove (x, y2, sizeof (y2)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */ + memmove (x, &c, sizeof (&c)); /* { dg-warning "call is the same expression as the source; did you mean to remove the addressof" } */ + memmove (x, w, sizeof w); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + + z += memcmp (y, x, sizeof (y)); /* { dg-warning "call is the same expression as the first source; did you mean to provide an explicit length" } */ + z += memcmp (y1, x, sizeof (y1)); /* { dg-warning "call is the same expression as the first source; did you mean to provide an explicit length" } */ + z += memcmp (y2, x, sizeof (y2)); /* { dg-warning "call is the same expression as the first source; did you mean to provide an explicit length" } */ + z += memcmp (&c, x, sizeof (&c)); /* { dg-warning "call is the same expression as the first source; did you mean to remove the addressof" } */ + z += memcmp (w, x, sizeof w); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */ + + z += memcmp (x, y, sizeof (y)); /* { dg-warning "call is the same expression as the second source; did you mean to provide an explicit length" } */ + z += memcmp (x, y1, sizeof (y1)); /* { dg-warning "call is the same expression as the second source; did you mean to provide an explicit length" } */ + z += memcmp (x, y2, sizeof (y2)); /* { dg-warning "call is the same expression as the second source; did you mean to provide an explicit length" } */ + z += memcmp (x, &c, sizeof (&c)); /* { dg-warning "call is the same expression as the second source; did you mean to remove the addressof" } */ + z += memcmp (x, w, sizeof w); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */ + + /* These are correct, no warning. */ + memset (y, 0, sizeof (*y)); + memset (y1, 0, sizeof (*y2)); + memset (buf1, 0, sizeof buf1); + memset (buf3, 0, sizeof (buf3)); + memset (&buf3[0], 0, sizeof (buf3)); + memset (&buf4[0], 0, sizeof (buf4)); + memset (w, 0, sizeof (X)); + /* These are probably broken, but obfuscated, no warning. */ + memset ((void *) y, 0, sizeof (y)); + memset ((char *) y1, 0, sizeof (y2)); + memset (y, 0, sizeof (y) + 0); + memset (y1, 0, 0 + sizeof (y2)); + memset ((void *) &c, 0, sizeof (&c)); + memset ((signed char *) &c, 0, sizeof (&c)); + memset (&c, 0, sizeof (&c) + 0); + memset (&c, 0, 0 + sizeof (&c)); + + /* These are correct, no warning. */ + memcpy (y, x, sizeof (*y)); + memcpy (y1, x, sizeof (*y2)); + memcpy (buf1, x, sizeof buf1); + memcpy (buf3, x, sizeof (buf3)); + memcpy (&buf3[0], x, sizeof (buf3)); + memcpy (&buf4[0], x, sizeof (buf4)); + memcpy (&y3, y, sizeof (y3)); + memcpy ((char *) &y3, y, sizeof (y3)); + memcpy (w, x, sizeof (X)); + /* These are probably broken, but obfuscated, no warning. */ + memcpy ((void *) y, x, sizeof (y)); + memcpy ((char *) y1, x, sizeof (y2)); + memcpy (y, x, sizeof (y) + 0); + memcpy (y1, x, 0 + sizeof (y2)); + memcpy ((void *) &c, x, sizeof (&c)); + memcpy ((signed char *) &c, x, sizeof (&c)); + memcpy (&c, x, sizeof (&c) + 0); + memcpy (&c, x, 0 + sizeof (&c)); + + /* These are correct, no warning. */ + memcpy (x, y, sizeof (*y)); + memcpy (x, y1, sizeof (*y2)); + memcpy (x, buf1, sizeof buf1); + memcpy (x, buf3, sizeof (buf3)); + memcpy (x, &buf3[0], sizeof (buf3)); + memcpy (x, &buf4[0], sizeof (buf4)); + memcpy (y, &y3, sizeof (y3)); + memcpy (y, (char *) &y3, sizeof (y3)); + memcpy (x, w, sizeof (X)); + /* These are probably broken, but obfuscated, no warning. */ + memcpy (x, (void *) y, sizeof (y)); + memcpy (x, (char *) y1, sizeof (y2)); + memcpy (x, y, sizeof (y) + 0); + memcpy (x, y1, 0 + sizeof (y2)); + memcpy (x, (void *) &c, sizeof (&c)); + memcpy (x, (signed char *) &c, sizeof (&c)); + memcpy (x, &c, sizeof (&c) + 0); + memcpy (x, &c, 0 + sizeof (&c)); + + /* These are correct, no warning. */ + memmove (y, x, sizeof (*y)); + memmove (y1, x, sizeof (*y2)); + memmove (buf1, x, sizeof buf1); + memmove (buf3, x, sizeof (buf3)); + memmove (&buf3[0], x, sizeof (buf3)); + memmove (&buf4[0], x, sizeof (buf4)); + memmove (&y3, y, sizeof (y3)); + memmove ((char *) &y3, y, sizeof (y3)); + memmove (w, x, sizeof (X)); + /* These are probably broken, but obfuscated, no warning. */ + memmove ((void *) y, x, sizeof (y)); + memmove ((char *) y1, x, sizeof (y2)); + memmove (y, x, sizeof (y) + 0); + memmove (y1, x, 0 + sizeof (y2)); + memmove ((void *) &c, x, sizeof (&c)); + memmove ((signed char *) &c, x, sizeof (&c)); + memmove (&c, x, sizeof (&c) + 0); + memmove (&c, x, 0 + sizeof (&c)); + + /* These are correct, no warning. */ + memmove (x, y, sizeof (*y)); + memmove (x, y1, sizeof (*y2)); + memmove (x, buf1, sizeof buf1); + memmove (x, buf3, sizeof (buf3)); + memmove (x, &buf3[0], sizeof (buf3)); + memmove (x, &buf4[0], sizeof (buf4)); + memmove (y, &y3, sizeof (y3)); + memmove (y, (char *) &y3, sizeof (y3)); + memmove (x, w, sizeof (X)); + /* These are probably broken, but obfuscated, no warning. */ + memmove (x, (void *) y, sizeof (y)); + memmove (x, (char *) y1, sizeof (y2)); + memmove (x, y, sizeof (y) + 0); + memmove (x, y1, 0 + sizeof (y2)); + memmove (x, (void *) &c, sizeof (&c)); + memmove (x, (signed char *) &c, sizeof (&c)); + memmove (x, &c, sizeof (&c) + 0); + memmove (x, &c, 0 + sizeof (&c)); + + /* These are correct, no warning. */ + z += memcmp (y, x, sizeof (*y)); + z += memcmp (y1, x, sizeof (*y2)); + z += memcmp (buf1, x, sizeof buf1); + z += memcmp (buf3, x, sizeof (buf3)); + z += memcmp (&buf3[0], x, sizeof (buf3)); + z += memcmp (&buf4[0], x, sizeof (buf4)); + z += memcmp (&y3, y, sizeof (y3)); + z += memcmp ((char *) &y3, y, sizeof (y3)); + z += memcmp (w, x, sizeof (X)); + /* These are probably broken, but obfuscated, no warning. */ + z += memcmp ((void *) y, x, sizeof (y)); + z += memcmp ((char *) y1, x, sizeof (y2)); + z += memcmp (y, x, sizeof (y) + 0); + z += memcmp (y1, x, 0 + sizeof (y2)); + z += memcmp ((void *) &c, x, sizeof (&c)); + z += memcmp ((signed char *) &c, x, sizeof (&c)); + z += memcmp (&c, x, sizeof (&c) + 0); + z += memcmp (&c, x, 0 + sizeof (&c)); + + /* These are correct, no warning. */ + z += memcmp (x, y, sizeof (*y)); + z += memcmp (x, y1, sizeof (*y2)); + z += memcmp (x, buf1, sizeof buf1); + z += memcmp (x, buf3, sizeof (buf3)); + z += memcmp (x, &buf3[0], sizeof (buf3)); + z += memcmp (x, &buf4[0], sizeof (buf4)); + z += memcmp (y, &y3, sizeof (y3)); + z += memcmp (y, (char *) &y3, sizeof (y3)); + z += memcmp (x, w, sizeof (X)); + /* These are probably broken, but obfuscated, no warning. */ + z += memcmp (x, (void *) y, sizeof (y)); + z += memcmp (x, (char *) y1, sizeof (y2)); + z += memcmp (x, y, sizeof (y) + 0); + z += memcmp (x, y1, 0 + sizeof (y2)); + z += memcmp (x, (void *) &c, sizeof (&c)); + z += memcmp (x, (signed char *) &c, sizeof (&c)); + z += memcmp (x, &c, sizeof (&c) + 0); + z += memcmp (x, &c, 0 + sizeof (&c)); + + return z; +} + +int +f4 (char *x, char **y, int z, char w[64]) +{ + const char *s1 = "foobarbaz"; + const char *s2 = "abcde12345678"; + strncpy (x, s1, sizeof (s1)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */ + strncat (x, s2, sizeof (s2)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */ + stpncpy (x, s1, sizeof (s1)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */ + y[0] = strndup (s1, sizeof (s1)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */ + z += strncmp (s1, s2, sizeof (s1)); /* { dg-warning "call is the same expression as the first source; did you mean to provide an explicit length" } */ + z += strncmp (s1, s2, sizeof (s2)); /* { dg-warning "call is the same expression as the second source; did you mean to provide an explicit length" } */ + z += strncasecmp (s1, s2, sizeof (s1)); /* { dg-warning "call is the same expression as the first source; did you mean to provide an explicit length" } */ + z += strncasecmp (s1, s2, sizeof (s2)); /* { dg-warning "call is the same expression as the second source; did you mean to provide an explicit length" } */ + + strncpy (w, s1, sizeof (w)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */ + strncat (w, s2, sizeof (w)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */ + stpncpy (w, s1, sizeof (w)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */ + + /* These are correct, no warning. */ + const char s3[] = "foobarbaz"; + const char s4[] = "abcde12345678"; + strncpy (x, s3, sizeof (s3)); + strncat (x, s4, sizeof (s4)); + stpncpy (x, s3, sizeof (s3)); + y[1] = strndup (s3, sizeof (s3)); + z += strncmp (s3, s4, sizeof (s3)); + z += strncmp (s3, s4, sizeof (s4)); + z += strncasecmp (s3, s4, sizeof (s3)); + z += strncasecmp (s3, s4, sizeof (s4)); + + return z; +} + +/* { dg-prune-output "\[\n\r\]*will always overflow\[\n\r\]*" } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/alias-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/alias-1.c new file mode 100644 index 000000000..92b880990 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/alias-1.c @@ -0,0 +1,39 @@ +/* { dg-do run } */ +/* { dg-options "-fschedule-insns" } */ +/* { dg-require-effective-target scheduling } */ + +extern void abort (void) __attribute__((noreturn)); + +struct B { int a; int b;}; +struct wrapper { +union setconflict +{ + struct S { char one1; struct B b1; } s; + struct T { struct B b2; char two2; } t; +} a; +}; + +int +main () +{ + int sum = 0; + int i; + struct wrapper w; + struct B *p; + + p = &w.a.s.b1; + asm ("": "=r" (p):"0" (p)); + p->a = 0; + asm ("": "=r" (p):"0" (p)); + sum += p->a; + + p = &w.a.t.b2; + asm ("": "=r" (p):"0" (p)); + p->b = 1; + asm ("": "=r" (p):"0" (p)); + sum += p->b; + + if (sum != 1) + abort(); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-compile-assign.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-compile-assign.c new file mode 100644 index 000000000..d6143d278 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-compile-assign.c @@ -0,0 +1,29 @@ +/* { dg-do compile { target arm*-*-* } } */ +/* { dg-options "-mfp16-format=ieee" } */ + +/* Test basic assignments and conversions for __fp16. */ + +__fp16 h0 = -1.0; +__fp16 h1 = 0.0; +__fp16 h2 = 1234.0; +__fp16 h3 = 42.0; +float f1 = 2.0; +float f2 = -999.9; + +void f (__fp16 *p) +{ + __fp16 t; + + h0 = 1.0; + h1 = h2; + h2 = f1; + f2 = h2; + + t = *p; + *p = h3; + h3 = t; +} + +/* Make sure we are not falling through to undefined libcalls. */ +/* { dg-final { scan-assembler-not "__truncsfhf" } } */ +/* { dg-final { scan-assembler-not "__extendhfsf" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-compile-convert.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-compile-convert.c new file mode 100644 index 000000000..04341959f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-compile-convert.c @@ -0,0 +1,41 @@ +/* { dg-do compile { target arm*-*-* } } */ +/* { dg-options "-mfp16-format=ieee" } */ + +/* Test basic assignments and conversions for __fp16. */ + +__fp16 h1 = 0.0; +__fp16 h2 = 1234.0; +char c1 = 1; +char c2 = 2; +short s1 = 10; +short s2 = 20; +int i1 = -100; +int i2 = -200; +long long l1 = 1000.0; +long long l2 = 2000.0; +double d1 = -10000.0; +double d2 = -20000.0; + +void f (void) +{ + c1 = h1; + h2 = c2; + + h1 = s1; + s2 = h2; + + i1 = h1; + h2 = i2; + + h1 = l1; + l2 = h2; + + d1 = h1; + h2 = d2; +} + +/* Make sure we are not falling through to undefined libcalls. */ +/* { dg-final { scan-assembler-not "__float.ihf" } } */ +/* { dg-final { scan-assembler-not "__fixhf.i" } } */ +/* { dg-final { scan-assembler-not "__trunc.fhf" } } */ +/* { dg-final { scan-assembler-not "__extendhf.f" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-int-convert-alt.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-int-convert-alt.c new file mode 100644 index 000000000..bcd7aeff1 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-int-convert-alt.c @@ -0,0 +1,17 @@ +/* Test floating-point conversions. Standard types and __fp16. */ +/* { dg-do run { target arm*-*-* } } */ +/* { dg-options "-mfp16-format=alternative" } */ + +#include "fp-int-convert.h" +#define FP16_MANT_DIG 11 + +int +main (void) +{ + TEST_I_F(signed char, unsigned char, float, FP16_MANT_DIG); + TEST_I_F(signed short, unsigned short, float, FP16_MANT_DIG); + TEST_I_F(signed int, unsigned int, float, FP16_MANT_DIG); + TEST_I_F(signed long, unsigned long, float, FP16_MANT_DIG); + TEST_I_F(signed long long, unsigned long long, float, FP16_MANT_DIG); + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-int-convert-ieee.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-int-convert-ieee.c new file mode 100644 index 000000000..1314d4b0e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-int-convert-ieee.c @@ -0,0 +1,17 @@ +/* Test floating-point conversions. Standard types and __fp16. */ +/* { dg-do run { target arm*-*-* } } */ +/* { dg-options "-mfp16-format=ieee" } */ + +#include "fp-int-convert.h" +#define FP16_MANT_DIG 11 + +int +main (void) +{ + TEST_I_F(signed char, unsigned char, float, FP16_MANT_DIG); + TEST_I_F(signed short, unsigned short, float, FP16_MANT_DIG); + TEST_I_F(signed int, unsigned int, float, FP16_MANT_DIG); + TEST_I_F(signed long, unsigned long, float, FP16_MANT_DIG); + TEST_I_F(signed long long, unsigned long long, float, FP16_MANT_DIG); + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-1.c new file mode 100644 index 000000000..0c601e68c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-1.c @@ -0,0 +1,5 @@ +/* Test various operators on __fp16 and mixed __fp16/float operands. */ +/* { dg-do run { target arm*-*-* } } */ +/* { dg-options "-mfp16-format=ieee" } */ + +#include "arm-fp16-ops.h" diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-2.c new file mode 100644 index 000000000..244e31082 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-2.c @@ -0,0 +1,5 @@ +/* Test various operators on __fp16 and mixed __fp16/float operands. */ +/* { dg-do run { target arm*-*-* } } */ +/* { dg-options "-mfp16-format=ieee -ffast-math" } */ + +#include "arm-fp16-ops.h" diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-3.c new file mode 100644 index 000000000..8f9ab64bc --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-3.c @@ -0,0 +1,5 @@ +/* Test various operators on __fp16 and mixed __fp16/float operands. */ +/* { dg-do run { target arm*-*-* } } */ +/* { dg-options "-mfp16-format=alternative" } */ + +#include "arm-fp16-ops.h" diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-4.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-4.c new file mode 100644 index 000000000..4877f392c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-4.c @@ -0,0 +1,5 @@ +/* Test various operators on __fp16 and mixed __fp16/float operands. */ +/* { dg-do run { target arm*-*-* } } */ +/* { dg-options "-mfp16-format=alternative -ffast-math" } */ + +#include "arm-fp16-ops.h" diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-5.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-5.c new file mode 100644 index 000000000..92bc8a9c0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-5.c @@ -0,0 +1,15 @@ +/* Test various operators on __fp16 and mixed __fp16/float operands. */ +/* { dg-do compile { target arm*-*-* } } */ +/* { dg-require-effective-target arm_fp16_ok } */ +/* { dg-options "-mfp16-format=ieee" } */ +/* { dg-add-options arm_fp16 } */ + +#include "arm-fp16-ops.h" + +/* We've specified options for hardware float, including fp16 support, so + we should not see any calls to libfuncs here. */ +/* { dg-final { scan-assembler-not "\tbl\t__.*hf2" } } */ +/* { dg-final { scan-assembler-not "\tbl\t__.*hf3" } } */ +/* { dg-final { scan-assembler-not "\tbl\t__gnu_h\[a-z\]*_ieee" } } */ +/* { dg-final { scan-assembler-not "\tbl\t__gnu_h2f_ieee" } } */ +/* { dg-final { scan-assembler-not "\tbl\t__gnu_f2h_ieee" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-6.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-6.c new file mode 100644 index 000000000..ae40b1e86 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-6.c @@ -0,0 +1,15 @@ +/* Test various operators on __fp16 and mixed __fp16/float operands. */ +/* { dg-do compile { target arm*-*-* } } */ +/* { dg-require-effective-target arm_fp16_ok } */ +/* { dg-options "-mfp16-format=ieee -ffast-math" } */ +/* { dg-add-options arm_fp16 } */ + +#include "arm-fp16-ops.h" + +/* We've specified options for hardware float, including fp16 support, so + we should not see any calls to libfuncs here. */ +/* { dg-final { scan-assembler-not "\tbl\t__.*hf2" } } */ +/* { dg-final { scan-assembler-not "\tbl\t__.*hf3" } } */ +/* { dg-final { scan-assembler-not "\tbl\t__gnu_h\[a-z\]*_ieee" } } */ +/* { dg-final { scan-assembler-not "\tbl\t__gnu_h2f_ieee" } } */ +/* { dg-final { scan-assembler-not "\tbl\t__gnu_f2h_ieee" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-7.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-7.c new file mode 100644 index 000000000..ed8089bd6 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-7.c @@ -0,0 +1,13 @@ +/* Test various operators on __fp16 and mixed __fp16/float operands. */ +/* { dg-do compile { target arm*-*-* } } */ +/* { dg-require-effective-target arm_neon_ok } */ +/* { dg-options "-mfp16-format=ieee" } */ +/* { dg-add-options arm_neon } */ + +#include "arm-fp16-ops.h" + +/* We've specified options for hardware float, so we should not see any + calls to libfuncs here except for those to the conversion functions. */ +/* { dg-final { scan-assembler-not "\tbl\t__.*hf2" } } */ +/* { dg-final { scan-assembler-not "\tbl\t__.*hf3" } } */ +/* { dg-final { scan-assembler-not "\tbl\t__gnu_h\[a-z\]*_ieee" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-8.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-8.c new file mode 100644 index 000000000..b138ca187 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops-8.c @@ -0,0 +1,13 @@ +/* Test various operators on __fp16 and mixed __fp16/float operands. */ +/* { dg-do compile { target arm*-*-* } } */ +/* { dg-require-effective-target arm_neon_ok } */ +/* { dg-options "-mfp16-format=ieee -ffast-math" } */ +/* { dg-add-options arm_neon } */ + +#include "arm-fp16-ops.h" + +/* We've specified options for hardware float, so we should not see any + calls to libfuncs here except for those to the conversion functions. */ +/* { dg-final { scan-assembler-not "\tbl\t__.*hf2" } } */ +/* { dg-final { scan-assembler-not "\tbl\t__.*hf3" } } */ +/* { dg-final { scan-assembler-not "\tbl\t__gnu_h\[a-z\]*_ieee" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops.h b/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops.h new file mode 100644 index 000000000..320494ee7 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/arm-fp16-ops.h @@ -0,0 +1,135 @@ +/* Test various operators on __fp16 and mixed __fp16/float operands. */ + +#include <assert.h> + +#define CHECK(e,r) assert ((e) == r) +#define CHECK2(e,r) (assert ((e) == r), temp = (e), assert (temp == r)) +#define TEST(e) assert (e) +#define TESTNOT(e) assert (!(e)) + +volatile __fp16 h0 = 0.0; +volatile __fp16 h1 = 1.0; +volatile __fp16 h42 = 42.0; +volatile __fp16 hm2 = -2.0; +volatile __fp16 temp; + +volatile float f0 = 0.0; +volatile float f1 = 1.0; +volatile float f42 = 42.0; +volatile float fm2 = -2.0; + +int main (void) +{ + TEST (h1); + TESTNOT (h0); + TEST (!h0); + TESTNOT (!h1); + + CHECK2 (-h1, -1.0); + CHECK2 (+h1, 1.0); + + CHECK (h1++, 1.0); + CHECK (h1, 2.0); + CHECK (++h1, 3.0); + CHECK (h1, 3.0); + + CHECK (--h1, 2.0); + CHECK (h1, 2.0); + CHECK (h1--, 2.0); + CHECK (h1, 1.0); + + CHECK2 (h42 * hm2, -84.0); + CHECK2 (h42 * (__fp16) -2.0, -84.0); + CHECK2 (h42 * fm2, -84.0); + CHECK2 (f42 * hm2, -84.0); + + CHECK2 (h42 / hm2, -21.0); + CHECK2 (h42 / (__fp16) -2.0, -21.0); + CHECK2 (h42 / fm2, -21.0); + CHECK2 (f42 / hm2, -21.0); + + CHECK2 (hm2 + h42, 40.0); + CHECK2 ((__fp16)-2.0 + h42, 40.0); + CHECK2 (hm2 + f42, 40.0); + CHECK2 (fm2 + h42, 40.0); + + CHECK2 (hm2 - h42, -44.0); + CHECK2 ((__fp16)-2.0 - h42, -44.0); + CHECK2 (hm2 - f42, -44.0); + CHECK2 (fm2 - h42, -44.0); + + TEST (hm2 < h42); + TEST (hm2 < (__fp16)42.0); + TEST (hm2 < f42); + TEST (fm2 < h42); + + TEST (h42 > hm2); + TEST ((__fp16)42.0 > hm2); + TEST (h42 > fm2); + TEST (f42 > hm2); + + TEST (hm2 <= h42); + TEST (hm2 <= (__fp16)42.0); + TEST (hm2 <= f42); + TEST (fm2 <= h42); + + TEST (h42 >= hm2); + TEST (h42 >= (__fp16)-2.0); + TEST (h42 >= fm2); + TEST (f42 >= hm2); + + TESTNOT (h1 == hm2); + TEST (h1 == h1); + TEST (h1 == (__fp16)1.0); + TEST (h1 == f1); + TEST (f1 == h1); + + TEST (h1 != hm2); + TESTNOT (h1 != h1); + TESTNOT (h1 != (__fp16)1.0); + TESTNOT (h1 != f1); + TESTNOT (f1 != h1); + + CHECK2 ((h1 ? hm2 : h42), -2.0); + CHECK2 ((h0 ? hm2 : h42), 42.0); + + CHECK (h0 = h42, 42.0); + CHECK (h0, 42.0); + CHECK (h0 = (__fp16)-2.0, -2.0); + CHECK (h0, -2.0); + CHECK (h0 = f0, 0.0); + CHECK (h0, 0.0); + + CHECK (h0 += h1, 1.0); + CHECK (h0, 1.0); + CHECK (h0 += (__fp16)1.0, 2.0); + CHECK (h0, 2.0); + CHECK (h0 += fm2, 0.0); + CHECK (h0, 0.0); + + CHECK (h0 -= h1, -1.0); + CHECK (h0, -1.0); + CHECK (h0 -= (__fp16)1.0, -2.0); + CHECK (h0, -2.0); + CHECK (h0 -= fm2, 0.0); + CHECK (h0, 0.0); + + h0 = hm2; + CHECK (h0 *= hm2, 4.0); + CHECK (h0, 4.0); + CHECK (h0 *= (__fp16)-2.0, -8.0); + CHECK (h0, -8.0); + CHECK (h0 *= fm2, 16.0); + CHECK (h0, 16.0); + + CHECK (h0 /= hm2, -8.0); + CHECK (h0, -8.0); + CHECK (h0 /= (__fp16)-2.0, 4.0); + CHECK (h0, 4.0); + CHECK (h0 /= fm2, -2.0); + CHECK (h0, -2.0); + + CHECK ((h0, h1), 1.0); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/asm-subreg-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/asm-subreg-1.c new file mode 100644 index 000000000..d3a14b24c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/asm-subreg-1.c @@ -0,0 +1,15 @@ +/* PR middle-end/20491 */ + +/* { dg-do compile } */ +/* { dg-skip-if "" { hppa*64*-*-* || sparc-*-vxworks* } "*" "" } */ + +/* Combine used to introduce invalid subregs for the asm input, and + we'd crash later on, when removing all subregs. */ + +volatile unsigned short _const_32 [4] = {1,2,3,4}; +void +evas_common_convert_yuv_420p_601_rgba() +{ + __asm__ __volatile__ ("" : : "X" (*_const_32)); +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/badshift.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/badshift.c new file mode 100644 index 000000000..39d123b13 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/badshift.c @@ -0,0 +1,29 @@ +/* PR rtl-optimization/20532 */ + +/* { dg-do run } */ +/* { dg-options "" } */ +/* { dg-options "-march=i386" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +/* We used to optimize the DImode shift-by-32 to zero because in combine + we turned: + + (v << 31) + (v << 31) + + into: + + (v * (((HOST_WIDE_INT)1 << 31) + ((HOST_WIDE_INT)1 << 31))) + + With a 32-bit HOST_WIDE_INT, the coefficient overflowed to zero. */ + +unsigned long long int badshift(unsigned long long int v) +{ + return v << 31 << 1; +} + +extern void abort (); + +int main() { + if (badshift (1) == 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-attr-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-attr-1.c new file mode 100644 index 000000000..c138b9234 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-attr-1.c @@ -0,0 +1,438 @@ +/* Copyright (C) 2003, 2005 Free Software Foundation. + + Verify that the `const' function attribute is applied to various + builtins and that these functions are optimized away by the + compiler under the appropriate circumstances. + + Written by Kaveh Ghazi, 2003-08-04. */ + +/* { dg-do link } */ +/* { dg-options "-ffast-math" } */ + +/* These are helper macros to test combinations of functions. We test + foo() != foo() with the same arguments, and expect the compiler to + optimize away these tests of const functions. */ + +/* Just test the __builtin_ functions. */ +#define BUILTIN_TEST1(FN, TYPE) \ +extern void link_failure_builtin_##FN(void); \ +void test_builtin_##FN(TYPE x) \ +{ if (__builtin_##FN(x) != __builtin_##FN(x)) link_failure_builtin_##FN(); } + +/* Just test the __builtin_ functions. */ +#define BUILTIN_TEST2(FN, TYPE) \ +extern void link_failure_builtin_##FN(void); \ +void test_builtin_##FN(TYPE x, TYPE y) \ +{ if (__builtin_##FN(x,y) != __builtin_##FN(x,y)) link_failure_builtin_##FN(); } + +/* Also test the regular (non-__builtin_) function. */ +#define TEST1(FN, TYPE, RTYPE) \ +BUILTIN_TEST1(FN, TYPE) \ +extern void link_failure_##FN(void); \ +extern RTYPE FN(TYPE); \ +void test_##FN(TYPE x) { if (FN(x) != FN(x)) link_failure_##FN(); } + +/* Test the __builtin_ functions taking void arguments (with the "f" + and "l" variants). */ +#define BUILTIN_FPTEST0(FN) \ +extern void link_failure_builtin_##FN(void); \ +extern void link_failure_builtin_##FN##f(void); \ +extern void link_failure_builtin_##FN##l(void); \ +void test_builtin_##FN(void) \ +{ if (__builtin_##FN() != __builtin_##FN()) link_failure_builtin_##FN(); } \ +void test_builtin_##FN##f(void) \ +{ if (__builtin_##FN##f() != __builtin_##FN##f()) link_failure_builtin_##FN##f(); } \ +void test_builtin_##FN##l(void) \ +{ if (__builtin_##FN##l() != __builtin_##FN##l()) link_failure_builtin_##FN##l(); } + +/* Test the __builtin_ functions taking one FP argument (with the "f" + and "l" variants). */ +#define BUILTIN_FPTEST1(FN) \ +extern void link_failure_builtin_##FN(void); \ +extern void link_failure_builtin_##FN##f(void); \ +extern void link_failure_builtin_##FN##l(void); \ +void test_builtin_##FN(double d) \ +{ if (__builtin_##FN(d) != __builtin_##FN(d)) link_failure_builtin_##FN(); } \ +void test_builtin_##FN##f(float f) \ +{ if (__builtin_##FN##f(f) != __builtin_##FN##f(f)) link_failure_builtin_##FN##f(); } \ +void test_builtin_##FN##l(long double ld) \ +{ if (__builtin_##FN##l(ld) != __builtin_##FN##l(ld)) link_failure_builtin_##FN##l(); } + +/* Test the __builtin_ functions taking one argument of supplied type + (with the "f" and "l" variants). */ +#define BUILTIN_FPTEST1ARG(FN, TYPE) \ +extern void link_failure_builtin_##FN(void); \ +extern void link_failure_builtin_##FN##f(void); \ +extern void link_failure_builtin_##FN##l(void); \ +void test_builtin_##FN(TYPE x) \ +{ if (__builtin_##FN(x) != __builtin_##FN(x)) link_failure_builtin_##FN(); } \ +void test_builtin_##FN##f(TYPE x) \ +{ if (__builtin_##FN##f(x) != __builtin_##FN##f(x)) link_failure_builtin_##FN##f(); } \ +void test_builtin_##FN##l(TYPE x) \ +{ if (__builtin_##FN##l(x) != __builtin_##FN##l(x)) link_failure_builtin_##FN##l(); } + +/* Test the __builtin_ functions taking two FP arguments (with the "f" + and "l" variants). */ +#define BUILTIN_FPTEST2(FN) \ +extern void link_failure_builtin_##FN(void); \ +extern void link_failure_builtin_##FN##f(void); \ +extern void link_failure_builtin_##FN##l(void); \ +void test_builtin_##FN(double d1, double d2) \ +{ if (__builtin_##FN(d1,d2) != __builtin_##FN(d1,d2)) link_failure_builtin_##FN(); } \ +void test_builtin_##FN##f(float f1, float f2) \ +{ if (__builtin_##FN##f(f1,f2) != __builtin_##FN##f(f1,f2)) link_failure_builtin_##FN##f(); } \ +void test_builtin_##FN##l(long double ld1, long double ld2) \ +{ if (__builtin_##FN##l(ld1,ld2) != __builtin_##FN##l(ld1,ld2)) link_failure_builtin_##FN##l(); } + +/* Test the __builtin_ functions taking two arguments, the first one + is of a supplied type and the second one one is of FP type (with + the "f" and "l" variants). */ +#define BUILTIN_FPTEST2ARG1(FN, TYPE) \ +extern void link_failure_builtin_##FN(void); \ +extern void link_failure_builtin_##FN##f(void); \ +extern void link_failure_builtin_##FN##l(void); \ +void test_builtin_##FN(TYPE x, double d) \ +{ if (__builtin_##FN(x,d) != __builtin_##FN(x,d)) link_failure_builtin_##FN(); } \ +void test_builtin_##FN##f(TYPE x, float f) \ +{ if (__builtin_##FN##f(x,f) != __builtin_##FN##f(x,f)) link_failure_builtin_##FN##f(); } \ +void test_builtin_##FN##l(TYPE x, long double ld) \ +{ if (__builtin_##FN##l(x,ld) != __builtin_##FN##l(x,ld)) link_failure_builtin_##FN##l(); } + +/* Test the __builtin_ functions taking two arguments, the first one + is of FP type and the second one one is of a supplied type (with + the "f" and "l" variants). */ +#define BUILTIN_FPTEST2ARG2(FN, TYPE) \ +extern void link_failure_builtin_##FN(void); \ +extern void link_failure_builtin_##FN##f(void); \ +extern void link_failure_builtin_##FN##l(void); \ +void test_builtin_##FN(double d, TYPE x) \ +{ if (__builtin_##FN(d,x) != __builtin_##FN(d,x)) link_failure_builtin_##FN(); } \ +void test_builtin_##FN##f(float f, TYPE x) \ +{ if (__builtin_##FN##f(f,x) != __builtin_##FN##f(f,x)) link_failure_builtin_##FN##f(); } \ +void test_builtin_##FN##l(long double ld, TYPE x) \ +{ if (__builtin_##FN##l(ld,x) != __builtin_##FN##l(ld,x)) link_failure_builtin_##FN##l(); } + +/* Test the __builtin_ functions taking three FP arguments (with the + "f" and "l" variants). */ +#define BUILTIN_FPTEST3(FN) \ +extern void link_failure_builtin_##FN(void); \ +extern void link_failure_builtin_##FN##f(void); \ +extern void link_failure_builtin_##FN##l(void); \ +void test_builtin_##FN(double d1, double d2, double d3) \ +{ if (__builtin_##FN(d1,d2,d3) != __builtin_##FN(d1,d2,d3)) link_failure_builtin_##FN(); } \ +void test_builtin_##FN##f(float f1, float f2, float f3) \ +{ if (__builtin_##FN##f(f1,f2,f3) != __builtin_##FN##f(f1,f2,f3)) link_failure_builtin_##FN##f(); } \ +void test_builtin_##FN##l(long double ld1, long double ld2, long double ld3) \ +{ if (__builtin_##FN##l(ld1,ld2,ld3) != __builtin_##FN##l(ld1,ld2,ld3)) link_failure_builtin_##FN##l(); } + +/* Test the __builtin_ functions taking one complex argument (with the + "f" and "l" variants). */ +#define BUILTIN_CPTEST1(FN) \ +extern void link_failure_builtin_##FN(void); \ +extern void link_failure_builtin_##FN##f(void); \ +extern void link_failure_builtin_##FN##l(void); \ +void test_builtin_##FN(_Complex double d) \ +{ if (__builtin_##FN(d) != __builtin_##FN(d)) link_failure_builtin_##FN(); } \ +void test_builtin_##FN##f(_Complex float f) \ +{ if (__builtin_##FN##f(f) != __builtin_##FN##f(f)) link_failure_builtin_##FN##f(); } \ +void test_builtin_##FN##l(_Complex long double ld) \ +{ if (__builtin_##FN##l(ld) != __builtin_##FN##l(ld)) link_failure_builtin_##FN##l(); } + +/* Test the __builtin_ functions taking two complex arguments (with + the "f" and "l" variants). */ +#define BUILTIN_CPTEST2(FN) \ +extern void link_failure_builtin_##FN(void); \ +extern void link_failure_builtin_##FN##f(void); \ +extern void link_failure_builtin_##FN##l(void); \ +void test_builtin_##FN(_Complex double d1, _Complex double d2) \ +{ if (__builtin_##FN(d1,d2) != __builtin_##FN(d1,d2)) link_failure_builtin_##FN(); } \ +void test_builtin_##FN##f(_Complex float f1, _Complex float f2) \ +{ if (__builtin_##FN##f(f1,f2) != __builtin_##FN##f(f1,f2)) link_failure_builtin_##FN##f(); } \ +void test_builtin_##FN##l(_Complex long double ld1, _Complex long double ld2) \ +{ if (__builtin_##FN##l(ld1,ld2) != __builtin_##FN##l(ld1,ld2)) link_failure_builtin_##FN##l(); } + +/* These macros additionally test the non-__builtin_ functions. */ + +/* Test the functions taking one FP argument (with the "f" and "l" + variants) and returning that type. */ +#define FPTEST1(FN) \ +BUILTIN_FPTEST1(FN) \ +extern void link_failure_##FN(void); \ +extern void link_failure_##FN##f(void); \ +extern void link_failure_##FN##l(void); \ +extern double FN(double); \ +extern float FN##f(float); \ +extern long double FN##l(long double); \ +void test_##FN(double d) \ +{ if (FN(d) != FN(d)) link_failure_##FN(); } \ +void test_##FN##f(float f) \ +{ if (FN##f(f) != FN##f(f)) link_failure_##FN##f(); } \ +void test_##FN##l(long double ld) \ +{ if (FN##l(ld) != FN##l(ld)) link_failure_##FN##l(); } + +/* Test the functions taking one FP argument (with the "f" and "l" + variants) and returning TYPE. */ +#define FPTEST1T(FN, TYPE) \ +BUILTIN_FPTEST1(FN) \ +extern void link_failure_##FN(void); \ +extern void link_failure_##FN##f(void); \ +extern void link_failure_##FN##l(void); \ +extern TYPE FN(double); \ +extern TYPE FN##f(float); \ +extern TYPE FN##l(long double); \ +void test_##FN(double d) \ +{ if (FN(d) != FN(d)) link_failure_##FN(); } \ +void test_##FN##f(float f) \ +{ if (FN##f(f) != FN##f(f)) link_failure_##FN##f(); } \ +void test_##FN##l(long double ld) \ +{ if (FN##l(ld) != FN##l(ld)) link_failure_##FN##l(); } + +/* Test the functions taking two FP arguments (with the "f" and "l" + variants). */ +#define FPTEST2(FN) \ +BUILTIN_FPTEST2(FN) \ +extern void link_failure_##FN(void); \ +extern void link_failure_##FN##f(void); \ +extern void link_failure_##FN##l(void); \ +extern double FN(double, double); \ +extern float FN##f(float, float); \ +extern long double FN##l(long double, long double); \ +void test_##FN(double d1, double d2) \ +{ if (FN(d1,d2) != FN(d1,d2)) link_failure_##FN(); } \ +void test_##FN##f(float f1, float f2) \ +{ if (FN##f(f1,f2) != FN##f(f1,f2)) link_failure_##FN##f(); } \ +void test_##FN##l(long double ld1, long double ld2) \ +{ if (FN##l(ld1,ld2) != FN##l(ld1,ld2)) link_failure_##FN##l(); } + +/* Test the functions taking two arguments, the first one is of a + supplied type and the second one one is of FP type (with the "f" + and "l" variants). */ +#define FPTEST2ARG1(FN, TYPE) \ +BUILTIN_FPTEST2ARG1(FN, TYPE) \ +extern void link_failure_##FN(void); \ +extern void link_failure_##FN##f(void); \ +extern void link_failure_##FN##l(void); \ +extern double FN(TYPE, double); \ +extern float FN##f(TYPE, float); \ +extern long double FN##l(TYPE, long double); \ +void test_##FN(TYPE x, double d) \ +{ if (FN(x,d) != FN(x,d)) link_failure_##FN(); } \ +void test_##FN##f(TYPE x, float f) \ +{ if (FN##f(x,f) != FN##f(x,f)) link_failure_##FN##f(); } \ +void test_##FN##l(TYPE x, long double ld) \ +{ if (FN##l(x,ld) != FN##l(x,ld)) link_failure_##FN##l(); } + +/* Test the functions taking two arguments, the first one is of FP + type and the second one one is of a supplied type (with the "f" and + "l" variants). */ +#define FPTEST2ARG2(FN, TYPE) \ +BUILTIN_FPTEST2ARG2(FN, TYPE) \ +extern void link_failure_##FN(void); \ +extern void link_failure_##FN##f(void); \ +extern void link_failure_##FN##l(void); \ +extern double FN(double, TYPE); \ +extern float FN##f(float, TYPE); \ +extern long double FN##l(long double, TYPE); \ +void test_##FN(double d, TYPE x) \ +{ if (FN(d,x) != FN(d,x)) link_failure_##FN(); } \ +void test_##FN##f(float f, TYPE x) \ +{ if (FN##f(f,x) != FN##f(f,x)) link_failure_##FN##f(); } \ +void test_##FN##l(long double ld, TYPE x) \ +{ if (FN##l(ld,x) != FN##l(ld,x)) link_failure_##FN##l(); } + +/* Test the functions taking three FP arguments (with the "f" and "l" + variants). */ +#define FPTEST3(FN) \ +BUILTIN_FPTEST3(FN) \ +extern void link_failure_##FN(void); \ +extern void link_failure_##FN##f(void); \ +extern void link_failure_##FN##l(void); \ +extern double FN(double, double, double); \ +extern float FN##f(float, float, float); \ +extern long double FN##l(long double, long double, long double); \ +void test_##FN(double d1, double d2, double d3) \ +{ if (FN(d1,d2,d3) != FN(d1,d2,d3)) link_failure_##FN(); } \ +void test_##FN##f(float f1, float f2, float f3) \ +{ if (FN##f(f1,f2,f3) != FN##f(f1,f2,f3)) link_failure_##FN##f(); } \ +void test_##FN##l(long double ld1, long double ld2, long double ld3) \ +{ if (FN##l(ld1,ld2,ld3) != FN##l(ld1,ld2,ld3)) link_failure_##FN##l(); } + +/* Test the functions taking one complex argument (with the "f" and + "l" variants) and returning that type. */ +#define CPTEST1(FN) \ +BUILTIN_CPTEST1(FN) \ +extern void link_failure_##FN(void); \ +extern void link_failure_##FN##f(void); \ +extern void link_failure_##FN##l(void); \ +extern _Complex double FN(_Complex double); \ +extern _Complex float FN##f(_Complex float); \ +extern _Complex long double FN##l(_Complex long double); \ +void test_##FN(_Complex double d) \ +{ if (FN(d) != FN(d)) link_failure_##FN(); } \ +void test_##FN##f(_Complex float f) \ +{ if (FN##f(f) != FN##f(f)) link_failure_##FN##f(); } \ +void test_##FN##l(_Complex long double ld) \ +{ if (FN##l(ld) != FN##l(ld)) link_failure_##FN##l(); } + +/* Test the functions taking one complex argument (with the "f" and + "l" variants) and returning the real type. */ +#define CPTEST1R(FN) \ +BUILTIN_CPTEST1(FN) \ +extern void link_failure_##FN(void); \ +extern void link_failure_##FN##f(void); \ +extern void link_failure_##FN##l(void); \ +extern double FN(_Complex double); \ +extern float FN##f(_Complex float); \ +extern long double FN##l(_Complex long double); \ +void test_##FN(_Complex double d) \ +{ if (FN(d) != FN(d)) link_failure_##FN(); } \ +void test_##FN##f(_Complex float f) \ +{ if (FN##f(f) != FN##f(f)) link_failure_##FN##f(); } \ +void test_##FN##l(_Complex long double ld) \ +{ if (FN##l(ld) != FN##l(ld)) link_failure_##FN##l(); } + +/* Test the functions taking two complex arguments (with the "f" and + "l" variants). */ +#define CPTEST2(FN) \ +BUILTIN_CPTEST2(FN) \ +extern void link_failure_##FN(void); \ +extern void link_failure_##FN##f(void); \ +extern void link_failure_##FN##l(void); \ +extern _Complex double FN(_Complex double, _Complex double); \ +extern _Complex float FN##f(_Complex float, _Complex float); \ +extern _Complex long double FN##l(_Complex long double, _Complex long double); \ +void test_##FN(_Complex double d1, _Complex double d2) \ +{ if (FN(d1,d2) != FN(d1,d2)) link_failure_##FN(); } \ +void test_##FN##f(_Complex float f1, _Complex float f2) \ +{ if (FN##f(f1,f2) != FN##f(f1,f2)) link_failure_##FN##f(); } \ +void test_##FN##l(_Complex long double ld1, _Complex long double ld2) \ +{ if (FN##l(ld1,ld2) != FN##l(ld1,ld2)) link_failure_##FN##l(); } + + +/* Test the math builtins. */ +FPTEST1 (acos) +FPTEST1 (acosh) +FPTEST1 (asin) +FPTEST1 (asinh) +FPTEST1 (atan) +FPTEST2 (atan2) +FPTEST1 (atanh) +FPTEST1 (cbrt) +FPTEST1 (ceil) +FPTEST2 (copysign) +FPTEST1 (cos) +FPTEST1 (cosh) +FPTEST2 (drem) +FPTEST1 (erf) +FPTEST1 (erfc) +FPTEST1 (exp) +FPTEST1 (exp10) +FPTEST1 (exp2) +FPTEST1 (expm1) +FPTEST1 (fabs) +FPTEST2 (fdim) +FPTEST1 (floor) +FPTEST3 (fma) +FPTEST2 (fmax) +FPTEST2 (fmin) +FPTEST2 (fmod) +BUILTIN_FPTEST0 (huge_val) +FPTEST2 (hypot) +FPTEST1T (ilogb, int) +BUILTIN_FPTEST0 (inf) /* { dg-warning "does not support infinity" "INF unsupported" { target vax-*-* pdp11-*-* spu-*-* } } */ +FPTEST1 (j0) +FPTEST1 (j1) +FPTEST2ARG1 (jn, int) +FPTEST2ARG2 (ldexp, int) +BUILTIN_FPTEST1 (llceil) +BUILTIN_FPTEST1 (llfloor) +FPTEST1T (llrint, long long) +FPTEST1T (llround, long long) +FPTEST1 (log) +FPTEST1 (log10) +FPTEST1 (log1p) +FPTEST1 (log2) +FPTEST1 (logb) +BUILTIN_FPTEST1 (lceil) +BUILTIN_FPTEST1 (lfloor) +FPTEST1T (lrint, long) +FPTEST1T (lround, long) +BUILTIN_FPTEST1ARG (nan, char *) +BUILTIN_FPTEST1ARG (nans, char *) +FPTEST1 (nearbyint) +FPTEST2 (nextafter) +FPTEST2ARG2 (nexttoward, long double) +FPTEST2 (pow) +FPTEST1 (pow10) +FPTEST2 (remainder) +FPTEST1 (rint) +FPTEST1 (round) +FPTEST2 (scalb) +FPTEST2ARG2 (scalbn, int) +FPTEST2ARG2 (scalbln, long int) +FPTEST1 (significand) +FPTEST1 (sin) +FPTEST1 (sinh) +FPTEST1 (sqrt) +FPTEST1 (tan) +FPTEST1 (tanh) +FPTEST1 (tgamma) +FPTEST1 (trunc) +FPTEST1 (y0) +FPTEST1 (y1) +FPTEST2ARG1 (yn, int) + +/* Test the complex math builtins. */ +/*CPTEST1 (cabs) See http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00040.html */ +CPTEST1 (cacos) +CPTEST1 (cacosh) +CPTEST1R (carg) +CPTEST1 (casin) +CPTEST1 (casinh) +CPTEST1 (catan) +CPTEST1 (catanh) +CPTEST1 (ccos) +CPTEST1 (ccosh) +CPTEST1 (cexp) +CPTEST1R (cimag) +CPTEST1 (clog) +CPTEST1 (conj) +CPTEST2 (cpow) +CPTEST1 (cproj) +CPTEST1R (creal) +CPTEST1 (csin) +CPTEST1 (csinh) +CPTEST1 (csqrt) +CPTEST1 (ctan) +CPTEST1 (ctanh) + +typedef __INTMAX_TYPE__ intmax_t; + +/* Various other const builtins. */ +TEST1 (abs, int, int) +BUILTIN_TEST1 (clz, int) +BUILTIN_TEST1 (clzl, long) +BUILTIN_TEST1 (clzll, long long) +BUILTIN_TEST1 (ctz, int) +BUILTIN_TEST1 (ctzl, long) +BUILTIN_TEST1 (ctzll, long long) +BUILTIN_TEST1 (clrsb, int) +BUILTIN_TEST1 (clrsbl, long) +BUILTIN_TEST1 (clrsbll, long long) +TEST1 (ffs, int, int) +TEST1 (ffsl, long, int) +TEST1 (ffsll, long long, int) +TEST1 (imaxabs, intmax_t, intmax_t) +TEST1 (labs, long, long) +TEST1 (llabs, long long, long long) +BUILTIN_TEST1 (parity, int) +BUILTIN_TEST1 (parityl, long) +BUILTIN_TEST1 (parityll, long long) +BUILTIN_TEST1 (popcount, int) +BUILTIN_TEST1 (popcountl, long) +BUILTIN_TEST1 (popcountll, long long) + +int main(void) +{ + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-complex-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-complex-1.c new file mode 100644 index 000000000..0d26c9cc7 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-complex-1.c @@ -0,0 +1,124 @@ +/* Test __builtin_complex semantics. */ +/* { dg-do run } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ +/* { dg-add-options ieee } */ + +extern void exit (int); +extern void abort (void); + +#define COMPARE_BODY(A, B, TYPE, COPYSIGN) \ + do { \ + TYPE s1 = COPYSIGN ((TYPE) 1.0, A); \ + TYPE s2 = COPYSIGN ((TYPE) 1.0, B); \ + if (s1 != s2) \ + abort (); \ + if ((__builtin_isnan (A) != 0) != (__builtin_isnan (B) != 0)) \ + abort (); \ + if ((A != B) != (__builtin_isnan (A) != 0)) \ + abort (); \ + } while (0) + +#ifndef __SPU__ +void +comparef (float a, float b) +{ + COMPARE_BODY (a, b, float, __builtin_copysignf); +} +#endif + +void +compare (double a, double b) +{ + COMPARE_BODY (a, b, double, __builtin_copysign); +} + +void +comparel (long double a, long double b) +{ + COMPARE_BODY (a, b, long double, __builtin_copysignl); +} + +#ifndef __SPU__ +void +comparecf (_Complex float a, float r, float i) +{ + comparef (__real__ a, r); + comparef (__imag__ a, i); +} +#endif + +void +comparec (_Complex double a, double r, double i) +{ + compare (__real__ a, r); + compare (__imag__ a, i); +} + +void +comparecl (_Complex long double a, long double r, long double i) +{ + comparel (__real__ a, r); + comparel (__imag__ a, i); +} + +#define VERIFY(A, B, TYPE, COMPARE) \ + do { \ + TYPE a = A; \ + TYPE b = B; \ + _Complex TYPE cr = __builtin_complex (a, b); \ + static _Complex TYPE cs = __builtin_complex (A, B); \ + COMPARE (cr, A, B); \ + COMPARE (cs, A, B); \ + } while (0) + +#define ALL_CHECKS(PZ, NZ, NAN, INF, TYPE, COMPARE) \ + do { \ + VERIFY (PZ, PZ, TYPE, COMPARE); \ + VERIFY (PZ, NZ, TYPE, COMPARE); \ + VERIFY (PZ, NAN, TYPE, COMPARE); \ + VERIFY (PZ, INF, TYPE, COMPARE); \ + VERIFY (NZ, PZ, TYPE, COMPARE); \ + VERIFY (NZ, NZ, TYPE, COMPARE); \ + VERIFY (NZ, NAN, TYPE, COMPARE); \ + VERIFY (NZ, INF, TYPE, COMPARE); \ + VERIFY (NAN, PZ, TYPE, COMPARE); \ + VERIFY (NAN, NZ, TYPE, COMPARE); \ + VERIFY (NAN, NAN, TYPE, COMPARE); \ + VERIFY (NAN, INF, TYPE, COMPARE); \ + VERIFY (INF, PZ, TYPE, COMPARE); \ + VERIFY (INF, NZ, TYPE, COMPARE); \ + VERIFY (INF, NAN, TYPE, COMPARE); \ + VERIFY (INF, INF, TYPE, COMPARE); \ + } while (0) + +void +check_float (void) +{ +#ifndef __SPU__ + ALL_CHECKS (0.0f, -0.0f, __builtin_nanf(""), __builtin_inff(), + float, comparecf); +#endif +} + +void +check_double (void) +{ + ALL_CHECKS (0.0, -0.0, __builtin_nan(""), __builtin_inf(), + double, comparec); +} + +void +check_long_double (void) +{ + ALL_CHECKS (0.0l, -0.0l, __builtin_nanl(""), __builtin_infl(), + long double, comparecl); +} + +int +main (void) +{ + check_float (); + check_double (); + check_long_double (); + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-convert-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-convert-1.c new file mode 100644 index 000000000..f13d29e67 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-convert-1.c @@ -0,0 +1,149 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Verify that built-in math function conversion to smaller FP types + is correctly performed by the compiler. + + Written by Kaveh Ghazi, 2004-03-17. */ + +/* { dg-do link } */ +/* { dg-options "-ffast-math" } */ +/* { dg-add-options c99_runtime } */ + +#include "../builtins-config.h" + +/* This check is necessary when converting to a C99 function. */ +#ifdef HAVE_C99_RUNTIME +#define C99CODE(CODE) (CODE) +#define MAYBEC99(CODE, C99) (CODE) +#else +#define C99CODE(CODE) 0 +#define MAYBEC99(CODE, C99) (!(C99) && (CODE)) +#endif + +void test(double d1, float f1, long double ld1) +{ + /* Test converting math builtins to narrower FP types based on a + narrowing cast on the outside of the call. MATHFN is the + function to test, and C99 is 0/1 depending on whether the + `double' version of MATHFN is a C99 function. The optimization + is only performed if the replacement function is actually + narrower in width, so check that first. */ +#define OUTER_CAST1(MATHFN, C99) \ + extern void link_failure_outer_##MATHFN##l_##MATHFN##_1(void); \ + extern void link_failure_outer_##MATHFN##l_##MATHFN##_2(void); \ + extern void link_failure_outer_##MATHFN##l_##MATHFN##f_1(void); \ + extern void link_failure_outer_##MATHFN##l_##MATHFN##f_2(void); \ + extern void link_failure_outer_##MATHFN##_##MATHFN##f_1(void); \ + extern void link_failure_outer_##MATHFN##_##MATHFN##f_2(void); \ + if (sizeof (long double) > sizeof (double) \ + && MAYBEC99 ((double) __builtin_##MATHFN##l((double)ld1) != __builtin_##MATHFN(ld1), C99)) \ + link_failure_outer_##MATHFN##l_##MATHFN##_1(); \ + if (sizeof (long double) > sizeof (double) \ + && MAYBEC99 ((double) __builtin_##MATHFN##l(d1) != __builtin_##MATHFN(d1), C99)) \ + link_failure_outer_##MATHFN##l_##MATHFN##_1(); \ + if (sizeof (long double) > sizeof (double) \ + && MAYBEC99 ((double) __builtin_##MATHFN##l(f1) != __builtin_##MATHFN(f1), C99)) \ + link_failure_outer_##MATHFN##l_##MATHFN##_2(); \ + if (sizeof (long double) > sizeof (float) \ + && C99CODE ((float) __builtin_##MATHFN##l((float) ld1) != __builtin_##MATHFN##f(ld1))) \ + link_failure_outer_##MATHFN##l_##MATHFN##f_1(); \ + if (sizeof (long double) > sizeof (float) \ + && C99CODE ((float) __builtin_##MATHFN##l((float) d1) != __builtin_##MATHFN##f(d1))) \ + link_failure_outer_##MATHFN##l_##MATHFN##f_1(); \ + if (sizeof (long double) > sizeof (float) \ + && C99CODE ((float) __builtin_##MATHFN##l(f1) != __builtin_##MATHFN##f(f1))) \ + link_failure_outer_##MATHFN##l_##MATHFN##f_2(); \ + if (sizeof (double) > sizeof (float) \ + && C99CODE ((float) __builtin_##MATHFN((float) ld1) != __builtin_##MATHFN##f(ld1))) \ + link_failure_outer_##MATHFN##_##MATHFN##f_1(); \ + if (sizeof (double) > sizeof (float) \ + && C99CODE ((float) __builtin_##MATHFN((float) d1) != __builtin_##MATHFN##f(d1))) \ + link_failure_outer_##MATHFN##_##MATHFN##f_1(); \ + if (sizeof (double) > sizeof (float) \ + && C99CODE ((float) __builtin_##MATHFN(f1) != __builtin_##MATHFN##f(f1))) \ + link_failure_outer_##MATHFN##_##MATHFN##f_2() + + /* Test converting math builtins to narrower FP types based on if + the argument is a narrower type (perhaps implicitly) cast to a + wider one. */ +#define INNER_CAST1(MATHFN, C99) \ + extern void link_failure_inner_##MATHFN##l_##MATHFN(void); \ + extern void link_failure_inner_##MATHFN##l_##MATHFN##f(void); \ + extern void link_failure_inner_##MATHFN##_##MATHFN##f(void); \ + if (sizeof (long double) > sizeof (double) \ + && MAYBEC99 (__builtin_##MATHFN##l(d1) != (long double) __builtin_##MATHFN(d1), C99)) \ + link_failure_inner_##MATHFN##l_##MATHFN(); \ + if (sizeof (long double) > sizeof (float) \ + && C99CODE (__builtin_##MATHFN##l(f1) != (long double) __builtin_##MATHFN##f(f1))) \ + link_failure_inner_##MATHFN##l_##MATHFN##f(); \ + if (sizeof (long double) > sizeof (float) \ + && C99CODE (__builtin_##MATHFN##l((double)f1) != (long double) __builtin_##MATHFN##f(f1))) \ + link_failure_inner_##MATHFN##l_##MATHFN##f(); \ + if (sizeof (double) > sizeof (float) \ + && C99CODE (__builtin_##MATHFN(f1) != (double) __builtin_##MATHFN##f(f1))) \ + link_failure_inner_##MATHFN##_##MATHFN##f() + + +#ifdef __OPTIMIZE__ + OUTER_CAST1 (acos, /*C99=*/ 0); + OUTER_CAST1 (acosh, /*C99=*/ 1); + OUTER_CAST1 (asin, /*C99=*/ 1); + OUTER_CAST1 (asinh, /*C99=*/ 1); + OUTER_CAST1 (atan, /*C99=*/ 0); + OUTER_CAST1 (atanh, /*C99=*/ 1); + OUTER_CAST1 (cbrt, /*C99=*/ 1); + OUTER_CAST1 (cos, /*C99=*/ 0); + OUTER_CAST1 (cosh, /*C99=*/ 0); + OUTER_CAST1 (erf, /*C99=*/ 1); + OUTER_CAST1 (erfc, /*C99=*/ 1); + OUTER_CAST1 (exp, /*C99=*/ 0); + OUTER_CAST1 (exp2, /*C99=*/ 1); + OUTER_CAST1 (expm1, /*C99=*/ 1); + OUTER_CAST1 (fabs, /*C99=*/ 0); + OUTER_CAST1 (log, /*C99=*/ 0); + OUTER_CAST1 (log10, /*C99=*/ 0); + OUTER_CAST1 (log1p, /*C99=*/ 1); + OUTER_CAST1 (log2, /*C99=*/ 1); + OUTER_CAST1 (logb, /*C99=*/ 1); + OUTER_CAST1 (sin, /*C99=*/ 0); + OUTER_CAST1 (sinh, /*C99=*/ 0); + OUTER_CAST1 (sqrt, /*C99=*/ 0); + OUTER_CAST1 (tan, /*C99=*/ 0); + OUTER_CAST1 (tanh, /*C99=*/ 0); + OUTER_CAST1 (tgamma, /*C99=*/ 1); + + INNER_CAST1 (ceil, /*C99=*/ 0); + OUTER_CAST1 (ceil, /*C99=*/ 0); + INNER_CAST1 (floor, /*C99=*/ 0); + OUTER_CAST1 (floor, /*C99=*/ 0); + INNER_CAST1 (lceil, /*C99=*/ 1); + OUTER_CAST1 (lceil, /*C99=*/ 1); + INNER_CAST1 (lfloor, /*C99=*/ 1); + OUTER_CAST1 (lfloor, /*C99=*/ 1); + INNER_CAST1 (lrint, /*C99=*/ 1); + OUTER_CAST1 (lrint, /*C99=*/ 1); + INNER_CAST1 (lround, /*C99=*/ 1); + OUTER_CAST1 (lround, /*C99=*/ 1); + INNER_CAST1 (llceil, /*C99=*/ 1); + OUTER_CAST1 (llceil, /*C99=*/ 1); + INNER_CAST1 (llfloor, /*C99=*/ 1); + OUTER_CAST1 (llfloor, /*C99=*/ 1); + INNER_CAST1 (llrint, /*C99=*/ 1); + OUTER_CAST1 (llrint, /*C99=*/ 1); + INNER_CAST1 (llround, /*C99=*/ 1); + OUTER_CAST1 (llround, /*C99=*/ 1); + INNER_CAST1 (nearbyint, /*C99=*/ 1); + OUTER_CAST1 (nearbyint, /*C99=*/ 1); + INNER_CAST1 (rint, /*C99=*/ 1); + OUTER_CAST1 (rint, /*C99=*/ 1); + INNER_CAST1 (round, /*C99=*/ 1); + OUTER_CAST1 (round, /*C99=*/ 1); + INNER_CAST1 (trunc, /*C99=*/ 1); + OUTER_CAST1 (trunc, /*C99=*/ 1); +#endif /* __OPTIMIZE__ */ +} + +int main (void) +{ + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-convert-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-convert-2.c new file mode 100644 index 000000000..167ecddcb --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-convert-2.c @@ -0,0 +1,78 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Verify that built-in math function conversion into integer rounding + functions is correctly performed by the compiler. + + Written by Kaveh ghazi, 2004-04-26. */ + +/* { dg-do link } */ +/* { dg-options "-ffast-math" } */ +/* { dg-add-options c99_runtime } */ + +#include "../builtins-config.h" + +/* Macro to do all FP type combinations. The second half tests + narrowing the FP type. */ +#define TEST_FP2FIXED(FN1, FN2) \ + extern void link_error_##FN1##_##FN2(void); \ + extern void link_error_##FN1##f_##FN2##f(void); \ + extern void link_error_##FN1##l_##FN2##l(void); \ + extern void link_error_##FN1##_l##FN2(void); \ + extern void link_error_##FN1##f_l##FN2##f(void); \ + extern void link_error_##FN1##l_l##FN2##l(void); \ + if ((long)__builtin_##FN1(d) != __builtin_##FN2(d)) \ + link_error_##FN1##_##FN2(); \ + if ((long)__builtin_##FN1##f(f) != __builtin_##FN2##f(f)) \ + link_error_##FN1##f_##FN2##f(); \ + if ((long)__builtin_##FN1##l(ld) != __builtin_##FN2##l(ld)) \ + link_error_##FN1##l_##FN2##l(); \ + if ((long long)__builtin_##FN1(d) != __builtin_l##FN2(d)) \ + link_error_##FN1##_l##FN2(); \ + if ((long long)__builtin_##FN1##f(f) != __builtin_l##FN2##f(f)) \ + link_error_##FN1##f_l##FN2##f(); \ + if ((long long)__builtin_##FN1##l(ld) != __builtin_l##FN2##l(ld)) \ + link_error_##FN1##l_l##FN2##l(); \ + extern void link_error_##FN1##_##FN2##f(void); \ + extern void link_error_##FN1##l_##FN2(void); \ + extern void link_error_##FN1##l_##FN2##f(void); \ + extern void link_error_##FN1##_l##FN2##f(void); \ + extern void link_error_##FN1##l_l##FN2(void); \ + extern void link_error_##FN1##l_l##FN2##f(void); \ + if (sizeof(double) > sizeof(float) \ + && (long)__builtin_##FN1(f) != __builtin_##FN2##f(f)) \ + link_error_##FN1##_##FN2##f(); \ + if (sizeof(long double) > sizeof(double) \ + && (long)__builtin_##FN1##l(d) != __builtin_##FN2(d)) \ + link_error_##FN1##l_##FN2(); \ + if (sizeof(long double) > sizeof(float) \ + && (long)__builtin_##FN1##l(f) != __builtin_##FN2##f(f)) \ + link_error_##FN1##l_##FN2##f(); \ + if (sizeof(double) > sizeof(float) \ + && (long long)__builtin_##FN1(f) != __builtin_l##FN2##f(f)) \ + link_error_##FN1##_l##FN2##f(); \ + if (sizeof(long double) > sizeof(double) \ + && (long long)__builtin_##FN1##l(d) != __builtin_l##FN2(d)) \ + link_error_##FN1##l_l##FN2(); \ + if (sizeof(long double) > sizeof(float) \ + && (long long)__builtin_##FN1##l(f) != __builtin_l##FN2##f(f)) \ + link_error_##FN1##l_l##FN2##f() + +void __attribute__ ((__noinline__)) foo (double d, float f, long double ld) +{ +#ifdef __OPTIMIZE__ +# ifdef HAVE_C99_RUNTIME + /* The resulting transformation functions are all C99. */ + TEST_FP2FIXED (ceil, lceil); + TEST_FP2FIXED (floor, lfloor); + TEST_FP2FIXED (round, lround); + TEST_FP2FIXED (nearbyint, lrint); + TEST_FP2FIXED (rint, lrint); +# endif +#endif +} + +int main() +{ + foo (1.0, 2.0, 3.0); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-convert-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-convert-3.c new file mode 100644 index 000000000..2034b4190 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-convert-3.c @@ -0,0 +1,61 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Verify that builtin math functions (with fixed point return types) + are converted to smaller FP types correctly by the compiler. + + Written by Kaveh Ghazi, 2004-05-01. */ + +/* { dg-do link } */ +/* { dg-options "-ffast-math" } */ +/* { dg-add-options c99_runtime } */ + +#include "../builtins-config.h" + +#define PROTOTYPE1_RET(FN, RET) \ + extern RET FN(double); \ + extern RET FN##f(float); \ + extern RET FN##l(long double); + +/* Test converting math builtins to narrower FP types based on if the + argument is a narrower type (perhaps implicitly) cast to a wider + one. */ +#define INNER_CAST1(MATHFN, RET) \ + PROTOTYPE1_RET (MATHFN, RET); \ + extern void link_failure_inner_##MATHFN##l_##MATHFN(void); \ + extern void link_failure_inner_##MATHFN##l_##MATHFN##f(void); \ + extern void link_failure_inner_##MATHFN##_##MATHFN##f(void); \ + if (sizeof (long double) > sizeof (double) \ + && MATHFN##l(d1) != MATHFN(d1)) \ + link_failure_inner_##MATHFN##l_##MATHFN(); \ + if (sizeof (long double) > sizeof (float) \ + && MATHFN##l(f1) != MATHFN##f(f1)) \ + link_failure_inner_##MATHFN##l_##MATHFN##f(); \ + if (sizeof (long double) > sizeof (float) \ + && MATHFN##l((double)f1) != MATHFN##f(f1)) \ + link_failure_inner_##MATHFN##l_##MATHFN##f(); \ + if (sizeof (double) > sizeof (float) \ + && MATHFN(f1) != MATHFN##f(f1)) \ + link_failure_inner_##MATHFN##_##MATHFN##f() + +void __attribute__ ((__noinline__)) test (double d1, float f1) +{ +#ifdef __OPTIMIZE__ +#ifdef HAVE_C99_RUNTIME + /* We're converting to implicitly generated C99 functions. */ + INNER_CAST1 (__builtin_lceil, long); + INNER_CAST1 (__builtin_llceil, long long); + INNER_CAST1 (__builtin_lfloor, long); + INNER_CAST1 (__builtin_llfloor, long long); + INNER_CAST1 (lround, long); + INNER_CAST1 (llround, long long); + INNER_CAST1 (lrint, long); + INNER_CAST1 (llrint, long long); +#endif /* HAVE_C99_RUNTIME */ +#endif /* __OPTIMIZE__ */ +} + +int main (void) +{ + test (1, 2); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-convert-4.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-convert-4.c new file mode 100644 index 000000000..3dc47ad1e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-convert-4.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2007 Free Software Foundation. + + Verify that nearbyint isn't transformed into e.g. rint or lrint + when -ftrapping-math is set. + + Written by Kaveh ghazi, 2007-03-04. */ + +/* { dg-do compile } */ +/* { dg-options "-ftrapping-math -fdump-tree-original" } */ +/* { dg-add-options c99_runtime } */ + +#include "../builtins-config.h" + +extern void bar (long); + +#define TESTIT(FUNC) do { \ + bar (__builtin_##FUNC(d)); \ + bar (__builtin_##FUNC##f(f)); \ + bar (__builtin_##FUNC##l(ld)); \ +} while (0) + +void __attribute__ ((__noinline__)) foo (double d, float f, long double ld) +{ + TESTIT(nearbyint); +} + +int main() +{ + foo (1.0, 2.0, 3.0); + return 0; +} + +/* { dg-final { scan-tree-dump-times "nearbyint " 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "nearbyintf" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "nearbyintl" 1 "original" } } */ +/* { dg-final { cleanup-tree-dump "original" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-cproj-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-cproj-1.c new file mode 100644 index 000000000..53ae6046a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-cproj-1.c @@ -0,0 +1,247 @@ +/* Copyright (C) 2010 Free Software Foundation. + + Verify that folding of built-in cproj is correctly performed by the + compiler. + + Origin: Kaveh R. Ghazi, April 9, 2010. */ + +/* { dg-do link } */ +/* { dg-add-options ieee } */ + +/* All references to link_error should go away at compile-time. The + argument is the __LINE__ number. It appears in the tree dump file + and aids in debugging should any of the tests fail. */ +extern void link_error(int); + +#define CPROJ(X) __builtin_cproj(X) +#define CPROJF(X) __builtin_cprojf(X) +#define CPROJL(X) __builtin_cprojl(X) +#ifndef __SPU__ +#define INF __builtin_inff() +#else +#define INF __builtin_inf() +#endif +#define I 1i +#define CPSGN(X,Y) __builtin_copysignf((X),(Y)) +#define CIMAG(X) __builtin_cimagf(X) +#define CREAL(X) __builtin_crealf(X) + +/* Check that the signs of the real and/or imaginary parts of two + complex numbers match. */ +#define CKSGN(X,Y) (CKSGN_R(X,Y) || CKSGN_I(X,Y)) +#define CKSGN_R(X,Y) (CPSGN(1,CREAL(X)) != CPSGN(1,CREAL(Y))) +#define CKSGN_I(X,Y) (CPSGN(1,CIMAG(X)) != CPSGN(1,CIMAG(Y))) + +/* Test that (cproj(X) == ZERO+Inf) and that the signs of the + imaginary parts match. ZERO is +/- 0i. */ +#ifndef __SPU__ +#define TEST_CST_INF(X,ZERO) do { \ + if (CPROJF(X) != ZERO+INF || CKSGN_I(CPROJF(X),ZERO+INF)) \ + link_error(__LINE__); \ + if (CPROJ(X) != ZERO+INF || CKSGN_I(CPROJ(X),ZERO+INF)) \ + link_error(__LINE__); \ + if (CPROJL(X) != ZERO+INF || CKSGN_I(CPROJL(X),ZERO+INF)) \ + link_error(__LINE__); \ +} while (0) +#else +#define TEST_CST_INF(X,ZERO) do { \ + if (CPROJ(X) != ZERO+INF || CKSGN_I(CPROJ(X),ZERO+INF)) \ + link_error(__LINE__); \ + if (CPROJL(X) != ZERO+INF || CKSGN_I(CPROJL(X),ZERO+INF)) \ + link_error(__LINE__); \ +} while (0) +#endif + +/* Test that (cproj(X) == X) for all finite (X). */ +#define TEST_CST(X) do { \ + if (CPROJF(X) != (X) || CKSGN(CPROJF(X),(X))) \ + link_error(__LINE__); \ +} while (0) + +/* Test that cproj(X + I*INF) -> (ZERO + INF), where ZERO is +-0i. + NEG is either blank or a minus sign when ZERO is negative. */ +#ifndef __SPU__ +#define TEST_IMAG_INF(NEG,ZERO) do { \ + if (CPROJF(f+I*NEG INF) != ZERO+INF \ + || CKSGN_I (CPROJF(f+I*NEG INF), ZERO+INF)) \ + link_error(__LINE__); \ + if (CPROJ(d+I*NEG INF) != ZERO+INF \ + || CKSGN_I (CPROJ(d+I*NEG INF), ZERO+INF)) \ + link_error(__LINE__); \ + if (CPROJL(ld+I*NEG INF) != ZERO+INF \ + || CKSGN_I (CPROJL(ld+I*NEG INF), ZERO+INF)) \ + link_error(__LINE__); \ +} while (0) +#else +#define TEST_IMAG_INF(NEG,ZERO) do { \ + if (CPROJ(d+I*NEG INF) != ZERO+INF \ + || CKSGN_I (CPROJ(d+I*NEG INF), ZERO+INF)) \ + link_error(__LINE__); \ + if (CPROJL(ld+I*NEG INF) != ZERO+INF \ + || CKSGN_I (CPROJL(ld+I*NEG INF), ZERO+INF)) \ + link_error(__LINE__); \ +} while (0) +#endif + +/* Like TEST_IMAG_INF, but check that side effects are honored. */ +#ifndef __SPU__ +#define TEST_IMAG_INF_SIDE_EFFECT(NEG,ZERO) do { \ + int side = 4; \ + if (CPROJF(++side+I*NEG INF) != ZERO+INF \ + || CKSGN_I (CPROJF(++side+I*NEG INF), ZERO+INF)) \ + link_error(__LINE__); \ + if (CPROJ(++side+I*NEG INF) != ZERO+INF \ + || CKSGN_I (CPROJ(++side+I*NEG INF), ZERO+INF)) \ + link_error(__LINE__); \ + if (CPROJL(++side+I*NEG INF) != ZERO+INF \ + || CKSGN_I (CPROJL(++side+I*NEG INF), ZERO+INF)) \ + link_error(__LINE__); \ + if (side != 10) \ + link_error(__LINE__); \ +} while (0) +#else +#define TEST_IMAG_INF_SIDE_EFFECT(NEG,ZERO) do { \ + int side = 4; \ + if (CPROJ(++side+I*NEG INF) != ZERO+INF \ + || CKSGN_I (CPROJ(++side+I*NEG INF), ZERO+INF)) \ + link_error(__LINE__); \ + if (CPROJL(++side+I*NEG INF) != ZERO+INF \ + || CKSGN_I (CPROJL(++side+I*NEG INF), ZERO+INF)) \ + link_error(__LINE__); \ + if (side != 8) \ + link_error(__LINE__); \ +} while (0) +#endif + +/* Test that cproj(INF, POSITIVE) -> INF+0i. NEG is either blank or a + minus sign to test negative INF. */ +#ifndef __SPU__ +#define TEST_REAL_INF(NEG) do { \ + __real cf = NEG INF; \ + __imag cf = (x ? 4 : 5); \ + if (CPROJF(cf) != INF \ + || CKSGN_I (CPROJF(cf), INF)) \ + link_error(__LINE__); \ + __real cd = NEG INF; \ + __imag cd = (x ? 4 : 5); \ + if (CPROJ(cd) != INF \ + || CKSGN_I (CPROJ(cd), INF)) \ + link_error(__LINE__); \ + __real cld = NEG INF; \ + __imag cld = (x ? 4 : 5); \ + if (CPROJL(cld) != INF \ + || CKSGN_I (CPROJL(cld), INF)) \ + link_error(__LINE__); \ +} while (0) +#else +#define TEST_REAL_INF(NEG) do { \ + __real cd = NEG INF; \ + __imag cd = (x ? 4 : 5); \ + if (CPROJ(cd) != INF \ + || CKSGN_I (CPROJ(cd), INF)) \ + link_error(__LINE__); \ + __real cld = NEG INF; \ + __imag cld = (x ? 4 : 5); \ + if (CPROJL(cld) != INF \ + || CKSGN_I (CPROJL(cld), INF)) \ + link_error(__LINE__); \ +} while (0) +#endif + +/* Like TEST_REAL_INF, but check that side effects are honored. */ +#ifndef __SPU__ +#define TEST_REAL_INF_SIDE_EFFECT(NEG) do { \ + int side = -9; \ + __real cf = NEG INF; \ + __imag cf = (x ? 4 : 5); \ + if (CPROJF((++side,cf)) != INF \ + || CKSGN_I (CPROJF((++side,cf)), INF)) \ + link_error(__LINE__); \ + __real cd = NEG INF; \ + __imag cd = (x ? 4 : 5); \ + if (CPROJ((++side,cd)) != INF \ + || CKSGN_I (CPROJ((++side,cd)), INF)) \ + link_error(__LINE__); \ + __real cld = NEG INF; \ + __imag cld = (x ? 4 : 5); \ + if (CPROJL((++side,cld)) != INF \ + || CKSGN_I (CPROJL((++side,cld)), INF)) \ + link_error(__LINE__); \ + if (side != -3) \ + link_error(__LINE__); \ +} while (0) +#else +#define TEST_REAL_INF_SIDE_EFFECT(NEG) do { \ + int side = -9; \ + __real cd = NEG INF; \ + __imag cd = (x ? 4 : 5); \ + if (CPROJ((++side,cd)) != INF \ + || CKSGN_I (CPROJ((++side,cd)), INF)) \ + link_error(__LINE__); \ + __real cld = NEG INF; \ + __imag cld = (x ? 4 : 5); \ + if (CPROJL((++side,cld)) != INF \ + || CKSGN_I (CPROJL((++side,cld)), INF)) \ + link_error(__LINE__); \ + if (side != -5) \ + link_error(__LINE__); \ +} while (0) +#endif + +void foo (_Complex long double cld, _Complex double cd, _Complex float cf, + long double ld, double d, float f, int x) +{ + TEST_CST_INF (INF+0I, 0); + TEST_CST_INF (INF-0I, -0.FI); + TEST_CST_INF (INF+4I, 0); + TEST_CST_INF (INF-4I, -0.FI); + TEST_CST_INF (-INF+0I, 0); + TEST_CST_INF (-INF-0I, -0.FI); + TEST_CST_INF (-INF+4I, 0); + TEST_CST_INF (-INF-4I, -0.FI); + + TEST_CST_INF (0+I*INF, 0); + TEST_CST_INF (0-I*INF, -0.FI); + TEST_CST_INF (23+I*INF, 0); + TEST_CST_INF (23-I*INF, -0.FI); + TEST_CST_INF (-0.F+I*INF, 0); + TEST_CST_INF (-0.F-I*INF, -0.FI); + TEST_CST_INF (-23+I*INF, 0); + TEST_CST_INF (-23-I*INF, -0.FI); + + TEST_CST_INF (INF+I*INF, 0); + TEST_CST_INF (INF-I*INF, -0.FI); + TEST_CST_INF (-INF+I*INF, 0); + TEST_CST_INF (-INF-I*INF, -0.FI); + + TEST_CST (0); + TEST_CST (-0.F); + TEST_CST (0-0.FI); + TEST_CST (-0.F-0.FI); + + TEST_CST (22+3I); + TEST_CST (22-3I); + TEST_CST (-22+3I); + TEST_CST (-22-3I); + + TEST_IMAG_INF (,0.FI); + TEST_IMAG_INF (-,-0.FI); + +#ifdef __OPTIMIZE__ + TEST_REAL_INF( ); + TEST_REAL_INF(-); + + TEST_IMAG_INF_SIDE_EFFECT (,0.FI); + TEST_IMAG_INF_SIDE_EFFECT (-,-0.FI); + + TEST_REAL_INF_SIDE_EFFECT( ); + TEST_REAL_INF_SIDE_EFFECT(-); +#endif + + return; +} + +int main (void) +{ + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-cproj-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-cproj-2.c new file mode 100644 index 000000000..39331651f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-cproj-2.c @@ -0,0 +1,46 @@ +/* Copyright (C) 2010 Free Software Foundation. + + Verify that folding of built-in cproj is correctly performed by the + compiler. With -ffinite-math-only all cproj calls should be + eliminated regardless of what the argument is, or what is known + about it. + + Origin: Kaveh R. Ghazi, April 9, 2010. */ + +/* { dg-do link } */ +/* { dg-options "-ffinite-math-only" } */ + +/* All references to link_error should go away at compile-time. The + argument is the __LINE__ number. It appears in the tree dump file + and aids in debugging should any of the tests fail. */ +extern void link_error(int); + +#define CPROJ(X) __builtin_cproj(X) +#define CPROJF(X) __builtin_cprojf(X) +#define CPROJL(X) __builtin_cprojl(X) + +/* Test that the supplied expressions eliminte the cproj call. */ +#define TEST_EXPRS(LD_EXPR, D_EXPR, F_EXPR) do { \ + if (CPROJF(F_EXPR) != (F_EXPR)) \ + link_error (__LINE__); \ + if (CPROJ(D_EXPR) != (D_EXPR)) \ + link_error (__LINE__); \ + if (CPROJL(LD_EXPR) != (LD_EXPR)) \ + link_error (__LINE__); \ +} while (0) + +void foo (_Complex long double cld, _Complex double cd, _Complex float cf) +{ +#ifdef __OPTIMIZE__ + TEST_EXPRS (cld, cd, cf); + TEST_EXPRS (cld*2, cd*2, cf*2); + TEST_EXPRS (cld*cld, cd*cd, cf*cf); +#endif + + return; +} + +int main (void) +{ + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-ctype-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-ctype-1.c new file mode 100644 index 000000000..ad6fc1c60 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-ctype-1.c @@ -0,0 +1,44 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Verify that built-in ctype function attributes are correctly set by + the compiler. + + Written by Kaveh Ghazi, 2004-03-23. */ + +/* { dg-do link } */ + + +void test(int i) +{ + /* All of these ctype functions should be const/pure and thus + eliminated. */ +#define TEST_CTYPE(FN) \ + extern int FN(int); \ + extern void link_failure_##FN(void); \ + if (FN(i) != FN(i)) \ + link_failure_##FN() + +#ifdef __OPTIMIZE__ + TEST_CTYPE(isalnum); + TEST_CTYPE(isalpha); + TEST_CTYPE(isascii); + TEST_CTYPE(isblank); + TEST_CTYPE(iscntrl); + TEST_CTYPE(isdigit); + TEST_CTYPE(isgraph); + TEST_CTYPE(islower); + TEST_CTYPE(isprint); + TEST_CTYPE(ispunct); + TEST_CTYPE(isspace); + TEST_CTYPE(isupper); + TEST_CTYPE(isxdigit); + TEST_CTYPE(toascii); + TEST_CTYPE(tolower); + TEST_CTYPE(toupper); +#endif /* __OPTIMIZE__ */ +} + +int main (void) +{ + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-ctype-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-ctype-2.c new file mode 100644 index 000000000..7046aad65 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-ctype-2.c @@ -0,0 +1,107 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Verify that built-in ctype transformations are done correctly by + the compiler. + + Written by Kaveh Ghazi, 2004-04-05. */ + +/* { dg-do link } */ + +extern void link_failure_var(void); + +void test(int i) +{ + /* All of these ctype calls should compile-time evaluate to true. */ +#define TEST_CTYPE_CST_TRUE(FN, VALUE) \ + extern void link_failure_##FN##_cst_true(void); \ + extern int FN(int); \ + if (! FN(VALUE)) \ + link_failure_##FN##_cst_true() + + /* All of these ctype calls should compile-time evaluate to false. */ +#define TEST_CTYPE_CST_FALSE(FN, VALUE) \ + extern void link_failure_##FN##_cst_false(void); \ + extern int FN(int); \ + if (FN(VALUE)) \ + link_failure_##FN##_cst_false() + + /* All of these ctype calls should compile-time evaluate to true. */ +#define TEST_TOCTYPE_CST_TRUE(FN, VALUE) \ + extern void link_failure_##FN##_cst_true(void); \ + extern int FN(int); \ + if (FN(VALUE) != (VALUE)) \ + link_failure_##FN##_cst_true() + + /* All of these ctype calls should compile-time evaluate to false. */ +#define TEST_TOCTYPE_CST_FALSE(FN, VALUE) \ + extern void link_failure_##FN##_cst_false(void); \ + extern int FN(int); \ + if (FN(VALUE) == (VALUE)) \ + link_failure_##FN##_cst_false() + +#ifdef __OPTIMIZE__ + TEST_CTYPE_CST_TRUE (isascii, 0); + TEST_CTYPE_CST_TRUE (isascii, 1); + TEST_CTYPE_CST_TRUE (isascii, 126); + TEST_CTYPE_CST_TRUE (isascii, 127); + + TEST_CTYPE_CST_FALSE (isascii, -1); + TEST_CTYPE_CST_FALSE (isascii, 128); + TEST_CTYPE_CST_FALSE (isascii, 129); + TEST_CTYPE_CST_FALSE (isascii, 255); + TEST_CTYPE_CST_FALSE (isascii, 256); + TEST_CTYPE_CST_FALSE (isascii, 257); + TEST_CTYPE_CST_FALSE (isascii, 10000); + TEST_CTYPE_CST_FALSE (isascii, __INT_MAX__); + + /* This ctype call should transform into another expression. */ + if (isascii(i) != ((i & ~0x7f) == 0)) + link_failure_var(); + + TEST_TOCTYPE_CST_TRUE (toascii, 0); + TEST_TOCTYPE_CST_TRUE (toascii, 1); + TEST_TOCTYPE_CST_TRUE (toascii, 126); + TEST_TOCTYPE_CST_TRUE (toascii, 127); + + TEST_TOCTYPE_CST_FALSE (toascii, -1); + TEST_TOCTYPE_CST_FALSE (toascii, 128); + TEST_TOCTYPE_CST_FALSE (toascii, 129); + TEST_TOCTYPE_CST_FALSE (toascii, 255); + TEST_TOCTYPE_CST_FALSE (toascii, 256); + TEST_TOCTYPE_CST_FALSE (toascii, 10000); + TEST_TOCTYPE_CST_FALSE (toascii, __INT_MAX__); + + /* This ctype call should transform into another expression. */ + if (toascii(i) != (i & 0x7f)) + link_failure_var(); + + TEST_CTYPE_CST_TRUE (isdigit, '0'); + TEST_CTYPE_CST_TRUE (isdigit, '1'); + TEST_CTYPE_CST_TRUE (isdigit, '2'); + TEST_CTYPE_CST_TRUE (isdigit, '3'); + TEST_CTYPE_CST_TRUE (isdigit, '4'); + TEST_CTYPE_CST_TRUE (isdigit, '5'); + TEST_CTYPE_CST_TRUE (isdigit, '6'); + TEST_CTYPE_CST_TRUE (isdigit, '7'); + TEST_CTYPE_CST_TRUE (isdigit, '8'); + TEST_CTYPE_CST_TRUE (isdigit, '9'); + + TEST_CTYPE_CST_FALSE (isdigit, '0'-1); + TEST_CTYPE_CST_FALSE (isdigit, '9'+1); + TEST_CTYPE_CST_FALSE (isdigit, -1); + TEST_CTYPE_CST_FALSE (isdigit, 0); + TEST_CTYPE_CST_FALSE (isdigit, 255); + TEST_CTYPE_CST_FALSE (isdigit, 256); + TEST_CTYPE_CST_FALSE (isdigit, 10000); + TEST_CTYPE_CST_FALSE (isdigit, __INT_MAX__); + + /* This ctype call should transform into another expression. */ + if (isdigit(i) != ((unsigned)i - '0' <= 9)) + link_failure_var(); +#endif /* __OPTIMIZE__ */ +} + +int main (void) +{ + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-explog-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-explog-1.c new file mode 100644 index 000000000..545f9239c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-explog-1.c @@ -0,0 +1,232 @@ +/* Copyright (C) 2003, 2004 Free Software Foundation. + + Verify that built-in math function constant folding of log & exp is + correctly performed by the compiler. + + Written by Kaveh Ghazi, 2003-09-05. */ + +/* { dg-do link } */ +/* { dg-options "-ffast-math" } */ +/* { dg-skip-if "PR44214" { *-*-* } { "-O0" } { "" } } */ + +/* Define "e" with as many bits as found in builtins.c:dconste. */ +#define M_E 2.7182818284590452353602874713526624977572470936999595749669676277241 +#define M_EF 2.7182818284590452353602874713526624977572470936999595749669676277241F +#define M_EL 2.7182818284590452353602874713526624977572470936999595749669676277241L +/* Precision for comparison tests. */ +#define PREC (sizeof (float) < sizeof (double) ? 0.0000001 : PRECF) +#define PRECF 0.0001F +#define PRECL (sizeof (float) < sizeof (long double) \ + ? 0.0000000000001L : PRECF) +#define PROTOTYPE(FN) extern double FN(double); extern float FN##f(float); \ + extern long double FN##l(long double); +#define PROTOTYPE2(FN) extern double FN(double, double); \ + extern float FN##f(float, float); \ + extern long double FN##l(long double, long double); + +PROTOTYPE(exp) +PROTOTYPE(exp2) +PROTOTYPE(exp10) +PROTOTYPE(log) +PROTOTYPE(log2) +PROTOTYPE(log10) +PROTOTYPE(pow10) +PROTOTYPE(sqrt) +PROTOTYPE(cbrt) +PROTOTYPE2(pow) + +void test(double d1, double d2, float f1, float f2, + long double ld1, long double ld2) +{ + /* Test logN(1) -> 0. */ +#define LOG_1(LOG) \ + extern void link_failure_##LOG##_1(void); \ + if (LOG(1.0) != 0.0 || LOG##f(1.0F) != 0.0F || LOG##l(1.0L) != 0.0L) \ + link_failure_##LOG##_1() + + LOG_1(log); + LOG_1(log2); + LOG_1(log10); + + /* Test logN(N) -> 1. */ +#define LOG_N(LOG, BASE) \ + extern void link_failure_##LOG##_N(void); \ + if (LOG(BASE) != 1.0 || LOG##f(BASE##F) != 1.0F || LOG##l(BASE##L) != 1.0L) \ + link_failure_##LOG##_N() + + LOG_N(log2, 2.0); + LOG_N(log10, 10.0); + + /* Test logN(expN(x)) -> x. */ +#define LOGEXP_SAME(LOG, EXP) \ + extern void link_failure_##LOG##_##EXP##_same(void); \ + if (LOG(EXP(d1)) != d1 || LOG##f(EXP##f(f1)) != f1 \ + || LOG##l(EXP##l(ld1)) != ld1) link_failure_##LOG##_##EXP##_same() + + LOGEXP_SAME(log,exp); + LOGEXP_SAME(log2,exp2); + LOGEXP_SAME(log10,exp10); + LOGEXP_SAME(log10,pow10); + + /* Test logN(expM(x)) -> x*logN(M). */ +#define LOGEXP(LOG, EXP, BASE) \ + extern void link_failure_##LOG##_##EXP(void); \ + if (LOG(EXP(d1)) != d1*LOG(BASE) || LOG##f(EXP##f(f1)) != f1*LOG##f(BASE##F) \ + || LOG##l(EXP##l(ld1)) != ld1*LOG##l(BASE##L)) link_failure_##LOG##_##EXP() + + LOGEXP(log,exp2,2.0); + LOGEXP(log,exp10,10.0); + LOGEXP(log,pow10,10.0); + LOGEXP(log2,exp,M_E); + LOGEXP(log2,exp2,2.0); + LOGEXP(log2,exp10,10.0); + LOGEXP(log2,pow10,10.0); + LOGEXP(log10,exp,M_E); + LOGEXP(log10,exp2,2.0); + LOGEXP(log10,exp10,10.0); + LOGEXP(log10,pow10,10.0); + + /* Test logN(sqrt(x)) -> 0.5*logN(x). */ +#define LOG_SQRT(LOG) \ + extern void link_failure_##LOG##_sqrt(void); \ + if (LOG(sqrt(d1)) != 0.5*LOG(d1) || LOG##f(sqrtf(f1)) != 0.5F*LOG##f(f1) \ + || LOG##l(sqrtl(ld1)) != 0.5L*LOG##l(ld1)) link_failure_##LOG##_sqrt() + + LOG_SQRT(log); + LOG_SQRT(log2); + LOG_SQRT(log10); + + /* Test sqrt(expN(x)) -> expN(x*0.5). */ +#define SQRT_EXP(EXP) \ + extern void link_failure_sqrt_##EXP(void); \ + if (sqrt(EXP(d1)) != EXP(d1*0.5) || sqrtf(EXP##f(f1)) != EXP##f(f1*0.5F) \ + || sqrtl(EXP##l(ld1)) != EXP##l(ld1*0.5L)) link_failure_sqrt_##EXP() + + SQRT_EXP(exp); + SQRT_EXP(exp2); + SQRT_EXP(exp10); + SQRT_EXP(pow10); + + /* Test logN(cbrt(x)) -> (1/3)*logN(x). */ +#define LOG_CBRT(LOG) \ + extern void link_failure_##LOG##_cbrt(void); \ + if (LOG(cbrt(d1)) != (1.0/3)*LOG(d1) \ + || LOG##f(cbrtf(f1)) != (1.0F/3)*LOG##f(f1) \ + || LOG##l(cbrtl(ld1)) != (1.0L/3)*LOG##l(ld1)) link_failure_##LOG##_cbrt() + + LOG_CBRT(log); + LOG_CBRT(log2); + LOG_CBRT(log10); + + /* Test cbrt(expN(x)) -> expN(x/3). */ +#define CBRT_EXP(EXP) \ + extern void link_failure_cbrt_##EXP(void); \ + if (cbrt(EXP(d1)) != EXP(d1/3.0) || cbrtf(EXP##f(f1)) != EXP##f(f1/3.0F) \ + || cbrtl(EXP##l(ld1)) != EXP##l(ld1/3.0L)) link_failure_cbrt_##EXP() + + CBRT_EXP(exp); + CBRT_EXP(exp2); + CBRT_EXP(exp10); + CBRT_EXP(pow10); + + /* Test logN(pow(x,y)) -> y*logN(x). */ +#define LOG_POW(LOG, POW) \ + extern void link_failure_##LOG##_##POW(void); \ + if (LOG(POW(d1,d2)) != d2*LOG(d1) || LOG##f(POW##f(f1,f2)) != f2*LOG##f(f1) \ + || LOG##l(POW##l(ld1,ld2)) != ld2*LOG##l(ld1)) link_failure_##LOG##_##POW() + + LOG_POW(log,pow); + LOG_POW(log2,pow); + LOG_POW(log10,pow); + + /* Test pow(expN(x),y)) -> expN(x*y). */ +#define POW_EXP(POW, EXP) \ + extern void link_failure_##POW##_##EXP(void); \ + if (POW(EXP(d1),d2) != EXP(d1*d2) || POW##f(EXP##f(f1),f2) != EXP##f(f1*f2) \ + || POW##l(EXP##l(ld1),ld2) != EXP##l(ld1*ld2)) link_failure_##POW##_##EXP() + + POW_EXP(pow, exp); + POW_EXP(pow, exp2); + POW_EXP(pow, exp10); + POW_EXP(pow, pow10); + + /* Test expN(0) -> 1. */ +#define EXP_0(EXP) \ + extern void link_failure_##EXP##_0(void); \ + if (EXP(0.0) != 1.0 || EXP##f(0.0F) != 1.0F || EXP##l(0.0L) != 1.0L) \ + link_failure_##EXP##_0() + + EXP_0(exp); + EXP_0(exp2); + EXP_0(exp10); + EXP_0(pow10); + + /* Test expN(1) -> N. */ +#define EXP_N(EXP, BASE) \ + extern void link_failure_##EXP##_N(void); \ + if (EXP(1.0) != BASE || EXP##f(1.0F) != BASE##F || EXP##l(1.0L) != BASE##L) \ + link_failure_##EXP##_N() + + EXP_N(exp, M_E); + EXP_N(exp2, 2.0); + EXP_N(exp10, 10.0); + EXP_N(pow10, 10.0); + + /* Test expN(integer) -> N*N*N*... */ +#define EXP_INT(EXP, BASE) \ + extern void link_failure_##EXP##_INT(void); \ + if (EXP(5.0) < (BASE)*(BASE)*(BASE)*(BASE)*(BASE) - PREC \ + || EXP(5.0) > (BASE)*(BASE)*(BASE)*(BASE)*(BASE) + PREC \ + || EXP##f(5.0F) < (BASE##F)*(BASE##F)*(BASE##F)*(BASE##F)*(BASE##F) -PRECF \ + || EXP##f(5.0F) > (BASE##F)*(BASE##F)*(BASE##F)*(BASE##F)*(BASE##F) +PRECF \ + || EXP##l(5.0L) < (BASE##L)*(BASE##L)*(BASE##L)*(BASE##L)*(BASE##L) -PRECL \ + || EXP##l(5.0L) > (BASE##L)*(BASE##L)*(BASE##L)*(BASE##L)*(BASE##L) +PRECL) \ + link_failure_##EXP##_INT() + + EXP_INT(exp, M_E); + EXP_INT(exp2, 2.0); + EXP_INT(exp10, 10.0); + EXP_INT(pow10, 10.0); + + /* Test expN(logN(x)) -> x. */ +#define EXPLOG_SAME(EXP, LOG) \ + extern void link_failure_##EXP##_##LOG##_same(void); \ + if (EXP(LOG(d1)) != d1 || EXP##f(LOG##f(f1)) != f1 \ + || EXP##l(LOG##l(ld1)) != ld1) link_failure_##EXP##_##LOG##_same() + + EXPLOG_SAME(exp, log); + EXPLOG_SAME(exp2, log2); + EXPLOG_SAME(exp10, log10); + EXPLOG_SAME(pow10, log10); + + /* Test expN(x)*expN(y)) -> expN(x+y). */ +#define EXPXEXP(EXP) \ + extern void link_failure_##EXP##X##EXP(void); \ + if (EXP(d1)*EXP(d2) != EXP(d1+d2) || EXP##f(f1)*EXP##f(f2) != EXP##f(f1+f2) \ + || EXP##l(ld1)*EXP##l(ld2) != EXP##l(ld1+ld2)) link_failure_##EXP##X##EXP() + + EXPXEXP(exp); + EXPXEXP(exp2); + EXPXEXP(exp10); + EXPXEXP(pow10); + + /* Test x/expN(y) -> x*expN(-y). */ + /* Test expN(x)/expN(y) -> expN(x-y). */ +#define DIVEXP(EXP) \ + extern void link_failure_div1_##EXP(void); \ + if (d1/EXP(d2) != d1*EXP(-d2) || f1/EXP##f(f2) != f1*EXP##f(-f2) \ + || ld1/EXP##l(ld2) != ld1*EXP##l(-ld2)) link_failure_div1_##EXP(); \ + extern void link_failure_div2_##EXP(void); \ + if (EXP(d1)/EXP(d2) != EXP(d1-d2) || EXP##f(f1)/EXP##f(f2) != EXP##f(f1-f2) \ + || EXP##l(ld1)/EXP##l(ld2) != EXP##l(ld1-ld2)) link_failure_div2_##EXP() + + DIVEXP(exp); + DIVEXP(exp2); + DIVEXP(exp10); + DIVEXP(pow10); +} + +int main (void) +{ + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-frexp-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-frexp-1.c new file mode 100644 index 000000000..a66ce51fc --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-frexp-1.c @@ -0,0 +1,137 @@ +/* Copyright (C) 2007 Free Software Foundation. + + Verify that built-in folding of frexp is correctly performed by the + compiler. + + Origin: Kaveh R. Ghazi, February 21, 2007. */ + +/* { dg-do link } */ +/* { dg-options "-fno-finite-math-only" { target sh*-*-* } } */ +/* In order to fold algebraic exprs below, targets with "composite" + floating point formats need -funsafe-math-optimizations. */ +/* { dg-options "-funsafe-math-optimizations" { target powerpc*-*-* } } */ + +extern void link_error(int); + +/* Return TRUE if the sign of X != sign of Y. This is important when + comparing signed zeros. */ +#define CKSGN_F(X,Y) \ + (__builtin_copysignf(1.0F,(X)) != __builtin_copysignf(1.0F,(Y))) +#define CKSGN(X,Y) \ + (__builtin_copysign(1.0,(X)) != __builtin_copysign(1.0,(Y))) +#define CKSGN_L(X,Y) \ + (__builtin_copysignl(1.0L,(X)) != __builtin_copysignl(1.0L,(Y))) + +/* We can only check the exponent when optimizing since we rely on + other optimizations to propagate the value. TRUE means an error + occurred. */ +#ifdef __OPTIMIZE__ +#define CKEXP(X,Y) X != Y +#else +#define CKEXP(X,Y) 0 +#endif + +/* Test that frexp(ARG,&i) == RES && i == EXP. Check the sign in + case we get -0.0. */ +#define TESTIT_FREXP(ARG,RES,EXP) do { \ + int i = 12345; \ + if (__builtin_frexpf(ARG##f,&i) != RES##f \ + || CKEXP(i,EXP) \ + || CKSGN_F(__builtin_frexpf(ARG##f,&i),RES##f)) \ + link_error(__LINE__); \ + i = 12345; \ + if (__builtin_frexp(ARG,&i) != RES \ + || CKEXP(i,EXP) \ + || CKSGN(__builtin_frexp(ARG,&i),RES)) \ + link_error(__LINE__); \ + i = 12345; \ + if (__builtin_frexpl(ARG##l,&i) != RES##l \ + || CKEXP(i,EXP) \ + || CKSGN_L(__builtin_frexpl(ARG##l,&i),RES##l)) \ + link_error(__LINE__); \ + } while (0) + +/* Test that FUNCRES(frexp(NEG FUNCARG(ARGARG),&i)) is false. Check + the sign as well. Ensure side-effects are evaluated in i. */ +#ifndef __SPU__ +#define TESTIT_FREXP2(NEG,FUNCARG,ARGARG,FUNCRES) do { \ + int i=5; \ + if (!__builtin_##FUNCRES##f(__builtin_frexpf(NEG __builtin_##FUNCARG##f(ARGARG),&i)) \ + || CKSGN_F(__builtin_frexpf(NEG __builtin_##FUNCARG##f(ARGARG),(i++,&i)), NEG __builtin_##FUNCARG##f(ARGARG)) \ + || CKEXP(i,6)) \ + link_error(__LINE__); \ + if (!__builtin_##FUNCRES(__builtin_frexp(NEG __builtin_##FUNCARG(ARGARG),&i)) \ + || CKSGN(__builtin_frexp(NEG __builtin_##FUNCARG(ARGARG),(i++,&i)), NEG __builtin_##FUNCARG(ARGARG)) \ + || CKEXP(i,7)) \ + link_error(__LINE__); \ + if (!__builtin_##FUNCRES##l(__builtin_frexpl(NEG __builtin_##FUNCARG##l(ARGARG),&i)) \ + || CKSGN_L(__builtin_frexpl(NEG __builtin_##FUNCARG##l(ARGARG),(i++,&i)), NEG __builtin_##FUNCARG##l(ARGARG)) \ + || CKEXP(i,8)) \ + link_error(__LINE__); \ + } while (0) +#else +#define TESTIT_FREXP2(NEG,FUNCARG,ARGARG,FUNCRES) do { \ + int i=6; \ + /* SPU single-precision floating point format does not support Inf or Nan. */ \ + if (!__builtin_##FUNCRES(__builtin_frexp(NEG __builtin_##FUNCARG(ARGARG),&i)) \ + || CKSGN(__builtin_frexp(NEG __builtin_##FUNCARG(ARGARG),(i++,&i)), NEG __builtin_##FUNCARG(ARGARG)) \ + || CKEXP(i,7)) \ + link_error(__LINE__); \ + if (!__builtin_##FUNCRES##l(__builtin_frexpl(NEG __builtin_##FUNCARG##l(ARGARG),&i)) \ + || CKSGN_L(__builtin_frexpl(NEG __builtin_##FUNCARG##l(ARGARG),(i++,&i)), NEG __builtin_##FUNCARG##l(ARGARG)) \ + || CKEXP(i,8)) \ + link_error(__LINE__); \ + } while (0) +#endif + +void __attribute__ ((__noinline__)) +foo(void) +{ + /* Test that frexp(ARG1,&i) -> ARG2 && i == ARG3. */ + TESTIT_FREXP (-0x1p40, -0.5, 41); + TESTIT_FREXP (-0x1p30, -0.5, 31); + TESTIT_FREXP (-0x1p20, -0.5, 21); + TESTIT_FREXP (-0x1p10, -0.5, 11); + TESTIT_FREXP (-0x1p5, -0.5, 6); + TESTIT_FREXP (-100/3.0, -100/192.0, 6); + TESTIT_FREXP (-1.5, -0.75, 1); + TESTIT_FREXP (-1.0, -0.5, 1); + TESTIT_FREXP (-1/3.0, -2/3.0, -1); + TESTIT_FREXP (-1/9.0, -8/9.0, -3); + TESTIT_FREXP (-0x1p-5, -0.5, -4); + TESTIT_FREXP (-0x1p-10, -0.5, -9); + TESTIT_FREXP (-0x1p-20, -0.5, -19); + TESTIT_FREXP (-0x1p-30, -0.5, -29); + TESTIT_FREXP (-0x1p-40, -0.5, -39); + TESTIT_FREXP (-0.0, -0.0, 0); + TESTIT_FREXP (0.0, 0.0, 0); + TESTIT_FREXP (0x1p-40, 0.5, -39); + TESTIT_FREXP (0x1p-30, 0.5, -29); + TESTIT_FREXP (0x1p-20, 0.5, -19); + TESTIT_FREXP (0x1p-10, 0.5, -9); + TESTIT_FREXP (0x1p-5, 0.5, -4); + TESTIT_FREXP (1/9.0, 8/9.0, -3); + TESTIT_FREXP (1/3.0, 2/3.0, -1); + TESTIT_FREXP (1.0, 0.5, 1); + TESTIT_FREXP (1.5, 0.75, 1); + TESTIT_FREXP (100/3.0, 100/192.0, 6); + TESTIT_FREXP (0x1p5, 0.5, 6); + TESTIT_FREXP (0x1p10, 0.5, 11); + TESTIT_FREXP (0x1p20, 0.5, 21); + TESTIT_FREXP (0x1p30, 0.5, 31); + TESTIT_FREXP (0x1p40, 0.5, 41); + + /* Test for frexp(+-Inf,&i) -> +-Inf and frexp(+-NaN,&i) -> +-NaN. + Exponent is left unspecified, but we test for side-effects. */ + TESTIT_FREXP2 ( ,inf, , isinf); + TESTIT_FREXP2 (- ,inf, , isinf); + TESTIT_FREXP2 ( ,nan, "", isnan); + TESTIT_FREXP2 (- ,nan, "", isnan); +} + +int main() +{ + foo (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-integral-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-integral-1.c new file mode 100644 index 000000000..522646dd5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-integral-1.c @@ -0,0 +1,69 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Verify that integral FP expressions are optimized. + + Written by Kaveh Ghazi, 2004-03-16. */ + +/* { dg-do link } */ +/* We need -ffinite-math-only so that we can fold "foo != foo", where + foo is a floating point expression. We need -fno-math-errno so + that various math functions are marked const/pure and can be + folded. */ +/* { dg-options "-ffinite-math-only -fno-math-errno" } */ + +extern int link_failure (int); + +/* Test that the various FP truncation builtins detect integral + arguments. */ +#define CHECK_FN(MATHFN) \ + if (__builtin_##MATHFN(i1) != i1) link_failure (__LINE__); \ + if (__builtin_##MATHFN##f(i1) != i1) link_failure (__LINE__); \ + if (__builtin_##MATHFN##l(i1) != i1) link_failure (__LINE__); + +#define CHECK_FN_RET(MATHFN, RET) \ + if (__builtin_##MATHFN(i1) != (RET)(double)i1) link_failure (__LINE__); \ + if (__builtin_##MATHFN##f(i1) != (RET)(float)i1) link_failure (__LINE__); \ + if (__builtin_##MATHFN##l(i1) != (RET)(long double)i1) link_failure (__LINE__); + + /* Check that various other integral expressions are detected. */ +#define CHECK_EXPR(EXPR,NAME) \ + if (__builtin_ceill(EXPR) != (EXPR)) link_failure (__LINE__); \ + if (__builtin_lroundl(EXPR) != (long)(long double)(EXPR)) link_failure (__LINE__); + +void __attribute__ ((__noinline__)) test (int i1, int i2) +{ + CHECK_FN(ceil); + CHECK_FN(floor); + CHECK_FN(nearbyint); + CHECK_FN(rint); + CHECK_FN(round); + CHECK_FN(trunc); + CHECK_FN_RET(lround, long); + CHECK_FN_RET(llround, long long); + CHECK_FN_RET(lrint, long); + CHECK_FN_RET(llrint, long long); + CHECK_FN_RET(lceil, long); + CHECK_FN_RET(llceil, long long); + CHECK_FN_RET(lfloor, long); + CHECK_FN_RET(llfloor, long long); + + CHECK_EXPR (5.0, REAL_CST); + CHECK_EXPR (5.0F, REAL_CSTf); + CHECK_EXPR (5.0L, REAL_CSTl); + CHECK_EXPR ((double)i1, FLOAT_EXPR); + CHECK_EXPR ((float)i1, FLOAT_EXPRf); + CHECK_EXPR ((long double)i1, FLOAT_EXPRl); + CHECK_EXPR (__builtin_fabs(i1), ABS_EXPR); + CHECK_EXPR (__builtin_fabsf(i1), ABS_EXPRf); + CHECK_EXPR (__builtin_fabsl(i1), ABS_EXPRl); + CHECK_EXPR (((void)i1,(double)i2), COMPOUND_EXPR); + CHECK_EXPR ((double)i1+i2, PLUS_EXPR); + CHECK_EXPR ((double)i1-i2, MINUS_EXPR); + CHECK_EXPR ((double)i1*i2, MULT_EXPR); +} + +int main (void) +{ + test (1, 2); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-isinf_sign-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-isinf_sign-1.c new file mode 100644 index 000000000..6dc2326ed --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-isinf_sign-1.c @@ -0,0 +1,56 @@ +/* Copyright (C) 2008 Free Software Foundation. + + Verify that __builtin_isinf_sign folds correctly. + + Origin: Kaveh R. Ghazi, May 17, 2008. */ + +/* { dg-do link } */ + +/* All references to link_error should go away at compile-time. */ +extern void link_error(int); + +void __attribute__ ((__noinline__)) +foo (float f, double d, long double ld) +{ + /* Test the generic expansion of isinf_sign. */ + + if (__builtin_isinf_sign(f) + != (__builtin_isinf(f) ? (__builtin_signbitf(f) ? -1 : 1) : 0)) + link_error (__LINE__); + if (__builtin_isinf_sign(d) + != (__builtin_isinf(d) ? (__builtin_signbit(d) ? -1 : 1) : 0)) + link_error (__LINE__); + if (__builtin_isinf_sign(ld) + != (__builtin_isinf(ld) ? (__builtin_signbitl(ld) ? -1 : 1) : 0)) + link_error (__LINE__); + + /* In boolean contexts, GCC will fold the inner conditional + expression to 1. So isinf_sign folds to plain isinf. */ + + if ((_Bool)__builtin_isinf_sign(f) != (__builtin_isinf(f) != 0)) + link_error (__LINE__); + if ((_Bool)__builtin_isinf_sign(d) != (__builtin_isinf(d) != 0)) + link_error (__LINE__); + if ((_Bool)__builtin_isinf_sign(ld) != (__builtin_isinf(ld) != 0)) + link_error (__LINE__); + + if ((__builtin_isinf_sign(f) != 0) != (__builtin_isinf(f) != 0)) + link_error (__LINE__); + if ((__builtin_isinf_sign(d) != 0) != (__builtin_isinf(d) != 0)) + link_error (__LINE__); + if ((__builtin_isinf_sign(ld) != 0) != (__builtin_isinf(ld) != 0)) + link_error (__LINE__); + + if ((__builtin_isinf_sign(f) ? 5 : 6) != (__builtin_isinf(f) ? 5 : 6)) + link_error (__LINE__); + if ((__builtin_isinf_sign(d) ? 5 : 6) != (__builtin_isinf(d) ? 5 : 6)) + link_error (__LINE__); + if ((__builtin_isinf_sign(ld) ? 5 : 6) != (__builtin_isinf(ld) ? 5 : 6)) + link_error (__LINE__); +} + +int main (void) +{ + foo (1, 2, 3); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-ldexp-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-ldexp-1.c new file mode 100644 index 000000000..94560a8ab --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-ldexp-1.c @@ -0,0 +1,216 @@ +/* Copyright (C) 2007 Free Software Foundation. + + Verify that built-in folding of ldexp et al. is correctly performed + by the compiler. + + Origin: Kaveh R. Ghazi, February 17, 2007. */ + +/* { dg-do link } */ +/* { dg-options "-fno-finite-math-only" { target sh*-*-* } } */ + +extern void link_error(int); + +/* Return TRUE if the sign of X != sign of Y. This is important when + comparing signed zeros. */ +#define CKSGN_F(X,Y) \ + (__builtin_copysignf(1.0F,(X)) != __builtin_copysignf(1.0F,(Y))) +#define CKSGN(X,Y) \ + (__builtin_copysign(1.0,(X)) != __builtin_copysign(1.0,(Y))) +#define CKSGN_L(X,Y) \ + (__builtin_copysignl(1.0L,(X)) != __builtin_copysignl(1.0L,(Y))) + +/* Test that FUNC(ARG1,ARG2) == RES. Check the sign for -0.0. */ +#define TESTIT(FUNC,ARG1,ARG2,RES) do { \ + if (__builtin_##FUNC##f(ARG1##f,ARG2) != RES##f \ + || CKSGN_F(__builtin_##FUNC##f(ARG1##f,ARG2),RES##f)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC(ARG1,ARG2) != RES \ + || CKSGN(__builtin_##FUNC(ARG1,ARG2),RES)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC##l(ARG1##l,ARG2) != RES##l \ + || CKSGN_L(__builtin_##FUNC##l(ARG1##l,ARG2),RES##l)) \ + link_error(__LINE__); \ + } while (0) + +/* Test that (long)FUNC(ARG1,ARG2) == (long)RES. The cast is + necessary when RES is not a constant. */ +#define TESTIT2(FUNC,ARG1,ARG2,RES) do { \ + if ((long)__builtin_##FUNC##f(ARG1##f,ARG2) != (long)RES##f) \ + link_error(__LINE__); \ + if ((long)__builtin_##FUNC(ARG1,ARG2) != (long)RES) \ + link_error(__LINE__); \ + if ((long)__builtin_##FUNC##l(ARG1##l,ARG2) != (long)RES##l) \ + link_error(__LINE__); \ + } while (0) + +/* Test that FUNCRES(FUNC(NEG FUNCARG(ARGARG),ARG2)) is false. Check + the sign as well. */ +#ifndef __SPU__ +#define TESTIT3(FUNC,NEG,FUNCARG,ARGARG,ARG2,FUNCRES) do { \ + if (!__builtin_##FUNCRES##f(__builtin_##FUNC##f(NEG __builtin_##FUNCARG##f(ARGARG),ARG2)) \ + || CKSGN_F(__builtin_##FUNC##f(NEG __builtin_##FUNCARG##f(ARGARG),ARG2), NEG __builtin_##FUNCARG##f(ARGARG))) \ + link_error(__LINE__); \ + if (!__builtin_##FUNCRES(__builtin_##FUNC(NEG __builtin_##FUNCARG(ARGARG),ARG2)) \ + || CKSGN(__builtin_##FUNC(NEG __builtin_##FUNCARG(ARGARG),ARG2), NEG __builtin_##FUNCARG(ARGARG))) \ + link_error(__LINE__); \ + if (!__builtin_##FUNCRES##l(__builtin_##FUNC##l(NEG __builtin_##FUNCARG##l(ARGARG),ARG2)) \ + || CKSGN_L(__builtin_##FUNC##l(NEG __builtin_##FUNCARG##l(ARGARG),ARG2), NEG __builtin_##FUNCARG##l(ARGARG))) \ + link_error(__LINE__); \ + } while (0) +#else +#define TESTIT3(FUNC,NEG,FUNCARG,ARGARG,ARG2,FUNCRES) do { \ + /* SPU single-precision floating point format does not support Inf or Nan. */ \ + if (!__builtin_##FUNCRES(__builtin_##FUNC(NEG __builtin_##FUNCARG(ARGARG),ARG2)) \ + || CKSGN(__builtin_##FUNC(NEG __builtin_##FUNCARG(ARGARG),ARG2), NEG __builtin_##FUNCARG(ARGARG))) \ + link_error(__LINE__); \ + if (!__builtin_##FUNCRES##l(__builtin_##FUNC##l(NEG __builtin_##FUNCARG##l(ARGARG),ARG2)) \ + || CKSGN_L(__builtin_##FUNC##l(NEG __builtin_##FUNCARG##l(ARGARG),ARG2), NEG __builtin_##FUNCARG##l(ARGARG))) \ + link_error(__LINE__); \ + } while (0) +#endif + +/* Using foo==MIN/MAX float values, test that FUNC(foo,EXP) == foo*exp2(EXP), + and also that FUNC(foo,-EXP) == foo*exp2(-EXP). */ +#define TESTIT4(FUNC,EXP) do { \ + if (__builtin_##FUNC##f(__FLT_MIN__,EXP) != __FLT_MIN__*__builtin_exp2f(EXP)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC##f(-__FLT_MIN__,EXP) != -__FLT_MIN__*__builtin_exp2f(EXP)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC(__DBL_MIN__,EXP) != __DBL_MIN__*__builtin_exp2(EXP)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC(-__DBL_MIN__,EXP) != -__DBL_MIN__*__builtin_exp2(EXP)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC##l(__LDBL_MIN__,EXP) != __LDBL_MIN__*__builtin_exp2l(EXP)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC##l(-__LDBL_MIN__,EXP) != -__LDBL_MIN__*__builtin_exp2l(EXP)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC##f(__FLT_MAX__,-EXP) != __FLT_MAX__*__builtin_exp2f(-EXP)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC##f(-__FLT_MAX__,-EXP) != -__FLT_MAX__*__builtin_exp2f(-EXP)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC(__DBL_MAX__,-EXP) != __DBL_MAX__*__builtin_exp2(-EXP)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC(-__DBL_MAX__,-EXP) != -__DBL_MAX__*__builtin_exp2(-EXP)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC##l(__LDBL_MAX__,-EXP) != __LDBL_MAX__*__builtin_exp2l(-EXP)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC##l(-__LDBL_MAX__,-EXP) != -__LDBL_MAX__*__builtin_exp2l(-EXP)) \ + link_error(__LINE__); \ + } while (0) + +void __attribute__ ((__noinline__)) +foo(float xf, double x, long double xl, int i, long l) +{ + /* f(0.0, i) -> 0.0 and f(-0.0, i) -> -0.0. */ + TESTIT (ldexp, 0.0, i, 0.0); + TESTIT (ldexp, -0.0, i, -0.0); + TESTIT (scalbn, 0.0, i, 0.0); + TESTIT (scalbn, -0.0, i, -0.0); + TESTIT (scalbln, 0.0, l, 0.0); + TESTIT (scalbln, -0.0, l, -0.0); + + /* f(x,0) -> x. */ + TESTIT2 (ldexp, x, 0, x); + TESTIT2 (scalbn, x, 0, x); + TESTIT2 (scalbln, x, 0, x); + + /* f(Inf,i) -> Inf and f(NaN,i) -> NaN. */ + TESTIT3 (ldexp, , inf, , i, isinf); + TESTIT3 (ldexp, -, inf, , i, isinf); + TESTIT3 (ldexp, , nan, "", i, isnan); + TESTIT3 (ldexp, -, nan, "", i, isnan); + + TESTIT3 (scalbn, , inf, , i, isinf); + TESTIT3 (scalbn, -, inf, , i, isinf); + TESTIT3 (scalbn, , nan, "", i, isnan); + TESTIT3 (scalbn, -, nan, "", i, isnan); + + TESTIT3 (scalbln, , inf, , i, isinf); + TESTIT3 (scalbln, -, inf, , i, isinf); + TESTIT3 (scalbln, , nan, "", i, isnan); + TESTIT3 (scalbln, -, nan, "", i, isnan); + + /* Evaluate when both arguments are constant. */ + TESTIT (ldexp, 5.0, 3, 40.0); + TESTIT (ldexp, -5.0, 3, -40.0); + TESTIT (ldexp, 5.0, -3, 0.625); + TESTIT (ldexp, -5.0, -3, -0.625); + + TESTIT (ldexp, 1000.0, 5, 32000.0); + TESTIT (ldexp, -1000.0, 5, -32000.0); + TESTIT (ldexp, 1000.0, -5, 31.25); + TESTIT (ldexp, -1000.0, -5, -31.25); + + /* f(x,N) -> x*exp2(N), using MIN/MAX constants for x and constant N. */ + TESTIT4 (ldexp, 1); + TESTIT4 (ldexp, 2); + TESTIT4 (ldexp, 3); + TESTIT4 (ldexp, 5); + TESTIT4 (ldexp, 9); + TESTIT4 (ldexp, 10); + TESTIT4 (ldexp, 12); + TESTIT4 (ldexp, 18); + TESTIT4 (ldexp, 25); + TESTIT4 (ldexp, 50); + TESTIT4 (ldexp, 75); + TESTIT4 (ldexp, 100); + TESTIT4 (ldexp, 123); + + /* These are folded when float radix is two. */ +#if __FLT_RADIX__ == 2 + TESTIT (scalbn, 5.0, 3, 40.0); + TESTIT (scalbn, -5.0, 3, -40.0); + TESTIT (scalbn, 5.0, -3, 0.625); + TESTIT (scalbn, -5.0, -3, -0.625); + + TESTIT (scalbn, 1000.0, 5, 32000.0); + TESTIT (scalbn, -1000.0, 5, -32000.0); + TESTIT (scalbn, 1000.0, -5, 31.25); + TESTIT (scalbn, -1000.0, -5, -31.25); + + TESTIT4 (scalbn, 1); + TESTIT4 (scalbn, 2); + TESTIT4 (scalbn, 3); + TESTIT4 (scalbn, 5); + TESTIT4 (scalbn, 9); + TESTIT4 (scalbn, 10); + TESTIT4 (scalbn, 12); + TESTIT4 (scalbn, 18); + TESTIT4 (scalbn, 25); + TESTIT4 (scalbn, 50); + TESTIT4 (scalbn, 75); + TESTIT4 (scalbn, 100); + TESTIT4 (scalbn, 123); + + TESTIT (scalbln, 5.0, 3, 40.0); + TESTIT (scalbln, -5.0, 3, -40.0); + TESTIT (scalbln, 5.0, -3, 0.625); + TESTIT (scalbln, -5.0, -3, -0.625); + + TESTIT (scalbln, 1000.0, 5, 32000.0); + TESTIT (scalbln, -1000.0, 5, -32000.0); + TESTIT (scalbln, 1000.0, -5, 31.25); + TESTIT (scalbln, -1000.0, -5, -31.25); + + TESTIT4 (scalbln, 1); + TESTIT4 (scalbln, 2); + TESTIT4 (scalbln, 3); + TESTIT4 (scalbln, 5); + TESTIT4 (scalbln, 9); + TESTIT4 (scalbln, 10); + TESTIT4 (scalbln, 12); + TESTIT4 (scalbln, 18); + TESTIT4 (scalbln, 25); + TESTIT4 (scalbln, 50); + TESTIT4 (scalbln, 75); + TESTIT4 (scalbln, 100); + TESTIT4 (scalbln, 123); +#endif +} + +int main() +{ + foo (0, 0, 0, 0, 0); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-logb-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-logb-1.c new file mode 100644 index 000000000..d759d1c6c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-logb-1.c @@ -0,0 +1,192 @@ +/* Copyright (C) 2007 Free Software Foundation. + + Verify that built-in folding of logb, ilogb and significand is + correctly performed by the compiler. + + Origin: Kaveh R. Ghazi, February 22, 2007. */ + +/* { dg-do link } */ +/* { dg-options "-fno-finite-math-only" { target sh*-*-* } } */ +/* In order to fold algebraic exprs below, targets with "composite" + floating point formats need -funsafe-math-optimizations. */ +/* { dg-options "-funsafe-math-optimizations" { target powerpc*-*-* } } */ + +extern void link_error(int); + +/* Return TRUE if the sign of X != sign of Y. This is important when + comparing signed zeros. */ +#define CKSGN_F(X,Y) \ + (__builtin_copysignf(1.0F,(X)) != __builtin_copysignf(1.0F,(Y))) +#define CKSGN(X,Y) \ + (__builtin_copysign(1.0,(X)) != __builtin_copysign(1.0,(Y))) +#define CKSGN_L(X,Y) \ + (__builtin_copysignl(1.0L,(X)) != __builtin_copysignl(1.0L,(Y))) + +/* Test that FUNC(ARG) == RES. Check the sign in case we get -0.0. */ +#define TESTIT(FUNC,ARG,RES) do { \ + if (__builtin_##FUNC##f(ARG##f) != RES##f \ + || CKSGN_F(__builtin_##FUNC##f(ARG##f),RES##f)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC(ARG) != RES \ + || CKSGN(__builtin_##FUNC(ARG),RES)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC##l(ARG##l) != RES##l \ + || CKSGN_L(__builtin_##FUNC##l(ARG##l),RES##l)) \ + link_error(__LINE__); \ + } while (0) + +/* Test that FUNC(ARG) == RES. RES is an int so it can't be -0.0. */ +#define TESTIT2(FUNC,ARG,RES) do { \ + if (__builtin_##FUNC##f(ARG##f) != RES) \ + link_error(__LINE__); \ + if (__builtin_##FUNC(ARG) != RES) \ + link_error(__LINE__); \ + if (__builtin_##FUNC##l(ARG##l) != RES) \ + link_error(__LINE__); \ + } while (0) + +/* Test if FUNCRES(FUNC(NEG FUNCARG(ARGARG))) is false. Check the + sign as well. */ +#ifndef __SPU__ +#define TESTIT3(FUNC,NEG,FUNCARG,ARGARG,FUNCRES,NEG2) do { \ + if (!__builtin_##FUNCRES##f(__builtin_##FUNC(NEG __builtin_##FUNCARG##f(ARGARG))) \ + || CKSGN_F(__builtin_##FUNC##f(NEG __builtin_##FUNCARG##f(ARGARG)), NEG2 __builtin_##FUNCARG##f(ARGARG))) \ + link_error(__LINE__); \ + if (!__builtin_##FUNCRES(__builtin_##FUNC(NEG __builtin_##FUNCARG(ARGARG))) \ + || CKSGN(__builtin_##FUNC(NEG __builtin_##FUNCARG(ARGARG)), NEG2 __builtin_##FUNCARG(ARGARG))) \ + link_error(__LINE__); \ + if (!__builtin_##FUNCRES##l(__builtin_##FUNC##l(NEG __builtin_##FUNCARG##l(ARGARG))) \ + || CKSGN_L(__builtin_##FUNC##l(NEG __builtin_##FUNCARG##l(ARGARG)), NEG2 __builtin_##FUNCARG##l(ARGARG))) \ + link_error(__LINE__); \ + } while (0) +#else +#define TESTIT3(FUNC,NEG,FUNCARG,ARGARG,FUNCRES,NEG2) do { \ + /* SPU single-precision floating point format does not support Inf or Nan. */ \ + if (!__builtin_##FUNCRES(__builtin_##FUNC(NEG __builtin_##FUNCARG(ARGARG))) \ + || CKSGN(__builtin_##FUNC(NEG __builtin_##FUNCARG(ARGARG)), NEG2 __builtin_##FUNCARG(ARGARG))) \ + link_error(__LINE__); \ + if (!__builtin_##FUNCRES##l(__builtin_##FUNC##l(NEG __builtin_##FUNCARG##l(ARGARG))) \ + || CKSGN_L(__builtin_##FUNC##l(NEG __builtin_##FUNCARG##l(ARGARG)), NEG2 __builtin_##FUNCARG##l(ARGARG))) \ + link_error(__LINE__); \ + } while (0) +#endif + +void __attribute__ ((__noinline__)) +foo(void) +{ + /* If radix == 2, test that logb(ARG2) -> ARG3. */ +#if __FLT_RADIX__ == 2 + TESTIT (logb, -0x1p40, 40.0); + TESTIT (logb, -0x1p30, 30.0); + TESTIT (logb, -0x1p20, 20.0); + TESTIT (logb, -0x1p10, 10.0); + TESTIT (logb, -0x1p5, 5.0); + TESTIT (logb, -100/3.0, 5.0); + TESTIT (logb, -2.0, 1.0); + TESTIT (logb, -1.5, 0.0); + TESTIT (logb, -1.0, 0.0); + TESTIT (logb, -1/3.0, -2.0); + TESTIT (logb, -1/9.0, -4.0); + TESTIT (logb, -0x1p-5, -5.0); + TESTIT (logb, -0x1p-10, -10.0); + TESTIT (logb, -0x1p-20, -20.0); + TESTIT (logb, -0x1p-30, -30.0); + TESTIT (logb, -0x1p-40, -40.0); + + TESTIT (logb, 0x1p-40, -40.0); + TESTIT (logb, 0x1p-30, -30.0); + TESTIT (logb, 0x1p-20, -20.0); + TESTIT (logb, 0x1p-10, -10.0); + TESTIT (logb, 0x1p-5, -5.0); + TESTIT (logb, 1/9.0, -4.0); + TESTIT (logb, 1/3.0, -2.0); + TESTIT (logb, 1.0, 0.0); + TESTIT (logb, 1.5, 0.0); + TESTIT (logb, 2.0, 1.0); + TESTIT (logb, 100/3.0, 5.0); + TESTIT (logb, 0x1p5, 5.0); + TESTIT (logb, 0x1p10, 10.0); + TESTIT (logb, 0x1p20, 20.0); + TESTIT (logb, 0x1p30, 30.0); + TESTIT (logb, 0x1p40, 40.0); +#endif + + /* If radix == 2, test that ilogb(ARG2) -> ARG3. */ +#if __FLT_RADIX__ == 2 + TESTIT2 (ilogb, -0x1p40, 40); + TESTIT2 (ilogb, -0x1p30, 30); + TESTIT2 (ilogb, -0x1p20, 20); + TESTIT2 (ilogb, -0x1p10, 10); + TESTIT2 (ilogb, -0x1p5, 5); + TESTIT2 (ilogb, -100/3.0, 5); + TESTIT2 (ilogb, -2.0, 1); + TESTIT2 (ilogb, -1.5, 0); + TESTIT2 (ilogb, -1.0, 0); + TESTIT2 (ilogb, -1/3.0, -2); + TESTIT2 (ilogb, -1/9.0, -4); + TESTIT2 (ilogb, -0x1p-5, -5); + TESTIT2 (ilogb, -0x1p-10, -10); + TESTIT2 (ilogb, -0x1p-20, -20); + TESTIT2 (ilogb, -0x1p-30, -30); + TESTIT2 (ilogb, -0x1p-40, -40); + + TESTIT2 (ilogb, 0x1p-40, -40); + TESTIT2 (ilogb, 0x1p-30, -30); + TESTIT2 (ilogb, 0x1p-20, -20); + TESTIT2 (ilogb, 0x1p-10, -10); + TESTIT2 (ilogb, 0x1p-5, -5); + TESTIT2 (ilogb, 1/9.0, -4); + TESTIT2 (ilogb, 1/3.0, -2); + TESTIT2 (ilogb, 1.0, 0); + TESTIT2 (ilogb, 1.5, 0); + TESTIT2 (ilogb, 2.0, 1); + TESTIT2 (ilogb, 100/3.0, 5); + TESTIT2 (ilogb, 0x1p5, 5); + TESTIT2 (ilogb, 0x1p10, 10); + TESTIT2 (ilogb, 0x1p20, 20); + TESTIT2 (ilogb, 0x1p30, 30); + TESTIT2 (ilogb, 0x1p40, 40); +#endif + + /* If radix == 2, test that significand(ARG2) -> ARG3. Zero always + folds regardless of the radix. */ + TESTIT (significand, -0.0, -0.0); + TESTIT (significand, 0.0, 0.0); + +#if __FLT_RADIX__ == 2 + TESTIT (significand, -0x1p5, -1.0); + TESTIT (significand, -100/3.0, -100/96.0); + TESTIT (significand, -1.5, -1.5); + TESTIT (significand, -1.0, -1.0); + TESTIT (significand, -1/3.0, -4/3.0); + TESTIT (significand, -1/9.0, -16/9.0); + TESTIT (significand, -0x1p-5, -1.0); + + TESTIT (significand, 0x1p-5, 1.0); + TESTIT (significand, 1/9.0, 16/9.0); + TESTIT (significand, 1/3.0, 4/3.0); + TESTIT (significand, 1.0, 1.0); + TESTIT (significand, 1.5, 1.5); + TESTIT (significand, 100/3.0, 100/96.0); + TESTIT (significand, 0x1p5, 1.0); +#endif + + /* Test for f(+-Inf) -> +-Inf and f(+-NaN) -> +-NaN, regardless of + the radix. */ + TESTIT3 (logb, ,inf, , isinf, ); + TESTIT3 (logb, - ,inf, , isinf, ); + TESTIT3 (logb, ,nan, "", isnan, ); + TESTIT3 (logb, - ,nan, "", isnan, -); + + TESTIT3 (significand, ,inf, , isinf, ); + TESTIT3 (significand, - ,inf, , isinf, -); + TESTIT3 (significand, ,nan, "", isnan, ); + TESTIT3 (significand, - ,nan, "", isnan, -); +} + +int main() +{ + foo (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-math-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-math-1.c new file mode 100644 index 000000000..d052f5347 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-math-1.c @@ -0,0 +1,186 @@ +/* Copyright (C) 2002, 2003, 2004 Free Software Foundation. + + Verify that built-in math function constant folding of constant + arguments is correctly performed by the compiler. + + Written by Roger Sayle, 16th August 2002. */ + +/* { dg-do link } */ + +extern double atan (double); +extern float atanf (float); +extern long double atanl (long double); +extern double cbrt (double); +extern float cbrtf (float); +extern long double cbrtl (long double); +extern double cos (double); +extern float cosf (float); +extern long double cosl (long double); +extern double exp (double); +extern float expf (float); +extern long double expl (long double); +extern double log (double); +extern float logf (float); +extern long double logl (long double); +extern double pow (double, double); +extern float powf (float, float); +extern long double powl (long double, long double); +extern double sin (double); +extern float sinf (float); +extern long double sinl (long double); +extern double sqrt (double); +extern float sqrtf (float); +extern long double sqrtl (long double); +extern double tan (double); +extern float tanf (float); +extern long double tanl (long double); + +/* All references to link_error should go away at compile-time. */ +extern void link_error(void); + +void test (float f, double d, long double ld) +{ + if (sqrt (0.0) != 0.0) + link_error (); + + if (sqrt (1.0) != 1.0) + link_error (); + + if (cbrt (0.0) != 0.0) + link_error (); + + if (cbrt (1.0) != 1.0) + link_error (); + + if (cbrt (-1.0) != -1.0) + link_error (); + + if (exp (0.0) != 1.0) + link_error (); + + if (exp (1.0) <= 2.71 || exp (1.0) >= 2.72) + link_error (); + + if (log (1.0) != 0.0) + link_error (); + + if (sin (0.0) != 0.0) + link_error (); + + if (cos (0.0) != 1.0) + link_error (); + + if (tan (0.0) != 0.0) + link_error (); + + if (atan (0.0) != 0.0) + link_error (); + + if (4.0*atan (1.0) <= 3.14 || 4.0*atan (1.0) >= 3.15) + link_error (); + + if (pow (d, 0.0) != 1.0) + link_error (); + + if (pow (1.0, d) != 1.0) + link_error (); + + + if (sqrtf (0.0F) != 0.0F) + link_error (); + + if (sqrtf (1.0F) != 1.0F) + link_error (); + + if (cbrtf (0.0F) != 0.0F) + link_error (); + + if (cbrtf (1.0F) != 1.0F) + link_error (); + + if (cbrtf (-1.0F) != -1.0F) + link_error (); + + if (expf (0.0F) != 1.0F) + link_error (); + + if (expf (1.0F) <= 2.71F || expf (1.0F) >= 2.72F) + link_error (); + + if (logf (1.0F) != 0.0F) + link_error (); + + if (sinf (0.0F) != 0.0F) + link_error (); + + if (cosf (0.0F) != 1.0F) + link_error (); + + if (tanf (0.0F) != 0.0F) + link_error (); + + if (atanf (0.0F) != 0.0F) + link_error (); + + if (4.0F*atanf (1.0F) <= 3.14F || 4.0F*atanf (1.0F) >= 3.15F) + link_error (); + + if (powf (f, 0.0F) != 1.0F) + link_error (); + + if (powf (1.0F, f) != 1.0F) + link_error (); + + + if (sqrtl (0.0L) != 0.0L) + link_error (); + + if (sqrtl (1.0L) != 1.0L) + link_error (); + + if (cbrtl (0.0L) != 0.0L) + link_error (); + + if (cbrtl (1.0L) != 1.0L) + link_error (); + + if (cbrtl (-1.0L) != -1.0L) + link_error (); + + if (expl (0.0L) != 1.0L) + link_error (); + + if (expl (1.0L) <= 2.71L || expl (1.0L) >= 2.72L) + link_error (); + + if (logl (1.0L) != 0.0L) + link_error (); + + if (sinl (0.0L) != 0.0L) + link_error (); + + if (cosl (0.0L) != 1.0L) + link_error (); + + if (tanl (0.0L) != 0.0L) + link_error (); + + if (atanl (0.0) != 0.0L) + link_error (); + + if (4.0L*atanl (1.0L) <= 3.14L || 4.0L*atanl (1.0L) >= 3.15L) + link_error (); + + if (powl (ld, 0.0L) != 1.0L) + link_error (); + + if (powl (1.0L, ld) != 1.0L) + link_error (); +} + +int main() +{ + test (3.0, 3.0F, 3.0L); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-math-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-math-2.c new file mode 100644 index 000000000..7e2ff1383 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-math-2.c @@ -0,0 +1,385 @@ +/* Copyright (C) 2006, 2007 Free Software Foundation. + + Test things that should block GCC from optimizing compile-time + constants passed to a builtin transcendental function. + + Origin: Kaveh R. Ghazi, October 22, 2006. */ + +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ + +extern void foof (float); +extern void foo (double); +extern void fool (long double); + +#define TESTIT(FUNC, ARG) do { \ + foof (__builtin_##FUNC##f (ARG##F)); \ + foo (__builtin_##FUNC (ARG)); \ + fool (__builtin_##FUNC##l (ARG##L)); \ +} while (0) + +#define TESTIT2(FUNC, ARG1, ARG2) do { \ + foof (__builtin_##FUNC##f (ARG1##F, ARG2##F)); \ + foo (__builtin_##FUNC (ARG1, ARG2)); \ + fool (__builtin_##FUNC##l (ARG1##L, ARG2##L)); \ +} while (0) + +#define TESTIT2_I1(FUNC, ARG1, ARG2) do { \ + foof (__builtin_##FUNC##f (ARG1, ARG2##F)); \ + foo (__builtin_##FUNC (ARG1, ARG2)); \ + fool (__builtin_##FUNC##l (ARG1, ARG2##L)); \ +} while (0) + +#define TESTIT2_I2ALL(FUNC, ARGF, MAXF, ARGD, MAXD, ARGLD, MAXLD) do { \ + foof (__builtin_##FUNC##f (ARGF, MAXF)); \ + foo (__builtin_##FUNC (ARGD, MAXD)); \ + fool (__builtin_##FUNC##l (ARGLD, MAXLD)); \ +} while (0) + +#define TESTIT2_I2(FUNC, ARG1, ARG2) do { \ + foof (__builtin_##FUNC##f (ARG1##F, ARG2)); \ + foo (__builtin_##FUNC (ARG1, ARG2)); \ + fool (__builtin_##FUNC##l (ARG1##L, ARG2)); \ +} while (0) + +#define TESTIT_REMQUO(ARG1, ARG2) do { \ + int quo; \ + foof (__builtin_remquof (ARG1##F, ARG2##F, &quo)); \ + foo (__builtin_remquo (ARG1, ARG2, &quo)); \ + fool (__builtin_remquol (ARG1##L, ARG2##L, &quo)); \ +} while (0) + +#define TESTIT_REENT(FUNC,ARG1) do { \ + int sg; \ + foof (__builtin_##FUNC##f_r (ARG1##F, &sg)); \ + foo (__builtin_##FUNC##_r (ARG1, &sg)); \ + fool (__builtin_##FUNC##l_r (ARG1##L, &sg)); \ +} while (0) + +void bar() +{ + /* An argument of NaN is not evaluated at compile-time. */ +#ifndef __SPU__ + foof (__builtin_exp2f (__builtin_nanf(""))); +#endif + foo (__builtin_exp2 (__builtin_nan(""))); + fool (__builtin_exp2l (__builtin_nanl(""))); + + /* An argument of Inf/-Inf is not evaluated at compile-time. */ +#ifndef __SPU__ + foof (__builtin_exp2f (__builtin_inff())); +#endif + foo (__builtin_exp2 (__builtin_inf())); + fool (__builtin_exp2l (__builtin_infl())); +#ifndef __SPU__ + foof (__builtin_exp2f (-__builtin_inff())); +#endif + foo (__builtin_exp2 (-__builtin_inf())); + fool (__builtin_exp2l (-__builtin_infl())); + + /* Result overflows MPFR, which in version 2.2.x has 30 exponent bits. */ + TESTIT (exp2, 0x1p50); + /* Result underflows MPFR, which in version 2.2.x has 30 exponent bits. */ + TESTIT (exp2, -0x1p50); + + /* Result overflows GCC's REAL_VALUE_TYPE, which has 26 exponent bits. */ + TESTIT (exp2, 0x1p28); + /* Result underflows GCC's REAL_VALUE_TYPE, which has 26 exponent bits. */ + TESTIT (exp2, -0x1p28); + + /* Result overflows (even an extended) C double's mode. */ + TESTIT (exp2, 0x1p24); + /* Result underflows (even an extended) C double's mode. */ + TESTIT (exp2, -0x1p24); + + /* Ensure that normal arguments/results are folded. */ + TESTIT (exp2, 1.5); + TESTIT (exp2, -1.5); + + /* The asin arg must be [-1 ... 1] inclusive. */ + TESTIT (asin, -1.5); + TESTIT (asin, 1.5); + + /* The acos arg must be [-1 ... 1] inclusive. */ + TESTIT (acos, -1.5); + TESTIT (acos, 1.5); + + /* The acosh arg must be [1 ... Inf] inclusive. */ + TESTIT (acosh, 0.5); + + /* The atanh arg must be [-1 ... 1] EXclusive. */ + TESTIT (atanh, -1.0); + TESTIT (atanh, 1.0); + + /* The log* arg must be [0 ... Inf] EXclusive. */ + TESTIT (log, -1.0); + TESTIT (log, 0.0); + TESTIT (log, -0.0); + + TESTIT (log2, -1.0); + TESTIT (log2, 0.0); + TESTIT (log2, -0.0); + + TESTIT (log10, -1.0); + TESTIT (log10, 0.0); + TESTIT (log10, -0.0); + + /* The log1p arg must be [-1 ... Inf] EXclusive. */ + TESTIT (log1p, -2.0); + TESTIT (log1p, -1.0); + + /* The tgamma arg errors with zero or negative integers. */ + TESTIT (tgamma, 0.0); + TESTIT (tgamma, -0.0); + TESTIT (tgamma, -1.0); + TESTIT (tgamma, -2.0); + TESTIT (tgamma, -3.0); + + /* An argument of NaN is not evaluated at compile-time. */ +#ifndef __SPU__ + foof (__builtin_powf (__builtin_nanf(""), 2.5F)); +#endif + foo (__builtin_pow (__builtin_nan(""), 2.5)); + fool (__builtin_powl (__builtin_nanl(""), 2.5L)); +#ifndef __SPU__ + foof (__builtin_powf (2.5F, __builtin_nanf(""))); +#endif + foo (__builtin_pow (2.5, __builtin_nan(""))); + fool (__builtin_powl (2.5L, __builtin_nanl(""))); + + /* An argument of Inf/-Inf is not evaluated at compile-time. */ +#ifndef __SPU__ + foof (__builtin_powf (__builtin_inff(), 2.5F)); +#endif + foo (__builtin_pow (__builtin_inf(), 2.5)); + fool (__builtin_powl (__builtin_infl(), 2.5L)); +#ifndef __SPU__ + foof (__builtin_powf (-__builtin_inff(), 2.5F)); +#endif + foo (__builtin_pow (-__builtin_inf(), 2.5)); + fool (__builtin_powl (-__builtin_infl(), 2.5L)); +#ifndef __SPU__ + foof (__builtin_powf (2.5F, __builtin_inff())); +#endif + foo (__builtin_pow (2.5, __builtin_inf())); + fool (__builtin_powl (2.5L, __builtin_infl())); +#ifndef __SPU__ + foof (__builtin_powf (2.5F, -__builtin_inff())); +#endif + foo (__builtin_pow (2.5, -__builtin_inf())); + fool (__builtin_powl (2.5L, -__builtin_infl())); + + /* Check for Inv/NaN return values. */ + TESTIT2 (pow, -0.0, -4.5); /* Returns Inf */ + TESTIT2 (pow, 0.0, -4.5); /* Returns Inf */ + TESTIT2 (pow, -3.0, -4.5); /* Returns NaN */ + + /* Check for overflow/underflow. */ + foof (__builtin_powf (__FLT_MAX__, 3.5F)); + foo (__builtin_pow (__DBL_MAX__, 3.5)); + fool (__builtin_powl (__LDBL_MAX__, 3.5L)); + TESTIT2 (pow, 2.0, 0x1p50); + foof (__builtin_powf (__FLT_MAX__, -3.5F)); + foo (__builtin_pow (__DBL_MAX__, -3.5)); + fool (__builtin_powl (__LDBL_MAX__, -3.5L)); + TESTIT2 (pow, 2.0, -0x1p50); + + /* The sqrt arg must be [0 ... Inf] inclusive. */ + TESTIT (sqrt, -0.5); + TESTIT (sqrt, -0.0); + TESTIT (sqrt, 0.0); + + /* Check for overflow/underflow. */ + + /* These adjustments are too big. */ +#define FLT_EXP_ADJ (2*(__FLT_MAX_EXP__-__FLT_MIN_EXP__)+1) +#define DBL_EXP_ADJ (2*(__DBL_MAX_EXP__-__DBL_MIN_EXP__)+1) +#define LDBL_EXP_ADJ (2*(__LDBL_MAX_EXP__-__LDBL_MIN_EXP__)+1) + + TESTIT2_I2 (ldexp, 1.0, __INT_MAX__); + TESTIT2_I2 (ldexp, 1.0, -__INT_MAX__-1); + TESTIT2_I2 (ldexp, -1.0, __INT_MAX__); + TESTIT2_I2 (ldexp, -1.0, -__INT_MAX__-1); + TESTIT2_I2ALL (ldexp, __FLT_MIN__, FLT_EXP_ADJ, __DBL_MIN__, + DBL_EXP_ADJ, __LDBL_MIN__, LDBL_EXP_ADJ); + TESTIT2_I2ALL (ldexp, __FLT_MAX__, -FLT_EXP_ADJ, __DBL_MAX__, + -DBL_EXP_ADJ, __LDBL_MAX__, -LDBL_EXP_ADJ); + TESTIT2_I2ALL (ldexp, __FLT_MIN__, __FLT_MIN_EXP__, __DBL_MIN__, + __DBL_MIN_EXP__, __LDBL_MIN__, __LDBL_MIN_EXP__); + TESTIT2_I2ALL (ldexp, __FLT_MAX__, __FLT_MAX_EXP__, __DBL_MAX__, + __DBL_MAX_EXP__, __LDBL_MAX__, __LDBL_MAX_EXP__); + + TESTIT2_I2 (scalbn, 1.0, __INT_MAX__); + TESTIT2_I2 (scalbn, 1.0, -__INT_MAX__-1); + TESTIT2_I2 (scalbn, -1.0, __INT_MAX__); + TESTIT2_I2 (scalbn, -1.0, -__INT_MAX__-1); + TESTIT2_I2ALL (scalbn, __FLT_MIN__, FLT_EXP_ADJ, __DBL_MIN__, + DBL_EXP_ADJ, __LDBL_MIN__, LDBL_EXP_ADJ); + TESTIT2_I2ALL (scalbn, __FLT_MAX__, -FLT_EXP_ADJ, __DBL_MAX__, + -DBL_EXP_ADJ, __LDBL_MAX__, -LDBL_EXP_ADJ); + TESTIT2_I2ALL (scalbn, __FLT_MIN__, __FLT_MIN_EXP__, __DBL_MIN__, + __DBL_MIN_EXP__, __LDBL_MIN__, __LDBL_MIN_EXP__); + TESTIT2_I2ALL (scalbn, __FLT_MAX__, __FLT_MAX_EXP__, __DBL_MAX__, + __DBL_MAX_EXP__, __LDBL_MAX__, __LDBL_MAX_EXP__); + + TESTIT2_I2 (scalbln, 1.0, __LONG_MAX__); + TESTIT2_I2 (scalbln, 1.0, -__LONG_MAX__-1); + TESTIT2_I2 (scalbln, -1.0, __LONG_MAX__); + TESTIT2_I2 (scalbln, -1.0, -__LONG_MAX__-1); + TESTIT2_I2ALL (scalbln, __FLT_MIN__, FLT_EXP_ADJ, __DBL_MIN__, + DBL_EXP_ADJ, __LDBL_MIN__, LDBL_EXP_ADJ); + TESTIT2_I2ALL (scalbln, __FLT_MAX__, -FLT_EXP_ADJ, __DBL_MAX__, + -DBL_EXP_ADJ, __LDBL_MAX__, -LDBL_EXP_ADJ); + TESTIT2_I2ALL (scalbln, __FLT_MIN__, __FLT_MIN_EXP__, __DBL_MIN__, + __DBL_MIN_EXP__, __LDBL_MIN__, __LDBL_MIN_EXP__); + TESTIT2_I2ALL (scalbln, __FLT_MAX__, __FLT_MAX_EXP__, __DBL_MAX__, + __DBL_MAX_EXP__, __LDBL_MAX__, __LDBL_MAX_EXP__); + + TESTIT (logb, 0.0); + TESTIT (logb, -0.0); + + TESTIT (ilogb, 0.0); + TESTIT (ilogb, -0.0); + +#ifndef __SPU__ + foof (__builtin_ilogbf (__builtin_inff())); +#endif + foo (__builtin_ilogb (__builtin_inf())); + fool (__builtin_ilogbl (__builtin_infl())); +#ifndef __SPU__ + foof (__builtin_ilogbf (-__builtin_inff())); +#endif + foo (__builtin_ilogb (-__builtin_inf())); + fool (__builtin_ilogbl (-__builtin_infl())); + +#ifndef __SPU__ + foof (__builtin_ilogbf (__builtin_nanf(""))); +#endif + foo (__builtin_ilogb (__builtin_nan(""))); + fool (__builtin_ilogbl (__builtin_nanl(""))); +#ifndef __SPU__ + foof (__builtin_ilogbf (-__builtin_nanf(""))); +#endif + foo (__builtin_ilogb (-__builtin_nan(""))); + fool (__builtin_ilogbl (-__builtin_nanl(""))); + + /* The y* arg must be [0 ... Inf] EXclusive. */ + TESTIT (y0, -1.0); + TESTIT (y0, 0.0); + TESTIT (y0, -0.0); + + TESTIT (y1, -1.0); + TESTIT (y1, 0.0); + TESTIT (y1, -0.0); + + TESTIT2_I1 (yn, 2, -1.0); + TESTIT2_I1 (yn, 2, 0.0); + TESTIT2_I1 (yn, 2, -0.0); + + TESTIT2_I1 (yn, -3, -1.0); + TESTIT2_I1 (yn, -3, 0.0); + TESTIT2_I1 (yn, -3, -0.0); + + /* The second argument of remquo/remainder/drem must not be 0. */ + TESTIT_REMQUO (1.0, 0.0); + TESTIT_REMQUO (1.0, -0.0); + TESTIT2 (remainder, 1.0, 0.0); + TESTIT2 (remainder, 1.0, -0.0); + TESTIT2 (drem, 1.0, 0.0); + TESTIT2 (drem, 1.0, -0.0); + + /* The argument to lgamma* cannot be zero or a negative integer. */ + TESTIT_REENT (lgamma, -4.0); /* lgamma_r */ + TESTIT_REENT (lgamma, -3.0); /* lgamma_r */ + TESTIT_REENT (lgamma, -2.0); /* lgamma_r */ + TESTIT_REENT (lgamma, -1.0); /* lgamma_r */ + TESTIT_REENT (lgamma, -0.0); /* lgamma_r */ + TESTIT_REENT (lgamma, 0.0); /* lgamma_r */ + + TESTIT_REENT (gamma, -4.0); /* gamma_r */ + TESTIT_REENT (gamma, -3.0); /* gamma_r */ + TESTIT_REENT (gamma, -2.0); /* gamma_r */ + TESTIT_REENT (gamma, -1.0); /* gamma_r */ + TESTIT_REENT (gamma, -0.0); /* gamma_r */ + TESTIT_REENT (gamma, 0.0); /* gamma_r */ +} + +/* { dg-final { scan-tree-dump-times "exp2 " 9 "original" } } */ +/* { dg-final { scan-tree-dump-times "exp2f" 9 "original" { target { ! { spu*-*-* } } } } } */ +/* { dg-final { scan-tree-dump-times "exp2f" 6 "original" { target { spu*-*-* } } } } */ +/* { dg-final { scan-tree-dump-times "exp2l" 9 "original" } } */ +/* { dg-final { scan-tree-dump-times "asin " 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "asinf" 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "asinl" 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "acos " 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "acosf" 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "acosl" 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "acosh " 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "acoshf" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "acoshl" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "atanh " 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "atanhf" 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "atanhl" 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "log " 3 "original" } } */ +/* { dg-final { scan-tree-dump-times "logf" 3 "original" } } */ +/* { dg-final { scan-tree-dump-times "logl" 3 "original" } } */ +/* { dg-final { scan-tree-dump-times "log2 " 3 "original" } } */ +/* { dg-final { scan-tree-dump-times "log2f" 3 "original" } } */ +/* { dg-final { scan-tree-dump-times "log2l" 3 "original" } } */ +/* { dg-final { scan-tree-dump-times "log10 " 3 "original" } } */ +/* { dg-final { scan-tree-dump-times "log10f" 3 "original" } } */ +/* { dg-final { scan-tree-dump-times "log10l" 3 "original" } } */ +/* { dg-final { scan-tree-dump-times "log1p " 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "log1pf" 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "log1pl" 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "tgamma " 5 "original" } } */ +/* { dg-final { scan-tree-dump-times "tgammaf" 5 "original" } } */ +/* { dg-final { scan-tree-dump-times "tgammal" 5 "original" } } */ +/* { dg-final { scan-tree-dump-times "pow " 13 "original" } } */ +/* { dg-final { scan-tree-dump-times "powf" 13 "original" { target { ! { spu*-*-* } } } } } */ +/* { dg-final { scan-tree-dump-times "powf" 7 "original" { target { spu*-*-* } } } } */ +/* { dg-final { scan-tree-dump-times "powl" 13 "original" } } */ +/* { dg-final { scan-tree-dump-times "sqrt " 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "sqrtf" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "sqrtl" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "ldexp " 8 "original" } } */ +/* { dg-final { scan-tree-dump-times "ldexpf" 8 "original" } } */ +/* { dg-final { scan-tree-dump-times "ldexpl" 8 "original" } } */ +/* { dg-final { scan-tree-dump-times "scalbn " 8 "original" } } */ +/* { dg-final { scan-tree-dump-times "scalbnf" 8 "original" } } */ +/* { dg-final { scan-tree-dump-times "scalbnl" 8 "original" } } */ +/* { dg-final { scan-tree-dump-times "scalbln " 8 "original" } } */ +/* { dg-final { scan-tree-dump-times "scalblnf" 8 "original" } } */ +/* { dg-final { scan-tree-dump-times "scalblnl" 8 "original" } } */ +/* { dg-final { scan-tree-dump-times "_logb " 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "_logbf" 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "_logbl" 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "ilogb " 6 "original" } } */ +/* { dg-final { scan-tree-dump-times "ilogbf" 6 "original" { target { ! { spu*-*-* } } } } } */ +/* { dg-final { scan-tree-dump-times "ilogbf" 2 "original" { target { spu*-*-* } } } } */ +/* { dg-final { scan-tree-dump-times "ilogbl" 6 "original" } } */ +/* { dg-final { scan-tree-dump-times "y0 " 3 "original" } } */ +/* { dg-final { scan-tree-dump-times "y0f" 3 "original" } } */ +/* { dg-final { scan-tree-dump-times "y0l" 3 "original" } } */ +/* { dg-final { scan-tree-dump-times "y1 " 3 "original" } } */ +/* { dg-final { scan-tree-dump-times "y1f" 3 "original" } } */ +/* { dg-final { scan-tree-dump-times "y1l" 3 "original" } } */ +/* { dg-final { scan-tree-dump-times "yn " 6 "original" } } */ +/* { dg-final { scan-tree-dump-times "ynf" 6 "original" } } */ +/* { dg-final { scan-tree-dump-times "ynl" 6 "original" } } */ +/* { dg-final { scan-tree-dump-times "remquo " 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "remquof" 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "remquol" 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "remainder " 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "remainderf" 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "remainderl" 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "drem " 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "dremf" 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "dreml" 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "lgamma_r " 6 "original" } } */ +/* { dg-final { scan-tree-dump-times "lgammaf_r" 6 "original" } } */ +/* { dg-final { scan-tree-dump-times "lgammal_r" 6 "original" } } */ +/* { dg-final { scan-tree-dump-times "_gamma_r " 6 "original" } } */ +/* { dg-final { scan-tree-dump-times "_gammaf_r" 6 "original" } } */ +/* { dg-final { scan-tree-dump-times "_gammal_r" 6 "original" } } */ +/* { dg-final { cleanup-tree-dump "original" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-math-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-math-3.c new file mode 100644 index 000000000..896edccaa --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-math-3.c @@ -0,0 +1,374 @@ +/* Copyright (C) 2006 Free Software Foundation. + + Verify that built-in math function constant folding of constant + arguments is correctly performed by the compiler. + + Origin: Kaveh R. Ghazi, October 23, 2006. */ + +/* { dg-do link } */ + +/* Define "e" with as many bits as found in builtins.c:dconste. */ +#define M_E 2.7182818284590452353602874713526624977572470936999595749669676277241 + +/* All references to link_error should go away at compile-time. */ +extern void link_error(int); + +/* Return TRUE if the sign of X != sign of Y. This is important when + comparing signed zeros. */ +#define CKSGN_F(X,Y) \ + (__builtin_copysignf(1.0F,(X)) != __builtin_copysignf(1.0F,(Y))) +#define CKSGN(X,Y) \ + (__builtin_copysign(1.0,(X)) != __builtin_copysign(1.0,(Y))) +#define CKSGN_L(X,Y) \ + (__builtin_copysignl(1.0L,(X)) != __builtin_copysignl(1.0L,(Y))) + +/* Test that FUNC(ARG) == (RES). */ +#define TESTIT(FUNC,ARG,RES) do { \ + if (__builtin_##FUNC##f(ARG##F) != RES##F \ + || CKSGN_F(__builtin_##FUNC##f(ARG##F),RES##F)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC(ARG) != RES \ + || CKSGN(__builtin_##FUNC(ARG),RES)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC##l(ARG##L) != RES##L \ + || CKSGN_L(__builtin_##FUNC##l(ARG##L),RES##L)) \ + link_error(__LINE__); \ + } while (0) + +/* Range test, check that (LOW) < FUNC(ARG) < (HI). */ +#define TESTIT_R(FUNC,ARG,LOW,HI) do { \ + if (__builtin_##FUNC##f(ARG) <= (LOW) || __builtin_##FUNC##f(ARG) >= (HI)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC(ARG) <= (LOW) || __builtin_##FUNC(ARG) >= (HI)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC##l(ARG) <= (LOW) || __builtin_##FUNC##l(ARG) >= (HI)) \ + link_error(__LINE__); \ + } while (0) + +/* Test that FUNC(ARG1, ARG2) == (RES). */ +#define TESTIT2(FUNC,ARG1,ARG2,RES) do { \ + if (__builtin_##FUNC##f(ARG1##F, ARG2##F) != RES##F \ + || CKSGN_F(__builtin_##FUNC##f(ARG1##F,ARG2##F),RES##F)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC(ARG1, ARG2) != RES \ + || CKSGN(__builtin_##FUNC(ARG1,ARG2),RES)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC##l(ARG1##L, ARG2##L) != RES##L \ + || CKSGN_L(__builtin_##FUNC##l(ARG1##L,ARG2##L),RES##L)) \ + link_error(__LINE__); \ + } while (0) + +/* Range test, check that (LOW) < FUNC(ARG1,ARG2) < (HI). */ +#define TESTIT2_R(FUNC,ARG1,ARG2,LOW,HI) do { \ + if (__builtin_##FUNC##f(ARG1, ARG2) <= (LOW) \ + || __builtin_##FUNC##f(ARG1, ARG2) >= (HI)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC(ARG1, ARG2) <= (LOW) \ + || __builtin_##FUNC(ARG1, ARG2) >= (HI)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC##l(ARG1, ARG2) <= (LOW) \ + || __builtin_##FUNC##l(ARG1, ARG2) >= (HI)) \ + link_error(__LINE__); \ + } while (0) + +/* Test that FUNC(ARG1, ARG2, ARG3) == (RES). */ +#define TESTIT3(FUNC,ARG1,ARG2,ARG3,RES) do { \ + if (__builtin_##FUNC##f(ARG1##F, ARG2##F, ARG3##F) != RES##F \ + || CKSGN_F(__builtin_##FUNC##f(ARG1##F,ARG2##F,ARG3##F),RES##F)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC(ARG1, ARG2, ARG3) != RES \ + || CKSGN(__builtin_##FUNC(ARG1,ARG2,ARG3),RES)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC##l(ARG1##L, ARG2##L, ARG3##L) != RES##L \ + || CKSGN_L(__builtin_##FUNC##l(ARG1##L,ARG2##L,ARG3##L),RES##L)) \ + link_error(__LINE__); \ + } while (0) + +/* Test that for FUNC(ARG, &ARG_S, &ARG_C); + assert (ARG_S == RES_S && ARG_C == RES_C);. */ +#define TESTIT_2P(FUNC,ARG,ARG_S,ARG_C,RES_S,RES_C) do { \ + __builtin_##FUNC##f(ARG##F, &ARG_S##f, &ARG_C##f); \ + if (ARG_S##f != (RES_S##F) || ARG_C##f != (RES_C##F)) \ + link_error(__LINE__); \ + __builtin_##FUNC(ARG, &ARG_S, &ARG_C); \ + if (ARG_S != (RES_S) || ARG_C != (RES_C)) \ + link_error(__LINE__); \ + __builtin_##FUNC##l(ARG##L, &ARG_S##l, &ARG_C##l); \ + if (ARG_S##l != (RES_S##L) || ARG_C##l != (RES_C##L)) \ + link_error(__LINE__); \ + } while (0) + +/* Test that for FUNC(ARG, &ARG_S, &ARG_C); + assert (LOW_S < ARG_S < HI_S && LOW_C < ARG_C < HI_C);. */ +#define TESTIT_2P_R(FUNC,ARG,ARG_S,ARG_C,LOW_S,HI_S,LOW_C,HI_C) do { \ + __builtin_##FUNC##f(ARG##F, &ARG_S##f, &ARG_C##f); \ + if (ARG_S##f <= (LOW_S##F) || ARG_S##f >= (HI_S##F) \ + || ARG_C##f <= (LOW_C##F) || ARG_C##f >= (HI_C##F)) \ + link_error(__LINE__); \ + __builtin_##FUNC(ARG, &ARG_S, &ARG_C); \ + if (ARG_S <= (LOW_S) || ARG_S >= (HI_S) \ + || ARG_C <= (LOW_C) || ARG_C >= (HI_C)) \ + link_error(__LINE__); \ + __builtin_##FUNC##l(ARG##L, &ARG_S##l, &ARG_C##l); \ + if (ARG_S##l <= (LOW_S##L) || ARG_S##l >= (HI_S##L) \ + || ARG_C##l <= (LOW_C##L) || ARG_C##l >= (HI_C##L)) \ + link_error(__LINE__); \ + } while (0) + +int main (void) +{ +#ifdef __OPTIMIZE__ + float sf, cf, oneF = 1.0F; + double s, c, one = 1.0; + long double sl, cl, oneL = 1.0L; +#endif + + TESTIT_R (asin, -1.0, -3.15/2.0, -3.14/2.0); /* asin(-1) == -pi/2 */ + TESTIT (asin, 0.0, 0.0); /* asin(0) == 0 */ + TESTIT (asin, -0.0, -0.0); /* asin(-0) == -0 */ + TESTIT_R (asin, 1.0, 3.14/2.0, 3.15/2.0); /* asin(1) == pi/2 */ + + TESTIT_R (acos, -1.0, 3.14, 3.15); /* acos(-1) == pi */ + TESTIT_R (acos, 0.0, 3.14/2.0, 3.15/2.0); /* acos(0) == pi/2 */ + TESTIT_R (acos, -0.0, 3.14/2.0, 3.15/2.0); /* acos(-0) == pi/2 */ + TESTIT (acos, 1.0, 0.0); /* acos(1) == 0 */ + + TESTIT_R (atan, -1.0, -3.15/4.0, -3.14/4.0); /* atan(-1) == -pi/4 */ + TESTIT (atan, 0.0, 0.0); /* atan(0) == 0 */ + TESTIT (atan, -0.0, -0.0); /* atan(-0) == -0 */ + TESTIT_R (atan, 1.0, 3.14/4.0, 3.15/4.0); /* atan(1) == pi/4 */ + + TESTIT_R (asinh, -1.0, -0.89, -0.88); /* asinh(-1) == -0.881... */ + TESTIT (asinh, 0.0, 0.0); /* asinh(0) == 0 */ + TESTIT (asinh, -0.0, -0.0); /* asinh(-0) == -0 */ + TESTIT_R (asinh, 1.0, 0.88, 0.89); /* asinh(1) == 0.881... */ + + TESTIT (acosh, 1.0, 0.0); /* acosh(1) == 0. */ + TESTIT_R (acosh, 2.0, 1.31, 1.32); /* acosh(2) == 1.316... */ + + TESTIT_R (atanh, -0.5, -0.55, -0.54); /* atanh(-0.5) == -0.549... */ + TESTIT (atanh, 0.0, 0.0); /* atanh(0) == 0 */ + TESTIT (atanh, -0.0, -0.0); /* atanh(-0) == -0 */ + TESTIT_R (atanh, 0.5, 0.54, 0.55); /* atanh(0.5) == 0.549... */ + + TESTIT_R (sin, -1.0, -0.85, -0.84); /* sin(-1) == -0.841... */ + TESTIT (sin, 0.0, 0.0); /* sin(0) == 0 */ + TESTIT (sin, -0.0, -0.0); /* sin(-0) == -0 */ + TESTIT_R (sin, 1.0, 0.84, 0.85); /* sin(1) == 0.841... */ + + TESTIT_R (cos, -1.0, 0.54, 0.55); /* cos(-1) == 0.5403... */ + TESTIT (cos, 0.0, 1.0); /* cos(0) == 1 */ + TESTIT (cos, -0.0, 1.0); /* cos(-0) == 1 */ + TESTIT_R (cos, 1.0, 0.54, 0.55); /* cos(1) == 0.5403... */ + + TESTIT_R (tan, -1.0, -1.56, 1.55); /* tan(-1) == -1.557... */ + TESTIT (tan, 0.0, 0.0); /* tan(0) == 0 */ + TESTIT (tan, -0.0, -0.0); /* tan(-0) == -0 */ + TESTIT_R (tan, 1.0, 1.55, 1.56); /* tan(1) == 1.557... */ + +#ifdef __OPTIMIZE__ + /* These tests rely on propagating the variables s, c and one, which + happens only when optimization is turned on. */ + TESTIT_2P_R (sincos, -1.0, s, c, -0.85, -0.84, 0.54, 0.55); /* (s==-0.841..., c==0.5403...) */ + TESTIT_2P (sincos, 0.0, s, c, 0.0, 1.0); /* (s==0, c==1) */ + TESTIT_2P (sincos, -0.0, s, c, -0.0, 1.0); /* (s==-0, c==1) */ + TESTIT_2P_R (sincos, 1.0, s, c, 0.84, 0.85, 0.54, 0.55); /* (s==0.841..., c==0.5403...) */ + TESTIT_2P_R (sincos, one, s, c, 0.84, 0.85, 0.54, 0.55); /* (s==0.841..., c==0.5403...) */ + TESTIT_2P_R (sincos, -one, s, c, -0.85, -0.84, 0.54, 0.55); /* (s==-0.841..., c==0.5403...) */ +#endif + + TESTIT_R (sinh, -1.0, -1.18, -1.17); /* sinh(-1) == -1.175... */ + TESTIT (sinh, 0.0, 0.0); /* sinh(0) == 0 */ + TESTIT (sinh, -0.0, -0.0); /* sinh(-0) == -0 */ + TESTIT_R (sinh, 1.0, 1.17, 1.18); /* sinh(1) == 1.175... */ + + TESTIT_R (cosh, -1.0, 1.54, 1.55); /* cosh(-1) == 1.543... */ + TESTIT (cosh, 0.0, 1.0); /* cosh(0) == 1 */ + TESTIT (cosh, -0.0, 1.0); /* cosh(-0) == 1 */ + TESTIT_R (cosh, 1.0, 1.54, 1.55); /* cosh(1) == 1.543... */ + + TESTIT_R (tanh, -1.0, -0.77, -0.76); /* tanh(-1) == -0.761... */ + TESTIT (tanh, -0.0, -0.0); /* tanh(-0) == -0 */ + TESTIT (tanh, 0.0, 0.0); /* tanh(0) == 0 */ + TESTIT_R (tanh, 1.0, 0.76, 0.77); /* tanh(1) == 0.761... */ + + TESTIT_R (exp, -1.0, 0.36, 0.37); /* exp(-1) == 1/e */ + TESTIT (exp, -0.0, 1.0); /* exp(-0) == 1 */ + TESTIT (exp, 0.0, 1.0); /* exp(0) == 1 */ + TESTIT_R (exp, 1.0, 2.71, 2.72); /* exp(1) == e */ + + TESTIT (exp2, -1.0, 0.5); /* exp2(-1) == 1/2 */ + TESTIT (exp2, -0.0, 1.0); /* exp2(-0) == 1 */ + TESTIT (exp2, 0.0, 1.0); /* exp2(0) == 1 */ + TESTIT (exp2, 1.0, 2.0); /* exp2(1) == 2 */ + + TESTIT (exp10, -1.0, 0.1); /* exp10(-1) == 1/10 */ + TESTIT (exp10, -0.0, 1.0); /* exp10(-0) == 1 */ + TESTIT (exp10, 0.0, 1.0); /* exp10(0) == 1 */ + TESTIT (exp10, 1.0, 10.0); /* exp10(1) == 10 */ + + TESTIT (pow10, -1.0, 0.1); /* pow10(-1) == 1/10 */ + TESTIT (pow10, -0.0, 1.0); /* pow10(-0) == 1 */ + TESTIT (pow10, 0.0, 1.0); /* pow10(0) == 1 */ + TESTIT (pow10, 1.0, 10.0); /* pow10(1) == 10 */ + + TESTIT_R (expm1, -1.0, -0.64, -0.63); /* expm1(-1) == 1/e - 1 */ + TESTIT (expm1, -0.0, -0.0); /* expm1(-0) == 0 */ + TESTIT (expm1, 0.0, 0.0); /* expm1(0) == 0 */ + TESTIT_R (expm1, 1.0, 1.71, 1.72); /* expm1(1) == e - 1 */ + + TESTIT (log, 1.0, 0.0); /* log(1) == 0 */ + TESTIT_R (log, M_E, 0.99, 1.01); /* log(e) == 1.000... */ + TESTIT_R (log, M_E*M_E, 1.99, 2.01); /* log(e*e) == 2.000... */ + + TESTIT (log2, 1.0, 0.0); /* log2(1) == 0 */ + TESTIT (log2, 2.0, 1.0); /* log2(2) == 1 */ + TESTIT (log2, 4.0, 2.0); /* log2(4) == 2 */ + + TESTIT (log10, 1.0, 0.0); /* log10(1) == 0 */ + TESTIT (log10, 10.0, 1.0); /* log10(10) == 1 */ + TESTIT (log10, 100.0, 2.0); /* log10(100) == 2 */ + + TESTIT (log1p, 0.0, 0.0); /* log1p(0) == 0 */ + TESTIT (log1p, -0.0, -0.0); /* log1p(-0) == -0 */ + TESTIT_R (log1p, M_E-1, 0.99, 1.01); /* log1p(e-1) == 1.000... */ + TESTIT_R (log1p, M_E*M_E-1, 1.99, 2.01); /* log1p(e*e-1) == 2.000... */ + + TESTIT (cbrt, -0.0, -0.0); /* cbrt(-0) == -0 */ + TESTIT (cbrt, 0.0, 0.0); /* cbrt(0) == 0 */ + TESTIT (cbrt, 1.0, 1.0); /* cbrt(1) == 1 */ + TESTIT (cbrt, -1.0, -1.0); /* cbrt(-1) == -1 */ + TESTIT (cbrt, 8.0, 2.0); /* cbrt(8) == 2 */ + TESTIT (cbrt, -8.0, -2.0); /* cbrt(-8) == -2 */ + + TESTIT (erf, -0.0, -0.0); /* erf(-0) == -0 */ + TESTIT (erf, 0.0, 0.0); /* erf(0) == 0 */ + TESTIT_R (erf, 1.0, 0.84, 0.85); /* erf(1) == 0.842... */ + TESTIT_R (erf, -1.0, -0.85, -0.84); /* erf(-1) == -0.842... */ + + TESTIT (erfc, -0.0, 1.0); /* erfc(-0) == 1 */ + TESTIT (erfc, 0.0, 1.0); /* erfc(0) == 1 */ + TESTIT_R (erfc, 1.0, 0.15, 0.16); /* erfc(1) == 0.157... */ + TESTIT_R (erfc, -1.0, 1.84, 1.85); /* erfc(-1) == 1.842... */ + + TESTIT_R (tgamma, -4.5, -0.061, -0.060); /* tgamma(-4.5) == -0.06001... */ + TESTIT_R (tgamma, -3.5, 0.27, 0.28); /* tgamma(-3.5) == 0.27008... */ + TESTIT_R (tgamma, -2.5, -0.95, -0.94); /* tgamma(-2.5) == -0.945... */ + TESTIT_R (tgamma, -1.5, 2.36, 2.37); /* tgamma(-1.5) == 2.363... */ + TESTIT_R (tgamma, -0.5, -3.55, -3.54); /* tgamma(-0.5) == -3.544... */ + TESTIT_R (tgamma, 0.5, 1.77, 1.78); /* tgamma(0.5) == 1.772... */ + TESTIT (tgamma, 1.0, 1.0); /* tgamma(1) == 1 */ + TESTIT_R (tgamma, 1.5, 0.88, 0.89); /* tgamma(1.5) == 0.886... */ + TESTIT (tgamma, 2.0, 1.0); /* tgamma(2) == 1 */ + TESTIT_R (tgamma, 2.5, 1.32, 1.33); /* tgamma(2.5) == 1.329... */ + TESTIT (tgamma, 3.0, 2.0); /* tgamma(3) == 2 */ + TESTIT_R (tgamma, 3.5, 3.32, 3.33); /* tgamma(3.5) == 3.323... */ + TESTIT (tgamma, 4.0, 6.0); /* tgamma(4) == 6 */ + TESTIT_R (tgamma, 4.5, 11.63, 11.64); /* tgamma(4.5) == 11.631... */ + + TESTIT2 (pow, 3.0, 4.0, 81.0); /* pow(3,4) == 81 */ + TESTIT2 (pow, -3.0, 5.0, -243.0); /* pow(-3,5) == -243 */ + TESTIT2 (pow, 16.0, 0.25, 2.0); /* pow(16,1/4) == 2 */ + TESTIT2 (pow, 4.0, -2.0, 0.0625); /* pow(4,-2) == 1/16 */ + TESTIT2 (pow, -2.0, -3.0, -0.125); /* pow(-2,-3) == -1/8 */ + TESTIT2_R (pow, -1.5, -3.0, -0.297, -0.296); /* pow(-1.5,-3) == -1/3.375 */ + + TESTIT2 (hypot, 0.0, 0.0, 0.0); /* hypot(0,0) == 0 */ + TESTIT2 (hypot, -0.0, 0.0, 0.0); /* hypot(-0,0) == 0 */ + TESTIT2 (hypot, 0.0, -0.0, 0.0); /* hypot(0,-0) == 0 */ + TESTIT2 (hypot, -0.0, -0.0, 0.0); /* hypot(-0,-0) == 0 */ + TESTIT2 (hypot, 3.0, 4.0, 5.0); /* hypot(3,4) == 5 */ + TESTIT2 (hypot, -3.0, 4.0, 5.0); /* hypot(-3,4) == 5 */ + TESTIT2 (hypot, 3.0, -4.0, 5.0); /* hypot(3,-4) == 5 */ + TESTIT2 (hypot, -3.0, -4.0, 5.0); /* hypot(-3,-4) == 5 */ + TESTIT2_R (hypot, 4.0, 5.0, 6.40, 6.41); /* hypot(4,5) == 6.403... */ + + TESTIT2 (atan2, 0.0, 0.0, 0.0); /* atan2(0,0) == 0 */ + TESTIT2 (atan2, -0.0, 0.0, -0.0); /* atan2(-0,0) == -0 */ + TESTIT2_R (atan2, 0.0, -0.0, 3.14, 3.15); /* atan2(0,-0) == pi */ + TESTIT2_R (atan2, -0.0, -0.0, -3.15, -3.14); /* atan2(-0,-0) == -pi */ + TESTIT2_R (atan2, 0.0, -1.0, 3.14, 3.15); /* atan2(0,-1) == pi */ + TESTIT2_R (atan2, -0.0, -1.0, -3.15, -3.14); /* atan2(-0,-1) == -pi */ + TESTIT2 (atan2, 0.0, 1.0, 0.0); /* atan2(0,1) == 0 */ + TESTIT2 (atan2, -0.0, 1.0, -0.0); /* atan2(-0,1) == -0 */ + TESTIT2_R (atan2, -1.0, 0.0, -1.58, -1.57); /* atan2(-1,0) == -pi/2 */ + TESTIT2_R (atan2, 1.0, 0.0, 1.57, 1.58); /* atan2(1,0) == pi/2 */ + + TESTIT2 (fdim, 0.0, 0.0, 0.0); /* fdim(0,0) == 0 */ + TESTIT2 (fdim, -0.0, 0.0, 0.0); /* fdim(-0,0) == 0 */ + TESTIT2 (fdim, 0.0, -0.0, 0.0); /* fdim(0,-0) == 0 */ + TESTIT2 (fdim, -0.0, -0.0, 0.0); /* fdim(-0,-0) == 0 */ + TESTIT2 (fdim, 5.0, 5.0, 0.0); /* fdim(5,5) == 0 */ + TESTIT2 (fdim, 5.0, 6.0, 0.0); /* fdim(5,6) == 0 */ + TESTIT2 (fdim, 6.0, 5.0, 1.0); /* fdim(6,5) == 1 */ + TESTIT2 (fdim, -5.0, -6.0, 1.0); /* fdim(-5,-6) == 1 */ + TESTIT2 (fdim, -6.0, -5.0, 0.0); /* fdim(-6,-5) == 0 */ + + TESTIT2 (fmin, 5.0, 6.0, 5.0); /* fmin(5,6) == 5 */ + TESTIT2 (fmin, 6.0, 5.0, 5.0); /* fmin(6,5) == 5 */ + TESTIT2 (fmin, -5.0, -6.0, -6.0); /* fmin(-5,-6) == -6 */ + TESTIT2 (fmin, -6.0, -5.0, -6.0); /* fmin(-6,-5) == -6 */ + TESTIT2 (fmin, -0.0, 0.0, -0.0); /* fmin(-0,0) == -0 */ + TESTIT2 (fmin, 0.0, -0.0, -0.0); /* fmin(-0,0) == -0 */ + + TESTIT2 (fmax, 5.0, 6.0, 6.0); /* fmax(5,6) == 6 */ + TESTIT2 (fmax, 6.0, 5.0, 6.0); /* fmax(6,5) == 6 */ + TESTIT2 (fmax, -5.0, -6.0, -5.0); /* fmax(-5,-6) == -5 */ + TESTIT2 (fmax, -6.0, -5.0, -5.0); /* fmax(-6,-5) == -5 */ + TESTIT2 (fmax, -0.0, 0.0, 0.0); /* fmax(-0,0) == 0 */ + TESTIT2 (fmax, 0.0, -0.0, 0.0); /* fmax(-0,0) == 0 */ + + TESTIT3 (fma, 2.0, 3.0, 4.0, 10.0); /* fma(2,3,4) == 10 */ + TESTIT3 (fma, 2.0, -3.0, 4.0, -2.0); /* fma(2,-3,4) == -2 */ + TESTIT3 (fma, 2.0, 3.0, -4.0, 2.0); /* fma(2,3,-4) == 2 */ + TESTIT3 (fma, 2.0, -3.0, -4.0, -10.0); /* fma(2,-3,-4) == -10 */ + TESTIT3 (fma, -2.0, -3.0, -4.0, 2.0); /* fma(-2,-3,-4) == 2 */ + TESTIT3 (fma, 6.0, -0.0, 0.0, 0.0); /* fma(6,-0,0) == 0 */ + TESTIT3 (fma, -0.0, 6.0, 0.0, 0.0); /* fma(-0,6,0) == 0 */ + TESTIT3 (fma, 6.0, -0.0, -0.0, -0.0); /* fma(6,-0,-0) == -0 */ + TESTIT3 (fma, -0.0, 6.0, -0.0, -0.0); /* fma(-0,6,-0) == -0 */ + TESTIT3 (fma, 0.0, 0.0, 0.0, 0.0); /* fma(0,0,0) == 0 */ + TESTIT3 (fma, -0.0, 0.0, 0.0, 0.0); /* fma(-0,0,0) == 0 */ + TESTIT3 (fma, 0.0, -0.0, 0.0, 0.0); /* fma(0,-0,0) == 0 */ + TESTIT3 (fma, -0.0, -0.0, 0.0, 0.0); /* fma(-0,-0,0) == 0 */ + TESTIT3 (fma, 0.0, 0.0, -0.0, 0.0); /* fma(0,0,-0) == 0 */ + TESTIT3 (fma, -0.0, 0.0, -0.0, -0.0); /* fma(-0,0,-0) == -0 */ + TESTIT3 (fma, 0.0, -0.0, -0.0, -0.0); /* fma(0,-0,-0) == -0 */ + TESTIT3 (fma, -0.0, -0.0, -0.0, 0.0); /* fma(-0,-0,-0) == 0 */ + + if (__builtin_fmaf(__FLT_MAX__, 2.0F, -__FLT_MAX__) != __FLT_MAX__) + link_error (__LINE__); + if (__builtin_fmaf(2.0F,__FLT_MAX__, -__FLT_MAX__) != __FLT_MAX__) + link_error (__LINE__); + if (__builtin_fmaf(__FLT_MIN__, 0.5F, __FLT_MIN__) != __FLT_MIN__*1.5F) + link_error (__LINE__); + if (__builtin_fmaf(0.5F,__FLT_MIN__, __FLT_MIN__) != __FLT_MIN__*1.5F) + link_error (__LINE__); + + if (__builtin_fma(__DBL_MAX__, 2.0, -__DBL_MAX__) != __DBL_MAX__) + link_error (__LINE__); + if (__builtin_fma(2.0,__DBL_MAX__, -__DBL_MAX__) != __DBL_MAX__) + link_error (__LINE__); + if (__builtin_fma(__DBL_MIN__, 0.5, __DBL_MIN__) != __DBL_MIN__*1.5) + link_error (__LINE__); + if (__builtin_fma(0.5,__DBL_MIN__, __DBL_MIN__) != __DBL_MIN__*1.5) + link_error (__LINE__); + + if (__builtin_fmal(__LDBL_MAX__, 2.0L, -__LDBL_MAX__) != __LDBL_MAX__) + link_error (__LINE__); + if (__builtin_fmal(2.0L,__LDBL_MAX__, -__LDBL_MAX__) != __LDBL_MAX__) + link_error (__LINE__); + if (__builtin_fmal(__LDBL_MIN__, 0.5L, __LDBL_MIN__) != __LDBL_MIN__*1.5L) + link_error (__LINE__); + if (__builtin_fmal(0.5L,__LDBL_MIN__, __LDBL_MIN__) != __LDBL_MIN__*1.5L) + link_error (__LINE__); + + TESTIT (sqrt, -0.0, -0.0); /* sqrt(-0) == -0 */ + TESTIT (sqrt, 0.0, 0.0); /* sqrt(0) == 0 */ + TESTIT (sqrt, 1.0, 1.0); /* sqrt(1) == 1 */ + TESTIT (sqrt, 4.0, 2.0); /* sqrt(4) == 2 */ + TESTIT_R (sqrt, 1.5, 1.22, 1.23); /* sqrt(1.5) == 1.224... */ + TESTIT_R (sqrt, 2.0, 1.41, 1.42); /* sqrt(2) == 1.414... */ + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-math-4.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-math-4.c new file mode 100644 index 000000000..d47e13933 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-math-4.c @@ -0,0 +1,311 @@ +/* Copyright (C) 2007 Free Software Foundation. + + Verify that built-in math function constant folding of constant + arguments is correctly performed by the compiler. This testcase is + for functionality that was available as of mpfr-2.3.0. + + Origin: Kaveh R. Ghazi, April 23, 2007. */ + +/* { dg-do link } */ + +/* All references to link_error should go away at compile-time. */ +extern void link_error(int); + +/* Return TRUE if the sign of X != sign of Y. This is important when + comparing signed zeros. */ +#define CKSGN_F(X,Y) \ + (__builtin_copysignf(1.0F,(X)) != __builtin_copysignf(1.0F,(Y))) +#define CKSGN(X,Y) \ + (__builtin_copysign(1.0,(X)) != __builtin_copysign(1.0,(Y))) +#define CKSGN_L(X,Y) \ + (__builtin_copysignl(1.0L,(X)) != __builtin_copysignl(1.0L,(Y))) + +/* Test that FUNC(ARG) == (RES). */ +#define TESTIT(FUNC,ARG,RES) do { \ + if (__builtin_##FUNC##f(ARG##F) != RES##F \ + || CKSGN_F(__builtin_##FUNC##f(ARG##F),RES##F)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC(ARG) != RES \ + || CKSGN(__builtin_##FUNC(ARG),RES)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC##l(ARG##L) != RES##L \ + || CKSGN_L(__builtin_##FUNC##l(ARG##L),RES##L)) \ + link_error(__LINE__); \ + } while (0) + +/* Range test, check that (LOW) < FUNC(ARG) < (HI). */ +#define TESTIT_R(FUNC,ARG,LOW,HI) do { \ + if (__builtin_##FUNC##f(ARG) <= (LOW) || __builtin_##FUNC##f(ARG) >= (HI)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC(ARG) <= (LOW) || __builtin_##FUNC(ARG) >= (HI)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC##l(ARG) <= (LOW) || __builtin_##FUNC##l(ARG) >= (HI)) \ + link_error(__LINE__); \ + } while (0) + +/* Test that FUNC(ARG1, ARG2) == (RES). */ +#define TESTIT2(FUNC,ARG1,ARG2,RES) do { \ + if (__builtin_##FUNC##f(ARG1, ARG2##F) != RES##F \ + || CKSGN_F(__builtin_##FUNC##f(ARG1,ARG2##F),RES##F)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC(ARG1, ARG2) != RES \ + || CKSGN(__builtin_##FUNC(ARG1,ARG2),RES)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC##l(ARG1, ARG2##L) != RES##L \ + || CKSGN_L(__builtin_##FUNC##l(ARG1,ARG2##L),RES##L)) \ + link_error(__LINE__); \ + } while (0) + +/* Range test, check that (LOW) < FUNC(ARG1,ARG2) < (HI). */ +#define TESTIT2_R(FUNC,ARG1,ARG2,LOW,HI) do { \ + if (__builtin_##FUNC##f(ARG1, ARG2##F) <= (LOW) \ + || __builtin_##FUNC##f(ARG1, ARG2##F) >= (HI)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC(ARG1, ARG2) <= (LOW) \ + || __builtin_##FUNC(ARG1, ARG2) >= (HI)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC##l(ARG1, ARG2##L) <= (LOW) \ + || __builtin_##FUNC##l(ARG1, ARG2##L) >= (HI)) \ + link_error(__LINE__); \ + } while (0) + +/* Test that remquo(ARG0, ARG1, &ARG_Q) == RES and ARG_Q == RES_Q. + Also test remainder/drem (ARG0,ARG1) == RES. */ +#define TESTIT2_REMQUO(ARG0,ARG1,ARG_Q,RES,RES_Q) do { \ + ARG_Q = 12345; \ + if (__builtin_remquof(ARG0##F, ARG1##F, &ARG_Q) != RES##F \ + || CKSGN_F(__builtin_remquof(ARG0##F, ARG1##F, &ARG_Q),RES##F) \ + || ARG_Q != RES_Q \ + || __builtin_remainderf(ARG0##F, ARG1##F) != RES##F \ + || CKSGN_F(__builtin_remainderf(ARG0##F, ARG1##F),RES##F) \ + || __builtin_dremf(ARG0##F, ARG1##F) != RES##F \ + || CKSGN_F(__builtin_dremf(ARG0##F, ARG1##F),RES##F)) \ + link_error(__LINE__); \ + ARG_Q = 12345; \ + if (__builtin_remquo(ARG0, ARG1, &ARG_Q) != RES \ + || CKSGN(__builtin_remquo(ARG0, ARG1, &ARG_Q),RES) \ + || ARG_Q != RES_Q \ + || __builtin_remainder(ARG0, ARG1) != RES \ + || CKSGN(__builtin_remainder(ARG0, ARG1),RES) \ + || __builtin_drem(ARG0, ARG1) != RES \ + || CKSGN(__builtin_drem(ARG0, ARG1),RES)) \ + link_error(__LINE__); \ + ARG_Q = 12345; \ + if (__builtin_remquol(ARG0##L, ARG1##L, &ARG_Q) != RES##L \ + || CKSGN_L(__builtin_remquol(ARG0##L, ARG1##L, &ARG_Q),RES##L) \ + || ARG_Q != RES_Q \ + || __builtin_remainderl(ARG0##L, ARG1##L) != RES##L \ + || CKSGN_L(__builtin_remainderl(ARG0##L, ARG1##L),RES##L) \ + || __builtin_dreml(ARG0##L, ARG1##L) != RES##L \ + || CKSGN_L(__builtin_dreml(ARG0##L, ARG1##L),RES##L)) \ + link_error(__LINE__); \ + } while (0) + +/* Test that FUNC(ARG,&SG) == (RES) && SG == RES_SG. */ +#define TESTIT_LGAMMA_REENT(FUNC,ARG,RES,RES_SG) do { \ + int sg; \ + sg = 123; \ + if (__builtin_##FUNC##f_r(ARG##F,&sg) != RES##F \ + || sg != RES_SG \ + || CKSGN_F(__builtin_##FUNC##f_r(ARG##F,&sg),RES##F)) \ + link_error(__LINE__); \ + sg = 123; \ + if (__builtin_##FUNC##_r(ARG,&sg) != RES \ + || sg != RES_SG \ + || CKSGN(__builtin_##FUNC##_r(ARG,&sg),RES)) \ + link_error(__LINE__); \ + sg = 123; \ + if (__builtin_##FUNC##l_r(ARG##L,&sg) != RES##L \ + || sg != RES_SG \ + || CKSGN_L(__builtin_##FUNC##l_r(ARG##L,&sg),RES##L)) \ + link_error(__LINE__); \ + } while (0) + +/* Range test, check that (LOW) < FUNC(ARG,&SG) < (HI), and also test + that SG == RES_SG. */ +#define TESTIT_LGAMMA_REENT_R(FUNC,ARG,LOW,HI,RES_SG) do { \ + int sg; \ + sg = 123; \ + if (__builtin_##FUNC##f_r(ARG,&sg) <= (LOW) || __builtin_##FUNC##f_r(ARG,&sg) >= (HI) \ + || sg != RES_SG) \ + link_error(__LINE__); \ + sg = 123; \ + if (__builtin_##FUNC##_r(ARG,&sg) <= (LOW) || __builtin_##FUNC##_r(ARG,&sg) >= (HI) \ + || sg != RES_SG) \ + link_error(__LINE__); \ + sg = 123; \ + if (__builtin_##FUNC##l_r(ARG,&sg) <= (LOW) || __builtin_##FUNC##l_r(ARG,&sg) >= (HI) \ + || sg != RES_SG) \ + link_error(__LINE__); \ + } while (0) + +int main (void) +{ +#ifdef __OPTIMIZE__ + int q; +#endif + + TESTIT (j0, 0.0, 1.0); /* j0(0) == 1 */ + TESTIT (j0, -0.0, 1.0); /* j0(-0) == 1 */ + TESTIT_R (j0, 1.0, 0.765, 0.766); /* j0(1) == 0.7651... */ + TESTIT_R (j0, -1.0, 0.765, 0.766); /* j0(-1) == 0.7651... */ + + TESTIT (j1, 0.0, 0.0); /* j1(0) == 0 */ + TESTIT (j1, -0.0, -0.0); /* j1(-0) == -0 */ + TESTIT_R (j1, 1.0, 0.44, 0.45); /* j1(1) == 0.440... */ + TESTIT_R (j1, -1.0, -0.45, -0.44); /* j1(-1) == -0.440... */ + + TESTIT2 (jn, 5, 0.0, 0.0); /* jn(5,0) == 0 */ + TESTIT2 (jn, 5, -0.0, -0.0); /* jn(5,-0) == -0 */ + TESTIT2 (jn, 6, 0.0, 0.0); /* jn(6,0) == 0 */ + TESTIT2 (jn, 6, -0.0, 0.0); /* jn(6,-0) == 0 */ + + TESTIT2 (jn, -5, 0.0, -0.0); /* jn(-5,0) == -0 */ + TESTIT2 (jn, -5, -0.0, 0.0); /* jn(-5,-0) == 0 */ + TESTIT2 (jn, -6, 0.0, 0.0); /* jn(-6,0) == 0 */ + TESTIT2 (jn, -6, -0.0, 0.0); /* jn(-6,-0) == 0 */ + + TESTIT2_R (jn, 2, 1.0, 0.11, 0.12); /* jn(2,1) == 0.114... */ + TESTIT2_R (jn, 2, -1.0, 0.11, 0.12); /* jn(2,-1) == 0.114... */ + TESTIT2_R (jn, 3, 5.0, 0.36, 0.37); /* jn(3,5) == 0.364... */ + TESTIT2_R (jn, 3, -5.0, -0.37, -0.36); /* jn(3,-5) == -0.364... */ + + TESTIT2_R (jn, -2, 1.0, 0.11, 0.12); /* jn(-2,1) == 0.114... */ + TESTIT2_R (jn, -2, -1.0, 0.11, 0.12); /* jn(-2,-1) == 0.114... */ + TESTIT2_R (jn, -3, 5.0, -0.37, -0.36); /* jn(-3,5) == -0.364... */ + TESTIT2_R (jn, -3, -5.0, 0.36, 0.37); /* jn(-3,-5) == 0.364... */ + + TESTIT2_R (jn, 4, 3.5, 0.20, 0.21); /* jn(4,3.5) == 0.204... */ + TESTIT2_R (jn, 4, -3.5, 0.20, 0.21); /* jn(4,-3.5) == 0.204... */ + TESTIT2_R (jn, 5, 4.6, 0.20, 0.21); /* jn(5,4.6) == 0.207... */ + TESTIT2_R (jn, 5, -4.6, -0.21, -0.20); /* jn(5,-4.6) == -0.207... */ + + TESTIT2_R (jn, -4, 3.5, 0.20, 0.21); /* jn(-4,3.5) == 0.204... */ + TESTIT2_R (jn, -4, -3.5, 0.20, 0.21); /* jn(-4,-3.5) == 0.204... */ + TESTIT2_R (jn, -5, 4.6, -0.21, -0.20); /* jn(-5,4.6) == -0.207... */ + TESTIT2_R (jn, -5, -4.6, 0.20, 0.21); /* jn(-5,-4.6) == 0.207... */ + + TESTIT_R (y0, 5.0, -0.31, -0.30); /* y0(5) == -0.308... */ + TESTIT_R (y0, 0.1, -1.54, -1.53); /* y0(0.1) == -1.534... */ + + TESTIT_R (y1, 5.0, 0.14, 0.15); /* y1(5) == 0.147... */ + TESTIT_R (y1, 0.1, -6.46, -6.45); /* y1(0.1) == -6.458... */ + + TESTIT2_R (yn, -1, 3.0, -0.33, -0.32); /* yn(-1,3) == -0.324... */ + TESTIT2_R (yn, -1, 0.25, 2.70, 2.71); /* yn(-1,0.25) == 2.704... */ + + TESTIT2_R (yn, 2, 4.0, 0.21, 0.22); /* yn(2,4) == 0.215... */ + TESTIT2_R (yn, 2, 0.9, -1.95, -1.94); /* yn(2,0.9) == -1.945... */ + TESTIT2_R (yn, -2, 4.0, 0.21, 0.22); /* yn(-2,4) == 0.215... */ + TESTIT2_R (yn, -2, 0.9, -1.95, -1.94); /* yn(-2,0.9) == -1.945... */ + + TESTIT2_R (yn, 3, 6.0, 0.32, 0.33); /* yn(3,6) == 0.328... */ + TESTIT2_R (yn, 3, 0.89, -8.03, -8.02); /* yn(3,0.89) == -8.020... */ + TESTIT2_R (yn, -3, 8.0, -0.03, -0.02); /* yn(-3,8) == -0.026... */ + TESTIT2_R (yn, -3, 0.99, 5.98, 5.99); /* yn(-3,0.99) == 5.982... */ + +#ifdef __OPTIMIZE__ + /* These tests rely on propagating the variable q, which happens + only when optimization is turned on. This macro also tests + remainder/drem. */ + TESTIT2_REMQUO (0.0, 1.0, q, 0.0, 0); /* remquo(0,1,&q)==0, q==0 */ + TESTIT2_REMQUO (1.0, 1.0, q, 0.0, 1); /* remquo(1,1,&q)==0, q==1 */ + TESTIT2_REMQUO (2.0, 1.0, q, 0.0, 2); /* remquo(2,1,&q)==0, q==2 */ + TESTIT2_REMQUO (-0.0, 1.0, q, -0.0, 0); /* remquo(-0,1,&q)==-0, q==0 */ + TESTIT2_REMQUO (-1.0, 1.0, q, -0.0, -1); /* remquo(-1,1,&q)==-0, q==-1 */ + TESTIT2_REMQUO (-2.0, 1.0, q, -0.0, -2); /* remquo(-2,1,&q)==-0, q==-2 */ + + TESTIT2_REMQUO (0.0, -1.0, q, 0.0, 0); /* remquo(0,-1,&q)==0, q==0 */ + TESTIT2_REMQUO (1.0, -1.0, q, 0.0, -1); /* remquo(1,-1,&q)==0, q==-1 */ + TESTIT2_REMQUO (2.0, -1.0, q, 0.0, -2); /* remquo(2,-1,&q)==0, q==-2 */ + TESTIT2_REMQUO (-0.0, -1.0, q, -0.0, 0); /* remquo(-0,-1,&q)==-0, q==0 */ + TESTIT2_REMQUO (-1.0, -1.0, q, -0.0, 1); /* remquo(-1,-1,&q)==-0, q==1 */ + TESTIT2_REMQUO (-2.0, -1.0, q, -0.0, 2); /* remquo(-2,-1,&q)==-0, q==2 */ + + TESTIT2_REMQUO (1.0, 2.0, q, 1.0, 0); /* remquo(1,2,&q)==1, q==0 */ + TESTIT2_REMQUO (3.0, 2.0, q, -1.0, 2); /* remquo(3,2,&q)==-1, q==2 */ + TESTIT2_REMQUO (5.0, 2.0, q, 1.0, 2); /* remquo(5,2,&q)==1, q==2 */ + TESTIT2_REMQUO (-1.0, 2.0, q, -1.0, 0); /* remquo(-1,2,&q)==-1, q==0 */ + TESTIT2_REMQUO (-3.0, 2.0, q, 1.0, -2); /* remquo(-3,2,&q)==1, q==-2 */ + TESTIT2_REMQUO (-5.0, 2.0, q, -1.0, -2); /* remquo(-5,2,&q)==-1, q==-2 */ + + TESTIT2_REMQUO (1.0, -2.0, q, 1.0, 0); /* remquo(1,-2,&q)==1, q==0 */ + TESTIT2_REMQUO (3.0, -2.0, q, -1.0, -2); /* remquo(3,-2,&q)==-1, q==-2 */ + TESTIT2_REMQUO (5.0, -2.0, q, 1.0, -2); /* remquo(5,-2,&q)==1, q==-2 */ + TESTIT2_REMQUO (-1.0, -2.0, q, -1.0, 0); /* remquo(-1,-2,&q)==-1, q==0 */ + TESTIT2_REMQUO (-3.0, -2.0, q, 1.0, 2); /* remquo(-3,-2,&q)==1, q==2 */ + TESTIT2_REMQUO (-5.0, -2.0, q, -1.0, 2); /* remquo(-5,-2,&q)==-1, q==2 */ + + /* Test that the maximum possible value can be generated into the + int quotient, and check for wrap around (modulo) when that value + is exceeded. We can only check for this when the mantissa has + enough bits to hold an INT_MAX value with complete precision. */ + +#define MAXIT(FUNC,X,R) do { \ + q = 12345; \ + if (__builtin_##FUNC((X), 1, &q) != 0 || q != (R)) \ + link_error (__LINE__); \ +} while (0) + + if (sizeof(int)*__CHAR_BIT__ <= __FLT_MANT_DIG__) + { + MAXIT(remquof, __INT_MAX__-1.0F, __INT_MAX__-1); + MAXIT(remquof, __INT_MAX__+0.0F, __INT_MAX__); + MAXIT(remquof, __INT_MAX__+1.0F, 0); + MAXIT(remquof, __INT_MAX__+2.0F, 1); + + MAXIT(remquof, -(__INT_MAX__-1.0F), -(__INT_MAX__-1)); + MAXIT(remquof, -(__INT_MAX__+0.0F), -__INT_MAX__); + MAXIT(remquof, -(__INT_MAX__+1.0F), 0); + MAXIT(remquof, -(__INT_MAX__+2.0F), -1); + } + + if (sizeof(int)*__CHAR_BIT__ <= __DBL_MANT_DIG__) + { + MAXIT(remquo, __INT_MAX__-1.0, __INT_MAX__-1); + MAXIT(remquo, __INT_MAX__+0.0, __INT_MAX__); + MAXIT(remquo, __INT_MAX__+1.0, 0); + MAXIT(remquo, __INT_MAX__+2.0, 1); + + MAXIT(remquo, -(__INT_MAX__-1.0), -(__INT_MAX__-1)); + MAXIT(remquo, -(__INT_MAX__+0.0), -__INT_MAX__); + MAXIT(remquo, -(__INT_MAX__+1.0), 0); + MAXIT(remquo, -(__INT_MAX__+2.0), -1); + } + + if (sizeof(int)*__CHAR_BIT__ <= __LDBL_MANT_DIG__) + { + MAXIT(remquo, __INT_MAX__-1.0L, __INT_MAX__-1); + MAXIT(remquo, __INT_MAX__+0.0L, __INT_MAX__); + MAXIT(remquo, __INT_MAX__+1.0L, 0); + MAXIT(remquo, __INT_MAX__+2.0L, 1); + + MAXIT(remquol, -(__INT_MAX__-1.0L), -(__INT_MAX__-1)); + MAXIT(remquol, -(__INT_MAX__+0.0L), -__INT_MAX__); + MAXIT(remquol, -(__INT_MAX__+1.0L), 0); + MAXIT(remquol, -(__INT_MAX__+2.0L), -1); + } + + /* These tests rely on propagating the variable sg which contains + signgam. This happens only when optimization is turned on. */ + TESTIT_LGAMMA_REENT_R (lgamma, -2.5, -0.06, -0.05, -1); /* lgamma_r(-2.5) == -0.056... */ + TESTIT_LGAMMA_REENT_R (lgamma, -1.5, 0.86, 0.87, 1); /* lgamma_r(-1.5) == 0.860... */ + TESTIT_LGAMMA_REENT_R (lgamma, -0.5, 1.26, 1.27, -1); /* lgamma_r(-0.5) == 1.265... */ + TESTIT_LGAMMA_REENT_R (lgamma, 0.5, 0.57, 0.58, 1); /* lgamma_r(0.5) == 0.572... */ + TESTIT_LGAMMA_REENT (lgamma, 1.0, 0.0, 1); /* lgamma_r(1) == 0 */ + TESTIT_LGAMMA_REENT_R (lgamma, 1.5, -0.13, -0.12, 1); /* lgamma_r(1.5) == -0.120... */ + TESTIT_LGAMMA_REENT (lgamma, 2.0, 0.0, 1); /* lgamma_r(2) == 0 */ + TESTIT_LGAMMA_REENT_R (lgamma, 2.5, 0.28, 0.29, 1); /* lgamma_r(2.5) == 0.284... */ + + TESTIT_LGAMMA_REENT_R (gamma, -2.5, -0.06, -0.05, -1); /* gamma_r(-2.5) == -0.056... */ + TESTIT_LGAMMA_REENT_R (gamma, -1.5, 0.86, 0.87, 1); /* gamma_r(-1.5) == 0.860... */ + TESTIT_LGAMMA_REENT_R (gamma, -0.5, 1.26, 1.27, -1); /* gamma_r(-0.5) == 1.265... */ + TESTIT_LGAMMA_REENT_R (gamma, 0.5, 0.57, 0.58, 1); /* gamma_r(0.5) == 0.572... */ + TESTIT_LGAMMA_REENT (gamma, 1.0, 0.0, 1); /* gamma_r(1) == 0 */ + TESTIT_LGAMMA_REENT_R (gamma, 1.5, -0.13, -0.12, 1); /* gamma_r(1.5) == -0.120... */ + TESTIT_LGAMMA_REENT (gamma, 2.0, 0.0, 1); /* gamma_r(2) == 0 */ + TESTIT_LGAMMA_REENT_R (gamma, 2.5, 0.28, 0.29, 1); /* gamma_r(2.5) == 0.284... */ +#endif + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-math-5.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-math-5.c new file mode 100644 index 000000000..259164107 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-math-5.c @@ -0,0 +1,123 @@ +/* Copyright (C) 2009 Free Software Foundation. + + Test things that should block GCC from optimizing compile-time + constants passed to a builtin complex transcendental functions. + + Origin: Kaveh R. Ghazi, January 28, 2009. */ + +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ + +extern void foof (_Complex float); +extern void foo (_Complex double); +extern void fool (_Complex long double); + +#define TESTIT(FUNC, ARG) do { \ + foof (__builtin_##FUNC##f (ARG##F)); \ + foo (__builtin_##FUNC (ARG)); \ + fool (__builtin_##FUNC##l (ARG##L)); \ +} while (0) + +#define TESTIT2(FUNC, ARG0, ARG1) do { \ + foof (__builtin_##FUNC##f (ARG0##F, ARG1##F)); \ + foo (__builtin_##FUNC (ARG0, ARG1)); \ + fool (__builtin_##FUNC##l (ARG0##L, ARG1##L)); \ +} while (0) + +void bar() +{ + /* An argument of NaN is not evaluated at compile-time. */ +#ifndef __SPU__ + foof (__builtin_csqrtf (__builtin_nanf(""))); +#endif + foo (__builtin_csqrt (__builtin_nan(""))); + fool (__builtin_csqrtl (__builtin_nanl(""))); + + /* An argument of Inf/-Inf is not evaluated at compile-time. */ +#ifndef __SPU__ + foof (__builtin_csqrtf (__builtin_inff())); +#endif + foo (__builtin_csqrt (__builtin_inf())); + fool (__builtin_csqrtl (__builtin_infl())); +#ifndef __SPU__ + foof (__builtin_csqrtf (-__builtin_inff())); +#endif + foo (__builtin_csqrt (-__builtin_inf())); + fool (__builtin_csqrtl (-__builtin_infl())); + + /* Check for overflow/underflow. */ + TESTIT (cexp, 1e20); + TESTIT (cexp, -1e20); + + /* An argument of NaN is not evaluated at compile-time. */ +#ifndef __SPU__ + foof (__builtin_cpowf (__builtin_nanf(""), 2.5F)); +#endif + foo (__builtin_cpow (__builtin_nan(""), 2.5)); + fool (__builtin_cpowl (__builtin_nanl(""), 2.5L)); +#ifndef __SPU__ + foof (__builtin_cpowf (2.5F, __builtin_nanf(""))); +#endif + foo (__builtin_cpow (2.5, __builtin_nan(""))); + fool (__builtin_cpowl (2.5L, __builtin_nanl(""))); + + /* An argument of Inf/-Inf is not evaluated at compile-time. */ +#ifndef __SPU__ + foof (__builtin_cpowf (__builtin_inff(), 2.5F)); +#endif + foo (__builtin_cpow (__builtin_inf(), 2.5)); + fool (__builtin_cpowl (__builtin_infl(), 2.5L)); +#ifndef __SPU__ + foof (__builtin_cpowf (-__builtin_inff(), 2.5F)); +#endif + foo (__builtin_cpow (-__builtin_inf(), 2.5)); + fool (__builtin_cpowl (-__builtin_infl(), 2.5L)); +#ifndef __SPU__ + foof (__builtin_cpowf (2.5F, __builtin_inff())); +#endif + foo (__builtin_cpow (2.5, __builtin_inf())); + fool (__builtin_cpowl (2.5L, __builtin_infl())); +#ifndef __SPU__ + foof (__builtin_cpowf (2.5F, -__builtin_inff())); +#endif + foo (__builtin_cpow (2.5, -__builtin_inf())); + fool (__builtin_cpowl (2.5L, -__builtin_infl())); + + /* Check for Inv/NaN return values. */ + TESTIT2 (cpow, -0.0, -4.5); /* Returns Inf */ + TESTIT2 (cpow, 0.0, -4.5); /* Returns Inf */ + + /* Check for overflow/underflow. */ + foof (__builtin_cpowf (__FLT_MAX__, 3.5F)); + foof (__builtin_cpowf (__FLT_MAX__ * 1.FI, 3.5F)); + foo (__builtin_cpow (__DBL_MAX__, 3.5)); + foo (__builtin_cpow (__DBL_MAX__ * 1.I, 3.5)); + fool (__builtin_cpowl (__LDBL_MAX__, 3.5L)); + fool (__builtin_cpowl (__LDBL_MAX__ * 1.LI, 3.5L)); + TESTIT2 (cpow, 2.0, 0x1p50); + TESTIT2 (cpow, 2.0, 0x1p28); + TESTIT2 (cpow, 2.0, 0x1p24); + foof (__builtin_cpowf (__FLT_MAX__, -3.5F)); + foof (__builtin_cpowf (__FLT_MAX__ * 1.FI, -3.5F)); + foo (__builtin_cpow (__DBL_MAX__, -3.5)); + foo (__builtin_cpow (__DBL_MAX__ * 1.I, -3.5)); + fool (__builtin_cpowl (__LDBL_MAX__, -3.5L)); + fool (__builtin_cpowl (__LDBL_MAX__ * 1.LI, -3.5L)); + TESTIT2 (cpow, 2.0, -0x1p50); + TESTIT2 (cpow, 2.0, -0x1p28); + TESTIT2 (cpow, 2.0, -0x1p24); + +} + +/* { dg-final { scan-tree-dump-times "csqrtf" 3 "original" { target { ! { spu*-*-* } } } } } */ +/* { dg-final { scan-tree-dump-times "csqrtf" 0 "original" { target { spu*-*-* } } } } */ +/* { dg-final { scan-tree-dump-times "csqrt " 3 "original" } } */ +/* { dg-final { scan-tree-dump-times "csqrtl" 3 "original" } } */ +/* { dg-final { scan-tree-dump-times "cexpf" 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "cexp " 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "cexpl" 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "cpowf" 18 "original" { target { ! { spu*-*-* } } } } } */ +/* { dg-final { scan-tree-dump-times "cpowf" 12 "original" { target { spu*-*-* } } } } */ +/* { dg-final { scan-tree-dump-times "cpow " 18 "original" } } */ +/* { dg-final { scan-tree-dump-times "cpowl" 18 "original" } } */ +/* { dg-final { cleanup-tree-dump "original" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-math-6.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-math-6.c new file mode 100644 index 000000000..462c7d3ee --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-math-6.c @@ -0,0 +1,302 @@ +/* Copyright (C) 2009 Free Software Foundation. + + Verify that folding of built-in complex math functions with + constant arguments is correctly performed by the compiler. + + Origin: Kaveh R. Ghazi, January 28, 2009. */ + +/* { dg-do link } */ + +/* All references to link_error should go away at compile-time. The + first number is the line number and the second is the value number + among several tests. These appear in the tree dump file and aid in + debugging. */ +extern void link_error(int, int); + +#define CONJ(X) __builtin_conjf(X) + +/* Return TRUE if the signs of floating point values X and Y are not + equal. This is important when comparing signed zeros. */ +#define CKSGN_F(X,Y) \ + (__builtin_copysignf(1,(X)) != __builtin_copysignf(1,(Y))) +#define CKSGN(X,Y) \ + (__builtin_copysign(1,(X)) != __builtin_copysign(1,(Y))) +#define CKSGN_L(X,Y) \ + (__builtin_copysignl(1,(X)) != __builtin_copysignl(1,(Y))) + +/* Return TRUE if signs of the real parts, and the signs of the + imaginary parts, of X and Y are not equal. */ +#define COMPLEX_CKSGN_F(X,Y) \ + (CKSGN_F(__real__ (X), __real__ (Y)) || CKSGN_F (__imag__ (X), __imag__ (Y))) +#define COMPLEX_CKSGN(X,Y) \ + (CKSGN(__real__ (X), __real__ (Y)) || CKSGN (__imag__ (X), __imag__ (Y))) +#define COMPLEX_CKSGN_L(X,Y) \ + (CKSGN_L(__real__ (X), __real__ (Y)) || CKSGN_L (__imag__ (X), __imag__ (Y))) + +/* For complex numbers, test that FUNC(ARG) == (RES). */ +#define TESTIT_COMPLEX(VAL_NUM, FUNC, ARG, RES) do { \ + if (__builtin_##FUNC##f(ARG) != (RES) \ + || COMPLEX_CKSGN_F(__builtin_##FUNC##f(ARG), (RES))) \ + link_error(__LINE__, VAL_NUM); \ + if (__builtin_##FUNC(ARG) != (RES) \ + || COMPLEX_CKSGN(__builtin_##FUNC(ARG), (RES))) \ + link_error(__LINE__, VAL_NUM); \ + if (__builtin_##FUNC##l(ARG) != (RES) \ + || COMPLEX_CKSGN_L(__builtin_##FUNC##l(ARG), (RES))) \ + link_error(__LINE__, VAL_NUM); \ + } while (0) + +/* For complex numbers, call the TESTIT_COMPLEX macro for all + combinations of neg and conj. */ +#define TESTIT_COMPLEX_ALLNEG(FUNC, ARG, RES1, RES2, RES3, RES4) do { \ + TESTIT_COMPLEX(1, FUNC, (_Complex float)(ARG), RES1); \ + TESTIT_COMPLEX(2, FUNC, -CONJ(ARG), RES2); \ + TESTIT_COMPLEX(3, FUNC, CONJ(ARG), RES3); \ + TESTIT_COMPLEX(4, FUNC, -(_Complex float)(ARG), RES4); \ +} while (0) + +/* For complex numbers, call the TESTIT_COMPLEX_R macro for all + combinations of neg and conj. */ +#define TESTIT_COMPLEX_R_ALLNEG(FUNC, ARG, RES1, RES2, RES3, RES4) do { \ + TESTIT_COMPLEX_R(1, FUNC, (_Complex float)(ARG), RES1); \ + TESTIT_COMPLEX_R(2, FUNC, -CONJ(ARG), RES2); \ + TESTIT_COMPLEX_R(3, FUNC, CONJ(ARG), RES3); \ + TESTIT_COMPLEX_R(4, FUNC, -(_Complex float)(ARG), RES4); \ +} while (0) + +/* For complex numbers, test that FUNC(ARG0, ARG1) == (RES). */ +#define TESTIT_COMPLEX2(VAL_NUM, FUNC, ARG0, ARG1, RES) do { \ + if (__builtin_##FUNC##f(ARG0, ARG1) != (RES) \ + || COMPLEX_CKSGN_F(__builtin_##FUNC##f(ARG0, ARG1), (RES))) \ + link_error(__LINE__, VAL_NUM); \ + if (__builtin_##FUNC(ARG0, ARG1) != (RES) \ + || COMPLEX_CKSGN(__builtin_##FUNC(ARG0, ARG1), (RES))) \ + link_error(__LINE__, VAL_NUM); \ + if (__builtin_##FUNC##l(ARG0, ARG1) != (RES) \ + || COMPLEX_CKSGN_L(__builtin_##FUNC##l(ARG0, ARG1), (RES))) \ + link_error(__LINE__, VAL_NUM); \ + } while (0) + +/* For complex numbers, call the TESTIT_COMPLEX2 macro for all + combinations of neg and conj. */ +#define TESTIT_COMPLEX2_ALLNEG(FUNC, ARG0, ARG1, RES1, RES2, RES3, RES4, RES5,\ + RES6, RES7, RES8, RES9, RES10, RES11, RES12, RES13, RES14, RES15, RES16) do{ \ + TESTIT_COMPLEX2(1, FUNC, (_Complex float)(ARG0),(_Complex float)(ARG1), RES1);\ + TESTIT_COMPLEX2(2, FUNC, (_Complex float)(ARG0),CONJ(ARG1), RES2); \ + TESTIT_COMPLEX2(3, FUNC, (_Complex float)(ARG0),-(_Complex float)(ARG1), RES3); \ + TESTIT_COMPLEX2(4, FUNC, (_Complex float)(ARG0),-CONJ(ARG1), RES4); \ + TESTIT_COMPLEX2(5, FUNC, -(_Complex float)(ARG0),(_Complex float)(ARG1), RES5); \ + TESTIT_COMPLEX2(6, FUNC, -(_Complex float)(ARG0),CONJ(ARG1), RES6); \ + TESTIT_COMPLEX2(7, FUNC, -(_Complex float)(ARG0),-(_Complex float)(ARG1), RES7); \ + TESTIT_COMPLEX2(8, FUNC, -(_Complex float)(ARG0),-CONJ(ARG1), RES8); \ + TESTIT_COMPLEX2(9, FUNC, CONJ(ARG0),(_Complex float)(ARG1), RES9); \ + TESTIT_COMPLEX2(10, FUNC, CONJ(ARG0),CONJ(ARG1), RES10); \ + TESTIT_COMPLEX2(11, FUNC, CONJ(ARG0),-(_Complex float)(ARG1), RES11); \ + TESTIT_COMPLEX2(12, FUNC, CONJ(ARG0),-CONJ(ARG1), RES12); \ + TESTIT_COMPLEX2(13, FUNC, -CONJ(ARG0),(_Complex float)(ARG1), RES13); \ + TESTIT_COMPLEX2(14, FUNC, -CONJ(ARG0),CONJ(ARG1), RES14); \ + TESTIT_COMPLEX2(15, FUNC, -CONJ(ARG0),-(_Complex float)(ARG1), RES15); \ + TESTIT_COMPLEX2(16, FUNC, -CONJ(ARG0),-CONJ(ARG1), RES16); \ +} while (0) + +/* Return TRUE if X differs from EXPECTED by more than 1%. If + EXPECTED is zero, then any difference may return TRUE. We don't + worry about signed zeros. */ +#define DIFF1PCT_F(X,EXPECTED) \ + (__builtin_fabsf((X)-(EXPECTED)) * 100 > __builtin_fabsf(EXPECTED)) +#define DIFF1PCT(X,EXPECTED) \ + (__builtin_fabs((X)-(EXPECTED)) * 100 > __builtin_fabs(EXPECTED)) +#define DIFF1PCT_L(X,EXPECTED) \ + (__builtin_fabsl((X)-(EXPECTED)) * 100 > __builtin_fabsl(EXPECTED)) + +/* Return TRUE if complex value X differs from EXPECTED by more than + 1% in either the real or imaginary parts. */ +#define COMPLEX_DIFF1PCT_F(X,EXPECTED) \ + (DIFF1PCT_F(__real__ (X), __real__ (EXPECTED)) \ + || DIFF1PCT_F(__imag__ (X), __imag__ (EXPECTED))) +#define COMPLEX_DIFF1PCT(X,EXPECTED) \ + (DIFF1PCT(__real__ (X), __real__ (EXPECTED)) \ + || DIFF1PCT(__imag__ (X), __imag__ (EXPECTED))) +#define COMPLEX_DIFF1PCT_L(X,EXPECTED) \ + (DIFF1PCT_L(__real__ (X), __real__ (EXPECTED)) \ + || DIFF1PCT_L(__imag__ (X), __imag__ (EXPECTED))) + +/* Range test, for complex numbers check that FUNC(ARG) is within 1% + of RES. This is NOT a test for accuracy to the last-bit, we're + merely checking that we get relatively sane results. I.e. the GCC + builtin is hooked up to the correct MPC function call. We first + check the magnitude and then the sign. */ +#define TESTIT_COMPLEX_R(VAL_NUM, FUNC, ARG, RES) do { \ + if (COMPLEX_DIFF1PCT_F (__builtin_##FUNC##f(ARG), (RES)) \ + || COMPLEX_CKSGN_F(__builtin_##FUNC##f(ARG), (RES))) \ + link_error(__LINE__, VAL_NUM); \ + if (COMPLEX_DIFF1PCT (__builtin_##FUNC(ARG), (RES)) \ + || COMPLEX_CKSGN(__builtin_##FUNC(ARG), (RES))) \ + link_error(__LINE__, VAL_NUM); \ + if (COMPLEX_DIFF1PCT (__builtin_##FUNC(ARG), (RES)) \ + || COMPLEX_CKSGN(__builtin_##FUNC(ARG), (RES))) \ + link_error(__LINE__, VAL_NUM); \ + } while (0) + +/* Range test, for complex numbers check that FUNC(ARG0, ARG1) is + within 1% of RES. This is NOT a test for accuracy to the last-bit, + we're merely checking that we get relatively sane results. + I.e. the GCC builtin is hooked up to the correct MPC function call. + We first check the magnitude and then the sign. */ +#define TESTIT_COMPLEX_R2(VAL_NUM, FUNC, ARG0, ARG1, RES) do { \ + if (COMPLEX_DIFF1PCT_F (__builtin_##FUNC##f(ARG0, ARG1), (RES)) \ + || COMPLEX_CKSGN_F (__builtin_##FUNC##f(ARG0, ARG1), (RES))) \ + link_error(__LINE__, VAL_NUM); \ + if (COMPLEX_DIFF1PCT (__builtin_##FUNC(ARG0, ARG1), (RES)) \ + || COMPLEX_CKSGN (__builtin_##FUNC(ARG0, ARG1), (RES))) \ + link_error(__LINE__, VAL_NUM); \ + if (COMPLEX_DIFF1PCT_L (__builtin_##FUNC##l(ARG0, ARG1), (RES)) \ + || COMPLEX_CKSGN_L (__builtin_##FUNC##l(ARG0, ARG1), (RES))) \ + link_error(__LINE__, VAL_NUM); \ + } while (0) + +/* For complex numbers, call the TESTIT_COMPLEX_R2 macro for all + combinations of neg and conj. */ +#define TESTIT_COMPLEX_R2_ALLNEG(FUNC, ARG0, ARG1, RES1, RES2, RES3, RES4, RES5,\ + RES6, RES7, RES8, RES9, RES10, RES11, RES12, RES13, RES14, RES15, RES16) do{ \ + TESTIT_COMPLEX_R2(1, FUNC, (_Complex float)(ARG0),(_Complex float)(ARG1), RES1);\ + TESTIT_COMPLEX_R2(2, FUNC, (_Complex float)(ARG0),CONJ(ARG1), RES2); \ + TESTIT_COMPLEX_R2(3, FUNC, (_Complex float)(ARG0),-(_Complex float)(ARG1), RES3); \ + TESTIT_COMPLEX_R2(4, FUNC, (_Complex float)(ARG0),-CONJ(ARG1), RES4); \ + TESTIT_COMPLEX_R2(5, FUNC, -(_Complex float)(ARG0),(_Complex float)(ARG1), RES5); \ + TESTIT_COMPLEX_R2(6, FUNC, -(_Complex float)(ARG0),CONJ(ARG1), RES6); \ + TESTIT_COMPLEX_R2(7, FUNC, -(_Complex float)(ARG0),-(_Complex float)(ARG1), RES7); \ + TESTIT_COMPLEX_R2(8, FUNC, -(_Complex float)(ARG0),-CONJ(ARG1), RES8); \ + TESTIT_COMPLEX_R2(9, FUNC, CONJ(ARG0),(_Complex float)(ARG1), RES9); \ + TESTIT_COMPLEX_R2(10, FUNC, CONJ(ARG0),CONJ(ARG1), RES10); \ + TESTIT_COMPLEX_R2(11, FUNC, CONJ(ARG0),-(_Complex float)(ARG1), RES11); \ + TESTIT_COMPLEX_R2(12, FUNC, CONJ(ARG0),-CONJ(ARG1), RES12); \ + TESTIT_COMPLEX_R2(13, FUNC, -CONJ(ARG0),(_Complex float)(ARG1), RES13); \ + TESTIT_COMPLEX_R2(14, FUNC, -CONJ(ARG0),CONJ(ARG1), RES14); \ + TESTIT_COMPLEX_R2(15, FUNC, -CONJ(ARG0),-(_Complex float)(ARG1), RES15); \ + TESTIT_COMPLEX_R2(16, FUNC, -CONJ(ARG0),-CONJ(ARG1), RES16); \ +} while (0) + +int main (void) +{ + TESTIT_COMPLEX (1, cacos, 1, CONJ(0)); + TESTIT_COMPLEX_R (1, cacos, -1, CONJ(3.141593F)); + TESTIT_COMPLEX (1, cacos, CONJ(1), 0); + TESTIT_COMPLEX_R (1, cacos, CONJ(-1), 3.141593F); + TESTIT_COMPLEX_R_ALLNEG (cacos, 3.45678F + 2.34567FI, + 0.60971F - 2.11780FI, 2.531875F - 2.117800FI, + 0.60971F + 2.11780FI, 2.531875F + 2.117800FI); + + TESTIT_COMPLEX_ALLNEG (casin, 0, + 0, -CONJ(0), CONJ(0), CONJ(-0.F)); + TESTIT_COMPLEX_R_ALLNEG (casin, 3.45678F + 2.34567FI, + 0.96107F + 2.11780FI, -0.96107F + 2.11780FI, + 0.96107F - 2.11780FI, -0.96107F - 2.11780FI); + + TESTIT_COMPLEX_ALLNEG (catan, 0, + 0, -CONJ(0), CONJ(0), CONJ(-0.F)); + TESTIT_COMPLEX_R_ALLNEG (catan, 3.45678F + 2.34567FI, + 1.37188F + 0.12997FI, -1.37188F + 0.12997FI, + 1.37188F - 0.12997FI, -1.37188F - 0.12997FI); + + TESTIT_COMPLEX (1, cacosh, 1, 0); + TESTIT_COMPLEX_R (1, cacosh, -1, 3.141593FI); + TESTIT_COMPLEX (1, cacosh, CONJ(1), CONJ(0)); + TESTIT_COMPLEX_R (1, cacosh, CONJ(-1), CONJ(3.141593FI)); + TESTIT_COMPLEX_R_ALLNEG (cacosh, 3.45678F + 2.34567FI, + 2.11780F + 0.60971FI, 2.11780F + 2.531875FI, + 2.11780F - 0.60971FI, 2.11780F - 2.531875FI); + + TESTIT_COMPLEX_ALLNEG (casinh, 0, + 0, -CONJ(0), CONJ(0), CONJ(-0.F)); + TESTIT_COMPLEX_R_ALLNEG (casinh, 3.45678F + 2.34567FI, + 2.12836F + 0.58310FI, -2.12836F + 0.58310FI, + 2.12836F - 0.58310FI, -2.12836F - 0.58310FI); + + TESTIT_COMPLEX_ALLNEG (catanh, 0, + 0, -CONJ(0), CONJ(0), CONJ(-0.F)); + TESTIT_COMPLEX_R_ALLNEG (catanh, 3.45678F + 2.34567FI, + 0.19693F + 1.43190FI, -0.19693F + 1.43190FI, + 0.19693F - 1.43190FI, -0.19693F - 1.43190FI); + + TESTIT_COMPLEX_ALLNEG (csin, 0, + 0, -0.F, CONJ(0), CONJ(-0.F)); + TESTIT_COMPLEX_R_ALLNEG (csin, 3.45678F + 2.34567FI, + -1.633059F - 4.917448FI, 1.633059F - 4.917448FI, + -1.633059F + 4.917448FI, 1.633059F + 4.917448FI); + + TESTIT_COMPLEX_ALLNEG (ccos, 0, + CONJ(1), 1, 1, CONJ(1)); + TESTIT_COMPLEX_R_ALLNEG (ccos, 3.45678F + 2.34567FI, + -5.008512F + 1.603367FI, -5.008512F - 1.603367FI, + -5.008512F - 1.603367FI, -5.008512F + 1.603367FI); + + TESTIT_COMPLEX_ALLNEG (ctan, 0, + 0, -0.F, CONJ(0), CONJ(-0.F)); + TESTIT_COMPLEX_R_ALLNEG (ctan, 3.45678F + 2.34567FI, + 0.010657F + 0.985230FI, -0.010657F + 0.985230FI, + 0.010657F - 0.985230FI, -0.010657F - 0.985230FI); + + TESTIT_COMPLEX_ALLNEG (csinh, 0, + 0, -0.F, CONJ(0), CONJ(-0.F)); + TESTIT_COMPLEX_R_ALLNEG (csinh, 3.45678F + 2.34567FI, + -11.083178F + 11.341487FI, 11.083178F +11.341487FI, + -11.083178F - 11.341487FI, 11.083178F -11.341487FI); + + TESTIT_COMPLEX_ALLNEG (ccosh, 0, + 1, CONJ(1), CONJ(1), 1); + TESTIT_COMPLEX_R_ALLNEG (ccosh, 3.45678F + 2.34567FI, + -11.105238F + 11.318958FI,-11.105238F -11.318958FI, + -11.105238F - 11.318958FI,-11.105238F +11.318958FI); + + TESTIT_COMPLEX_ALLNEG (ctanh, 0, + 0, -0.F, CONJ(0), CONJ(-0.F)); + TESTIT_COMPLEX_R_ALLNEG (ctanh, 3.45678F + 2.34567FI, + 1.000040F - 0.001988FI, -1.000040F - 0.001988FI, + 1.000040F + 0.001988FI, -1.000040F + 0.001988FI); + + TESTIT_COMPLEX (1, clog, 1, 0); + TESTIT_COMPLEX_R (1, clog, -1, 3.141593FI); + TESTIT_COMPLEX (1, clog, CONJ(1), CONJ(0)); + TESTIT_COMPLEX_R (1, clog, CONJ(-1), CONJ(3.141593FI)); + TESTIT_COMPLEX_R_ALLNEG (clog, 3.45678F + 2.34567FI, + 1.429713F + 0.596199FI, 1.429713F + 2.545394FI, + 1.429713F - 0.596199FI, 1.429713F - 2.545394FI); + + TESTIT_COMPLEX_ALLNEG (csqrt, 0, + 0, 0, CONJ(0), CONJ(0)); + TESTIT_COMPLEX_R_ALLNEG (csqrt, 3.45678F + 2.34567FI, + 1.953750F + 0.600299FI, 0.600299F + 1.953750FI, + 1.953750F - 0.600299FI, 0.600299F - 1.953750FI); + + TESTIT_COMPLEX2_ALLNEG (cpow, 1, 0, + 1, 1, CONJ(1), CONJ(1), CONJ(1), CONJ(1), 1, 1, + CONJ(1), CONJ(1), 1, 1, 1, 1, CONJ(1), CONJ(1)); + TESTIT_COMPLEX2_ALLNEG (cpow, 1.FI, 0, + 1, 1, CONJ(1), CONJ(1), CONJ(1), CONJ(1), 1, 1, + CONJ(1), CONJ(1), 1, 1, 1, 1, CONJ(1), CONJ(1)); + TESTIT_COMPLEX_R2_ALLNEG (cpow, 2, 3, + 8, 8, CONJ(1/8.F), CONJ(1/8.F), CONJ(-8), CONJ(-8), -1/8.F, -1/8.F, + CONJ(8), CONJ(8), 1/8.F, 1/8.F, -8, -8, CONJ(-1/8.F), CONJ(-1/8.F)); + TESTIT_COMPLEX_R2_ALLNEG (cpow, 3, 4, + 81, 81, CONJ(1/81.F), CONJ(1/81.F), CONJ(81), CONJ(81), 1/81.F, 1/81.F, + CONJ(81), CONJ(81), 1/81.F, 1/81.F, 81, 81, CONJ(1/81.F), CONJ(1/81.F)); + TESTIT_COMPLEX_R2_ALLNEG (cpow, 3, 5, + 243, 243, CONJ(1/243.F), CONJ(1/243.F), CONJ(-243), CONJ(-243), -1/243.F, -1/243.F, + CONJ(243), CONJ(243), 1/243.F, 1/243.F, -243, -243, CONJ(-1/243.F), CONJ(-1/243.F)); + TESTIT_COMPLEX_R2_ALLNEG (cpow, 4, 2, + 16, 16, CONJ(1/16.F), CONJ(1/16.F), CONJ(16), CONJ(16), 1/16.F, 1/16.F, + CONJ(16), CONJ(16), 1/16.F, 1/16.F, 16, 16, CONJ(1/16.F), CONJ(1/16.F)); + TESTIT_COMPLEX_R2_ALLNEG (cpow, 1.5, 3, + 3.375F, 3.375F, CONJ(1/3.375F), CONJ(1/3.375F), CONJ(-3.375F), CONJ(-3.375F), -1/3.375F, -1/3.375F, + CONJ(3.375F), CONJ(3.375F), 1/3.375F, 1/3.375F, -3.375F, -3.375F, CONJ(-1/3.375F), CONJ(-1/3.375F)); + + TESTIT_COMPLEX2 (1, cpow, 16, 0.25F, 2); + + TESTIT_COMPLEX_R2 (1, cpow, 3.45678F + 2.34567FI, 1.23456 + 4.56789FI, 0.212485F + 0.319304FI); + TESTIT_COMPLEX_R2 (1, cpow, 3.45678F - 2.34567FI, 1.23456 + 4.56789FI, 78.576402F + -41.756208FI); + TESTIT_COMPLEX_R2 (1, cpow, -1.23456F + 2.34567FI, 2.34567 - 1.23456FI, -110.629847F + -57.021655FI); + TESTIT_COMPLEX_R2 (1, cpow, -1.23456F - 2.34567FI, 2.34567 - 1.23456FI, 0.752336F + 0.199095FI); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-math-7.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-math-7.c new file mode 100644 index 000000000..064e28641 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-math-7.c @@ -0,0 +1,102 @@ +/* Copyright (C) 2009 Free Software Foundation. + + Verify that folding of complex mul and div work correctly. + + Origin: Kaveh R. Ghazi, August 13, 2009. */ + +/* { dg-do run } */ +/* C6X fails due to -freciprocal-math default. */ +/* { dg-skip-if "" { tic6x-*-* } "*" "" } */ +/* { dg-add-options ieee } */ +/* { dg-require-effective-target large_double } */ + +extern void link_error(int); + +/* Evaluate this expression at compile-time. */ +#define COMPILETIME_TESTIT(TYPE,X,OP,Y,RES) do { \ + if ((_Complex TYPE)(X) OP (_Complex TYPE)(Y) != (_Complex TYPE)(RES)) \ + link_error(__LINE__); \ +} while (0) + +/* Use this error function for cases which only evaluate at + compile-time when optimizing. */ +#ifdef __OPTIMIZE__ +# define ERROR_FUNC(X) link_error(X) +#else +# define ERROR_FUNC(X) __builtin_abort() +#endif + +/* Evaluate this expression at compile-time using static initializers. */ +#define STATICINIT_TESTIT(TYPE,X,OP,Y,RES) do { \ + static const _Complex TYPE foo = (_Complex TYPE)(X) OP (_Complex TYPE)(Y); \ + if (foo != (_Complex TYPE)(RES)) \ + ERROR_FUNC (__LINE__); \ +} while (0) + +/* Evaluate this expression at runtime. */ +#define RUNTIME_TESTIT(TYPE,X,OP,Y,RES) do { \ + volatile _Complex TYPE foo; \ + foo = (_Complex TYPE)(X); \ + foo OP##= (_Complex TYPE)(Y); \ + if (foo != (_Complex TYPE)(RES)) \ + __builtin_abort(); \ +} while (0) + +/* Evaluate this expression at compile-time and runtime. */ +#define TESTIT(TYPE,X,OP,Y,RES) do { \ + STATICINIT_TESTIT(TYPE,X,OP,Y,RES); \ + COMPILETIME_TESTIT(TYPE,X,OP,Y,RES); \ + RUNTIME_TESTIT(TYPE,X,OP,Y,RES); \ +} while (0) + +/* Either the real or imaginary parts should be infinity. */ +#define TEST_ONE_PART_INF(VAL) do { \ + static const _Complex double foo = (VAL); \ + if (! __builtin_isinf(__real foo) && ! __builtin_isinf(__imag foo)) \ + ERROR_FUNC (__LINE__); \ + if (! __builtin_isinf(__real (VAL)) && ! __builtin_isinf(__imag (VAL))) \ + __builtin_abort(); \ +} while (0) + +int main() +{ + /* Test some regular finite values. */ + TESTIT (double, 3.+4.i, *, 2, 6+8i); + TESTIT (double, 3.+4.i, /, 2, 1.5+2i); + TESTIT (int, 3+4i, *, 2, 6+8i); + TESTIT (int, 3+4i, /, 2, 1+2i); + + TESTIT (double, 3.+4.i, *, 2+5i, -14+23i); + TESTIT (double, 3.+4.i, /, 5i, .8-.6i); + TESTIT (int, 3+4i, *, 2+5i, -14+23i); + TESTIT (int, 30+40i, /, 5i, 8-6i); + TESTIT (int, 14+6i, /, 7+3i, 2); + TESTIT (int, 8+24i, /, 4+12i, 2); + + /* Test that we don't overflow. */ + TESTIT (double, + (__DBL_MAX__ * 0.5 + __DBL_MAX__ * 0.5i), + /, + (__DBL_MAX__ * 0.25 + __DBL_MAX__ * 0.25i), + 2); + + /* Test for accuracy. */ + COMPILETIME_TESTIT (double, + (1 + __DBL_EPSILON__ + 1i), + *, + (1 - __DBL_EPSILON__ + 1i), + -4.93038065763132378382330353301741393545754021943139377981e-32+2i); + + /* This becomes (NaN + iInf). */ +#define VAL1 ((_Complex double)__builtin_inf() * 1i) + + /* Test some C99 Annex G special cases. */ + TEST_ONE_PART_INF ((VAL1) * (VAL1)); + TEST_ONE_PART_INF ((_Complex double)1 / (_Complex double)0); + TEST_ONE_PART_INF ((VAL1) / (_Complex double)1); + + RUNTIME_TESTIT (double, 1, /, VAL1, 0); + STATICINIT_TESTIT (double, 1, /, VAL1, 0); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-math-8.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-math-8.c new file mode 100644 index 000000000..1a1a843e7 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-math-8.c @@ -0,0 +1,34 @@ +/* { dg-do link } */ + +extern void link_error (void); + +int main() +{ + if (!__builtin_constant_p(1.0)) + link_error (); + if (!__builtin_constant_p(__builtin_fma (1.0, 1.0, 1.0))) + link_error (); + + if (__builtin_constant_p(__builtin_fmaf (__FLT_MAX__, __FLT_MAX__, 0.0F))) + link_error (); + if (__builtin_constant_p(__builtin_fmaf (__FLT_MAX__, 1.0F, __FLT_MAX__))) + link_error (); + if (__builtin_constant_p(__builtin_fmaf (__FLT_MIN__, __FLT_MIN__, 0.0F))) + link_error (); + + if (__builtin_constant_p(__builtin_fma (__DBL_MAX__, __DBL_MAX__, 0.0))) + link_error (); + if (__builtin_constant_p(__builtin_fma (__DBL_MAX__, 1.0, __DBL_MAX__))) + link_error (); + if (__builtin_constant_p(__builtin_fma (__DBL_MIN__, __DBL_MIN__, 0.0))) + link_error (); + + if (__builtin_constant_p(__builtin_fmal (__LDBL_MAX__, __LDBL_MAX__, 0.0L))) + link_error (); + if (__builtin_constant_p(__builtin_fmal (__LDBL_MAX__, 1.0L, __LDBL_MAX__))) + link_error (); + if (__builtin_constant_p(__builtin_fmal (__LDBL_MIN__, __LDBL_MIN__, 0.0L))) + link_error (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-minmax-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-minmax-1.c new file mode 100644 index 000000000..13831ad3a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-minmax-1.c @@ -0,0 +1,128 @@ +/* Copyright (C) 2006 Free Software Foundation. + + Verify that built-in math function folding of fmin/fmax is + correctly performed by the compiler. + + Origin: Kaveh R. Ghazi, November 13, 2006. */ + +/* { dg-do link } */ +/* { dg-options "-fno-math-errno" } */ + +/* All references to link_error should go away at compile-time. */ +extern void link_error(int); + +#define DECLARE(FUNC) \ + extern float FUNC##f (float); \ + extern double FUNC (double); \ + extern long double FUNC##l (long double) +#define DECLARE2(FUNC) \ + extern float FUNC##f (float, float); \ + extern double FUNC (double, double); \ + extern long double FUNC##l (long double, long double) + +DECLARE2(fmin); +DECLARE2(fmax); +DECLARE(fabs); +extern int pure(int) __attribute__ ((__pure__)); + +/* Test that FUNC(x,x) == x. We cast to (long) so "!=" folds. */ +#define TEST_EQ(FUNC) do { \ + if ((long)FUNC##f(xf,xf) != (long)xf) \ + link_error(__LINE__); \ + if ((long)FUNC(x,x) != (long)x) \ + link_error(__LINE__); \ + if ((long)FUNC##l(xl,xl) != (long)xl) \ + link_error(__LINE__); \ + } while (0) + +/* Test that FUNC(purefn,purefn) == purefn. We cast to (long) so "!=" folds. */ +#define TEST_EQ_PURE(FUNC) do { \ + if ((long)FUNC##f(pure(i),pure(i)) != (long)FUNC##f(pure(i),pure(i))) \ + link_error(__LINE__); \ + if ((long)FUNC(pure(i),pure(i)) != (long)FUNC(pure(i),pure(i))) \ + link_error(__LINE__); \ + if ((long)FUNC##l(pure(i),pure(i)) != (long)FUNC##l(pure(i),pure(i))) \ + link_error(__LINE__); \ + } while (0) + +/* Test that FIXFUNC(FUNC(int1,int2)) == (TYPE)FUNC(int1,int2), + i.e. FIXFUNC should be folded away and replaced with a cast. */ +#define TEST_FIXFUNC(FUNC,FIXFUNC,TYPE) do { \ + if (FIXFUNC##f(FUNC##f(i,j)) != (TYPE)FUNC##f(i,j)) \ + link_error(__LINE__); \ + if (FIXFUNC(FUNC(i,j)) != (TYPE)FUNC(i,j)) \ + link_error(__LINE__); \ + if (FIXFUNC##l(FUNC##l(i,j)) != (TYPE)FUNC##l(i,j)) \ + link_error(__LINE__); \ + } while (0) + +/* Test that FUNC(int1,int2) has an integer return type. */ +#define TEST_INT(FUNC) do { \ + TEST_FIXFUNC(FUNC,__builtin_lround,long); \ + TEST_FIXFUNC(FUNC,__builtin_llround,long long); \ + TEST_FIXFUNC(FUNC,__builtin_lrint,long); \ + TEST_FIXFUNC(FUNC,__builtin_llrint,long long); \ + TEST_FIXFUNC(FUNC,__builtin_lceil,long); \ + TEST_FIXFUNC(FUNC,__builtin_llceil,long long); \ + TEST_FIXFUNC(FUNC,__builtin_lfloor,long); \ + TEST_FIXFUNC(FUNC,__builtin_llfloor,long long); \ + } while (0) + +/* Test that (long)fabs(FUNC(fabs(x),fabs(y))) == + (long)FUNC(fabs(x),fabs(y)). We cast to (long) so "!=" folds. */ +#define TEST_NONNEG(FUNC) do { \ + if ((long)fabsf(FUNC##f(fabsf(xf),fabsf(yf))) != (long)FUNC##f(fabsf(xf),fabsf(yf))) \ + link_error(__LINE__); \ + if ((long)fabs(FUNC(fabs(x),fabs(y))) != (long)FUNC(fabs(x),fabs(y))) \ + link_error(__LINE__); \ + if ((long)fabsl(FUNC##l(fabsl(xl),fabsl(yl))) != (long)FUNC##l(fabsl(xl),fabsl(yl))) \ + link_error(__LINE__); \ + } while (0) + +/* Test that FUNC(NaN,x) == x. We cast to (long) so "!=" folds. Set + parameter SIGNAL to `s' for testing signaling NaN. */ +#define TEST_NAN(FUNC,SIGNAL) do { \ + if ((long)FUNC##f(__builtin_nan##SIGNAL##f(""),xf) != (long)xf) \ + link_error(__LINE__); \ + if ((long)FUNC##f(xf,__builtin_nan##SIGNAL##f("")) != (long)xf) \ + link_error(__LINE__); \ + if ((long)FUNC(__builtin_nan##SIGNAL(""),x) != (long)x) \ + link_error(__LINE__); \ + if ((long)FUNC(x,__builtin_nan##SIGNAL("")) != (long)x) \ + link_error(__LINE__); \ + if ((long)FUNC##l(__builtin_nan##SIGNAL##l(""),xl) != (long)xl) \ + link_error(__LINE__); \ + if ((long)FUNC##l(xl,__builtin_nan##SIGNAL##l("")) != (long)xl) \ + link_error(__LINE__); \ + } while (0) + +void __attribute__ ((__noinline__)) + foo (float xf, double x, long double xl, + float yf, double y, long double yl, + int i, int j) +{ + TEST_EQ(fmin); + TEST_EQ(fmax); + +#ifdef __OPTIMIZE__ + TEST_EQ_PURE(fmin); + TEST_EQ_PURE(fmax); +#endif + + TEST_INT(fmin); + TEST_INT(fmax); + + TEST_NONNEG(fmin); + TEST_NONNEG(fmax); + + TEST_NAN(fmin,); + TEST_NAN(fmax,); + TEST_NAN(fmin,s); + TEST_NAN(fmax,s); +} + +int main() +{ + foo (1,1,1,1,1,1,1,1); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-modf-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-modf-1.c new file mode 100644 index 000000000..05e16ac2c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-modf-1.c @@ -0,0 +1,195 @@ +/* Copyright (C) 2007 Free Software Foundation. + + Verify that built-in folding of modf is correctly performed by the + compiler. + + Origin: Kaveh R. Ghazi, February 23, 2007. */ + +/* { dg-do link } */ +/* { dg-options "-fno-finite-math-only" { target sh*-*-* } } */ +/* { dg-options "-funsafe-math-optimizations -fsigned-zeros -fno-associative-math" { target powerpc-*-darwin* powerpc*-*-linux* } } */ + +extern void link_error(int); + +/* Return TRUE if the sign of X != sign of Y. This is important when + comparing signed zeros. */ +#define CKSGN_F(X,Y) \ + (__builtin_copysignf(1.0F,(X)) != __builtin_copysignf(1.0F,(Y))) +#define CKSGN(X,Y) \ + (__builtin_copysign(1.0,(X)) != __builtin_copysign(1.0,(Y))) +#define CKSGN_L(X,Y) \ + (__builtin_copysignl(1.0L,(X)) != __builtin_copysignl(1.0L,(Y))) + +/* We use these macros if we can only check these when optimizing. In + some cases we rely on other optimizations to propagate the value + and fold away certain constructs. Likewise for the sign testing. + TRUE means an error occurred. */ +#ifdef __OPTIMIZE__ +#define CKRES(X) (X) +#define CKIPTR(X,Y) X != Y +#define CKSGN_IPTR_F(X,Y) CKSGN_F(X,Y) +#define CKSGN_IPTR(X,Y) CKSGN(X,Y) +#define CKSGN_IPTR_L(X,Y) CKSGN_L(X,Y) +#else +#define CKRES(X) 0 +#define CKIPTR(X,Y) 0 +#define CKSGN_IPTR_F(X,Y) 0 +#define CKSGN_IPTR(X,Y) 0 +#define CKSGN_IPTR_L(X,Y) 0 +#endif + +/* Test that modf(ARG1,&iptr) == FRACRES && iptr == INTRES. Check the + sign in case we get -0.0. */ +#define TESTIT_MODF(ARG,INTRES,FRACRES) do { \ + float iptrf = 0.5; double iptr = 0.5; long double iptrl = 0.5; \ + if (__builtin_modff(ARG##f,&iptrf) != FRACRES##f \ + || CKIPTR(iptrf,INTRES##f) \ + || CKSGN_F(__builtin_modff(ARG##f,&iptrf),FRACRES##f) \ + || CKSGN_IPTR_F(iptrf,INTRES##f)) \ + link_error(__LINE__); \ + if (__builtin_modf(ARG,&iptr) != FRACRES \ + || CKIPTR(iptr,INTRES) \ + || CKSGN(__builtin_modf(ARG,&iptr),FRACRES) \ + || CKSGN_IPTR(iptr,INTRES)) \ + link_error(__LINE__); \ + if (__builtin_modfl(ARG##l,&iptrl) != FRACRES##l \ + || CKIPTR(iptrl,INTRES##l) \ + || CKSGN_L(__builtin_modfl(ARG##l,&iptrl),FRACRES##l) \ + || CKSGN_IPTR_L(iptrl,INTRES##l)) \ + link_error(__LINE__); \ + } while (0) + +/* Test that modf(NEG FUNCARG(ARGARG, &iptr)) == FRACRES && + FUNCRES(iptr) is true. Check the sign of both as well. This is + for checking an argument of Inf. */ +#ifndef __SPU__ +#define TESTIT_MODF2(NEG,FUNCARG,ARGARG,FUNCRES,FRACRES) do { \ + float iptrf = 0.5; double iptr = 0.5; long double iptrl = 0.5; \ + if (__builtin_modff(NEG __builtin_##FUNCARG##f(ARGARG),&iptrf) != FRACRES##f \ + || CKSGN_F(__builtin_modff(NEG __builtin_##FUNCARG##f(ARGARG),&iptrf), FRACRES##f) \ + || CKIPTR(!__builtin_##FUNCRES##f(iptrf),0) \ + || CKSGN_IPTR_F(iptrf,FRACRES##f)) \ + link_error(__LINE__); \ + if (__builtin_modf(NEG __builtin_##FUNCARG(ARGARG),&iptr) != FRACRES \ + || CKSGN(__builtin_modf(NEG __builtin_##FUNCARG(ARGARG),&iptr), FRACRES) \ + || CKIPTR(!__builtin_##FUNCRES(iptr),0) \ + || CKSGN_IPTR(iptr,FRACRES)) \ + link_error(__LINE__); \ + if (__builtin_modfl(NEG __builtin_##FUNCARG##l(ARGARG),&iptrl) != FRACRES##l \ + || CKSGN_L(__builtin_modfl(NEG __builtin_##FUNCARG##l(ARGARG),&iptrl), FRACRES##l) \ + || CKIPTR(!__builtin_##FUNCRES##l(iptrl),0) \ + || CKSGN_IPTR_L(iptrl,FRACRES##l)) \ + link_error(__LINE__); \ + } while (0) +#else +#define TESTIT_MODF2(NEG,FUNCARG,ARGARG,FUNCRES,FRACRES) do { \ + /* SPU single-precision floating point format does not support Inf or Nan. */ \ + double iptr = 0.5; long double iptrl = 0.5; \ + if (__builtin_modf(NEG __builtin_##FUNCARG(ARGARG),&iptr) != FRACRES \ + || CKSGN(__builtin_modf(NEG __builtin_##FUNCARG(ARGARG),&iptr), FRACRES) \ + || CKIPTR(!__builtin_##FUNCRES(iptr),0) \ + || CKSGN_IPTR(iptr,FRACRES)) \ + link_error(__LINE__); \ + if (__builtin_modfl(NEG __builtin_##FUNCARG##l(ARGARG),&iptrl) != FRACRES##l \ + || CKSGN_L(__builtin_modfl(NEG __builtin_##FUNCARG##l(ARGARG),&iptrl), FRACRES##l) \ + || CKIPTR(!__builtin_##FUNCRES##l(iptrl),0) \ + || CKSGN_IPTR_L(iptrl,FRACRES##l)) \ + link_error(__LINE__); \ + } while (0) +#endif + +/* Test that FUNCRES(modf(NEG FUNCARG(ARGARG, &iptr))) is true && + FUNCRES(iptr) is true. Check the sign of both as well. This is + for checking an argument of NaN. */ +#ifndef __SPU__ +#define TESTIT_MODF3(NEG,FUNCARG,ARGARG,FUNCRES) do { \ + float iptrf = 0.5; double iptr = 0.5; long double iptrl = 0.5; \ + if (CKRES(!__builtin_##FUNCRES##f(__builtin_modff(NEG __builtin_##FUNCARG##f(ARGARG),&iptrf))) \ + || CKSGN_F(__builtin_modff(NEG __builtin_##FUNCARG##f(ARGARG),&iptrf), NEG 1) \ + || CKIPTR(!__builtin_##FUNCRES##f(iptrf),0) \ + || CKSGN_IPTR_F(iptrf,NEG 1)) \ + link_error(__LINE__); \ + if (CKRES(!__builtin_##FUNCRES(__builtin_modf(NEG __builtin_##FUNCARG(ARGARG),&iptr))) \ + || CKSGN(__builtin_modf(NEG __builtin_##FUNCARG(ARGARG),&iptr), NEG 1) \ + || CKIPTR(!__builtin_##FUNCRES(iptr),0) \ + || CKSGN_IPTR(iptr,NEG 1)) \ + link_error(__LINE__); \ + if (CKRES(!__builtin_##FUNCRES##l(__builtin_modfl(NEG __builtin_##FUNCARG##l(ARGARG),&iptrl))) \ + || CKSGN_L(__builtin_modfl(NEG __builtin_##FUNCARG##l(ARGARG),&iptrl), NEG 1) \ + || CKIPTR(!__builtin_##FUNCRES##l(iptrl),0) \ + || CKSGN_IPTR_L(iptrl,NEG 1)) \ + link_error(__LINE__); \ + } while (0) +#else +#define TESTIT_MODF3(NEG,FUNCARG,ARGARG,FUNCRES) do { \ + /* SPU single-precision floating point format does not support Inf or Nan. */ \ + double iptr = 0.5; long double iptrl = 0.5; \ + if (CKRES(!__builtin_##FUNCRES(__builtin_modf(NEG __builtin_##FUNCARG(ARGARG),&iptr))) \ + || CKSGN(__builtin_modf(NEG __builtin_##FUNCARG(ARGARG),&iptr), NEG 1) \ + || CKIPTR(!__builtin_##FUNCRES(iptr),0) \ + || CKSGN_IPTR(iptr,NEG 1)) \ + link_error(__LINE__); \ + if (CKRES(!__builtin_##FUNCRES##l(__builtin_modfl(NEG __builtin_##FUNCARG##l(ARGARG),&iptrl))) \ + || CKSGN_L(__builtin_modfl(NEG __builtin_##FUNCARG##l(ARGARG),&iptrl), NEG 1) \ + || CKIPTR(!__builtin_##FUNCRES##l(iptrl),0) \ + || CKSGN_IPTR_L(iptrl,NEG 1)) \ + link_error(__LINE__); \ + } while (0) +#endif + +void __attribute__ ((__noinline__)) +foo(void) +{ + /* Test that modf(ARG1,&iptr) -> ARG3 && iptr == ARG2. */ + TESTIT_MODF (0x1p10F+0.5, 0x1p10, 0.5); + TESTIT_MODF (0x1p10F+0x1p-10, 0x1p10, 0x1p-10); + TESTIT_MODF (12345678L/17.0, 726216.0, -726216L+12345678L/17.0); + TESTIT_MODF (555.555, 555.0, -555+555.555); + TESTIT_MODF (5000/11.0, 454.0, -454+5000/11.0); + TESTIT_MODF (1000/7.0, 142.0, -142+1000/7.0); + TESTIT_MODF (123/7.0, 17.0, -17+123/7.0); + TESTIT_MODF (117/7.0, 16.0, -16+117/7.0); + TESTIT_MODF (5.5, 5.0, 0.5); + TESTIT_MODF (1.5, 1.0, 0.5); + TESTIT_MODF (4/3.0, 1.0, -1+4/3.0); + TESTIT_MODF (1.0, 1.0, 0.0); + TESTIT_MODF (0.5, 0.0, 0.5); + TESTIT_MODF (4/9.0, 0.0, 4/9.0); + TESTIT_MODF (1/3.0, 0.0, 1/3.0); + TESTIT_MODF (1/9.0, 0.0, 1/9.0); + TESTIT_MODF (0.0, 0.0, 0.0); + + TESTIT_MODF (-0.0, -0.0, -0.0); + TESTIT_MODF (-1/9.0, -0.0, -1/9.0); + TESTIT_MODF (-1/3.0, -0.0, -1/3.0); + TESTIT_MODF (-4/9.0, -0.0, -4/9.0); + TESTIT_MODF (-0.5, -0.0, -0.5); + TESTIT_MODF (-1.0, -1.0, -0.0); + TESTIT_MODF (-4/3.0, -1.0, 1-4/3.0); + TESTIT_MODF (-1.5, -1.0, -0.5); + TESTIT_MODF (-5.5, -5.0, -0.5); + TESTIT_MODF (-117/7.0, -16.0, 16-117/7.0); + TESTIT_MODF (-123/7.0, -17.0, 17-123/7.0); + TESTIT_MODF (-1000/7.0, -142.0, 142-1000/7.0); + TESTIT_MODF (-5000/11.0, -454.0, 454-5000/11.0); + TESTIT_MODF (-555.555, -555.0, 555-555.555); + TESTIT_MODF (-12345678L/17.0, -726216.0, 726216L-12345678L/17.0); + TESTIT_MODF (-0x1p10F-0x1p-10, -0x1p10, -0x1p-10); + TESTIT_MODF (-0x1p10F-0.5, -0x1p10, -0.5); + + + /* Test for modf(+-Inf,&i) -> (i=+-0.0, +-Inf). */ + TESTIT_MODF2 ( ,inf, , isinf, 0.0); + TESTIT_MODF2 (- ,inf, , isinf, -0.0); + + /* Test for and modf(+-NaN,&i) -> (i=+-NaN, +-NaN). */ + TESTIT_MODF3 ( ,nan, "", isnan); + TESTIT_MODF3 (- ,nan, "", isnan); +} + +int main() +{ + foo(); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-nonneg-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-nonneg-1.c new file mode 100644 index 000000000..8a3286a59 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-nonneg-1.c @@ -0,0 +1,180 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Verify that GCC can determine which built-in functions produce a + nonnegative result. + + Written by Kaveh Ghazi, 2004-03-10. */ + +/* { dg-do link } */ +/* { dg-options "-ffast-math" } */ + +#define PROTOTYPE_RTYPE(FN,RTYPE) extern RTYPE FN(double); \ + extern RTYPE FN##f(float); \ + extern RTYPE FN##l(long double); +#define PROTOTYPE(FN) extern double FN(double); extern float FN##f(float); \ + extern long double FN##l(long double); +#define PROTOTYPE2(FN) extern double FN(double, double); \ + extern float FN##f(float, float); \ + extern long double FN##l(long double, long double); +#define CPROTOTYPE1(FN) extern double FN(_Complex double); \ + extern float FN##f(_Complex float); \ + extern long double FN##l(_Complex long double); +#define CPROTOTYPE1(FN) extern double FN(_Complex double); \ + extern float FN##f(_Complex float); \ + extern long double FN##l(_Complex long double); +#define IPROTOTYPE(FN) extern int FN(int); extern int FN##l(long); \ + extern int FN##ll(long long); +#define PROTOTYPE2TYPE2(FN,A2TYPE) extern double FN(double, A2TYPE); \ + extern float FN##f(float, A2TYPE); \ + extern long double FN##l(long double, A2TYPE); +#define PROTOTYPE2_A2FPTR(FN) extern double FN(double, double *); \ + extern float FN##f(float, float *); \ + extern long double FN##l(long double, long double *); + +extern int signbit (double); +extern int signbitf (float); +extern int signbitl (long double); + +void test(double d1, double d2, float f1, float f2, + long double ld1, long double ld2) +{ + /* These are always nonnegative. */ + +#define TEST1(FN) \ + extern void link_failure_##FN (void); PROTOTYPE(FN) \ + if (signbit(FN(d1)) || signbitf(FN##f(f1)) || signbitl(FN##l(ld1))) \ + link_failure_##FN() + +#define TEST2(FN) \ + extern void link_failure_##FN (void); PROTOTYPE2(FN) \ + if (signbit(FN(d1,d2)) || signbitf(FN##f(f1,f2)) || signbitl(FN##l(ld1,ld2))) \ + link_failure_##FN() + +#define CTEST1(FN) \ + extern void link_failure_##FN (void); CPROTOTYPE1(FN) \ + if (signbit(FN(d1)) || signbitf(FN##f(f1)) || signbitl(FN##l(ld1))) \ + link_failure_##FN() + +#define ITEST1(FN) \ + extern void link_failure_##FN (void); IPROTOTYPE(FN) \ + if (signbit(FN(d1)) || signbitf(FN##l(f1)) || signbitl(FN##ll(ld1))) \ + link_failure_##FN() + + TEST1 (acos); + TEST1 (acosh); + CTEST1 (cabs); + TEST1 (cosh); + TEST1 (erfc); + TEST1 (exp); + TEST1 (exp10); + TEST1 (exp2); + TEST1 (fabs); + TEST2 (fdim); + TEST2 (hypot); + TEST1 (pow10); + TEST1 (sqrt); + ITEST1 (ffs); + ITEST1 (__builtin_parity); + ITEST1 (__builtin_popcount); + + /* These are nonnegative if the first argument is. */ +#define ARG1TEST1(FN) \ + extern void link_failure_##FN (void); PROTOTYPE(FN) \ + if (signbit(FN(fabs(d1))) || signbitf(FN##f(fabsf(f1))) \ + || signbitl(FN##l(fabsl(ld1)))) \ + link_failure_##FN() + + /* Same, but allow specifying the return type. */ +#define ARG1TEST1_RTYPE(FN,RTYPE) \ + extern void link_failure_##FN (void); PROTOTYPE_RTYPE(FN,RTYPE) \ + if (signbit(FN(fabs(d1))) || signbitf(FN##f(fabsf(f1))) \ + || signbitl(FN##l(fabsl(ld1)))) \ + link_failure_##FN() + + /* These are nonnegative if the first argument is. */ +#define ARG1TEST2(FN) \ + extern void link_failure_##FN (void); PROTOTYPE2(FN) \ + if (signbit(FN(fabs(d1),d2)) || signbitf(FN##f(fabsf(f1),f2)) \ + || signbitl(FN##l(fabsl(ld1),ld2))) \ + link_failure_##FN() + + /* These are nonnegative if the second argument is. */ +#define ARG2TEST2(FN) \ + extern void link_failure_##FN (void); PROTOTYPE2(FN) \ + if (signbit(FN(d1,fabs(d2))) || signbitf(FN##f(f1,fabsf(f2))) \ + || signbitl(FN##l(ld1,fabsl(ld2)))) \ + link_failure_##FN() + + /* These are nonnegative if the first OR second argument is. */ +#define ARG2TESTor(FN) \ + extern void link_failure_##FN (void); PROTOTYPE2(FN) \ + if (signbit(FN(fabs(d1),d2)) || signbitf(FN##f(fabsf(f1),f2)) \ + || signbitl(FN##l(fabsl(ld1),ld2)) || signbit(FN(d1,fabs(d2))) \ + || signbitf(FN##f(f1,fabsf(f2))) || signbitl(FN##l(ld1,fabsl(ld2)))) \ + link_failure_##FN() + + /* These are nonnegative if the first AND second argument is. */ +#define ARG2TESTand(FN) \ + extern void link_failure_##FN (void); PROTOTYPE2(FN) \ + if (signbit(FN(fabs(d1),fabs(d2))) || signbitf(FN##f(fabsf(f1),fabsf(f2))) \ + || signbitl(FN##l(fabsl(ld1),fabsl(ld2)))) \ + link_failure_##FN() + + /* These are nonnegative if the first argument is, 2nd arg is an int. */ +#define ARG1TEST2_A2INT(FN, INTTYPE) \ + extern void link_failure_##FN (void); PROTOTYPE2TYPE2(FN, INTTYPE) \ + if (signbit(FN(fabs(d1),d2)) || signbitf(FN##f(fabsf(f1),f2)) \ + || signbitl(FN##l(fabsl(ld1),ld2))) \ + link_failure_##FN() + + /* These are nonnegative if the first argument is, specify 2nd arg. */ +#define ARG2TEST1_A2FPTR(FN) \ + extern void link_failure_##FN (void); PROTOTYPE2_A2FPTR(FN) \ + if (signbit(FN(fabs(d1),&d2)) || signbitf(FN##f(fabsf(f1),&f2)) \ + || signbitl(FN##l(fabsl(ld1),&ld2))) \ + link_failure_##FN() + + ARG1TEST1 (asinh); + ARG1TEST1 (atan); + ARG1TEST1 (atanh); + ARG1TEST1 (cbrt); + ARG1TEST1 (ceil); + ARG1TEST1 (erf); + ARG1TEST1 (expm1); + ARG1TEST1 (floor); + ARG1TEST2 (fmod); + ARG1TEST2_A2INT (ldexp, int); + ARG1TEST1_RTYPE (__builtin_llceil, long long); + ARG1TEST1_RTYPE (__builtin_llfloor, long long); + ARG1TEST1_RTYPE (llrint, long long); + ARG1TEST1_RTYPE (llround, long long); + ARG1TEST1_RTYPE (__builtin_lceil, long); + ARG1TEST1_RTYPE (__builtin_lfloor, long); + ARG1TEST1_RTYPE (lrint, long); + ARG1TEST1_RTYPE (lround, long); + /* The modf* functions aren't ever "const" or "pure" even with + -ffast-math so they won't be eliminated and yield a link failure. */ + /* ARG2TEST1_A2FPTR (modf);*/ + ARG1TEST1 (nearbyint); + ARG1TEST2 (pow); + ARG1TEST1 (rint); + ARG1TEST1 (round); + ARG1TEST2 (scalb); + ARG1TEST2_A2INT (scalbln, long); + ARG1TEST2_A2INT (scalbn, int); + ARG1TEST1_RTYPE (signbit, int); + ARG1TEST1 (significand); + ARG1TEST1 (sinh); + ARG1TEST1 (tanh); + ARG1TEST1 (trunc); + + ARG2TESTor (fmax); + ARG2TESTand (fmin); + ARG2TEST2 (copysign); + +} + +int main (void) +{ + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-noret-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-noret-1.c new file mode 100644 index 000000000..d3e97701f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-noret-1.c @@ -0,0 +1,79 @@ +/* Test for builtin noreturn attributes. */ +/* Origin: Joseph Myers <jsm28@cam.ac.uk> */ +/* { dg-options "-multiply_defined suppress" { target powerpc-*-darwin* } } */ +/* { dg-do link } */ +/* { dg-require-weak "" } */ + +extern void abort (void); +extern void exit (int); +extern void _exit (int); +extern void _Exit (int); + +extern void tabort (void); +extern void texit (void); +extern void t_exit (void); +extern void t_Exit (void); + +extern void link_failure (void); + +/* Some libcs have _exit and/or _Exit, and won't allow it to be re-defined, + so make it weak. */ +#pragma weak _exit +#pragma weak _Exit + +int +main (void) +{ + volatile int i = 0; + if (i) + tabort (); + if (i) + texit (); + if (i) + t_exit (); + if (i) + t_Exit (); + exit (0); +} + +void +tabort (void) +{ + abort (); + link_failure (); +} + +void +texit (void) +{ + exit (1); + link_failure (); +} + +void +t_exit (void) +{ + _exit (1); + link_failure (); +} + +/* Some non-Unix libcs might not have _exit. */ +void +_exit (int i) +{ + abort (); +} + +void +t_Exit (void) +{ + _Exit (1); + link_failure (); +} + +/* Some libcs might not have _Exit. */ +void +_Exit (int i) +{ + abort (); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-noret-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-noret-2.c new file mode 100644 index 000000000..1103e3d81 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-noret-2.c @@ -0,0 +1,89 @@ +/* Test for builtin noreturn attributes when the visible declarations + are function-local. Modified from builtin-noret-1.c by Zack Weinberg + <zack@codesourcery.com>. */ +/* { dg-options "-multiply_defined suppress" { target powerpc-*-darwin* } } */ +/* { dg-do link } */ +/* { dg-require-weak "" } */ + +extern void tabort (void); +extern void texit (void); +extern void t_exit (void); +extern void t_Exit (void); + +extern void link_failure (void); + +int +main (void) +{ + volatile int i = 0; + extern void exit (int); + if (i) + tabort (); + if (i) + texit (); + if (i) + t_exit (); + if (i) + t_Exit (); + exit (0); +} + +void +tabort (void) +{ + extern void abort (void); + abort (); + link_failure (); +} + +void +texit (void) +{ + extern void exit (int); + exit (1); + link_failure (); +} + +void +t_exit (void) +{ + extern void _exit (int); + /* Some non-Unix libcs have _exit, and won't allow it to be re-defined, + so make it weak. */ +#pragma weak _exit + _exit (1); + link_failure (); +} + +/* Some non-Unix libcs might not have _exit. */ +/* Some non-Unix libcs have _exit, and won't allow it to be re-defined, + so make it weak. */ +#pragma weak _exit +void +_exit (int i) +{ + extern void abort (void); + abort (); +} + +void +t_Exit (void) +{ + extern void _Exit (int); + /* Some libcs have _Exit, and won't allow it to be re-defined, + so make it weak. */ +#pragma weak _Exit + _Exit (1); + link_failure (); +} + +/* Some libcs might not have _Exit. */ +/* Some libcs have _Exit, and won't allow it to be re-defined, + so make it weak. */ +#pragma weak _Exit +void +_Exit (int i) +{ + extern void abort (void); + abort (); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-pow-mpfr-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-pow-mpfr-1.c new file mode 100644 index 000000000..6206b9ee3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-pow-mpfr-1.c @@ -0,0 +1,19 @@ +/* Version 2.2.0 of MPFR had bugs in pow underflow/overflow. This + test checks to see if that buggy version was installed. The + problem is NOT fixed with the version 2.2.0 "cumulative patch". + However it is fixed in version 2.2.1 and presumably later MPFR + versions. + + Origin: Kaveh R. Ghazi 12/17/2006. */ + +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ + +extern double testit() +{ + /* This underflows and therefore gcc should not fold it. */ + return __builtin_pow (0.11, 1.0e38); +} + +/* { dg-final { scan-tree-dump "pow" "original" } } */ +/* { dg-final { cleanup-tree-dump "original" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-power-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-power-1.c new file mode 100644 index 000000000..9e7c25adb --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-power-1.c @@ -0,0 +1,114 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Verify that built-in folding of various math "power" functions is + correctly performed by the compiler. + + Written by Kaveh Ghazi, 2004-03-11. */ + +/* { dg-do link } */ +/* { dg-options "-ffast-math" } */ +/* { dg-add-options c99_runtime } */ +/* { dg-skip-if "PR44214" { *-*-* } { "-O0" } { "" } } */ + +#include "../builtins-config.h" + +#ifdef HAVE_C99_RUNTIME +#define C99CODE(CODE) CODE +#else +#define C99CODE(CODE) 0 +#endif + +#define PROTOTYPE(FN) extern double FN(double); extern float FN##f(float); \ + extern long double FN##l(long double); +#define PROTOTYPE2(FN) extern double FN(double, double); \ + extern float FN##f(float, float); \ + extern long double FN##l(long double, long double); + +PROTOTYPE(fabs) +PROTOTYPE(sqrt) +PROTOTYPE(cbrt) +PROTOTYPE2(pow) + +void test(double d1, double d2, double d3, + float f1, float f2, float f3, + long double ld1, long double ld2, long double ld3) +{ + /* Test N1root(N2root(x)) -> pow(x,1/(N1*N2)). */ + /* E.g. sqrt(cbrt(x)) -> pow(x,1/6). */ + /* The `ABS' argument is `fabs' when the transformation only works + for nonnegative arguments. Otherwise it's blank. */ +#define ROOT_ROOT(FN1,N1,FN2,N2,ABS) \ + extern void link_failure_##FN1##_##FN2(void); \ + if (FN1(FN2(ABS(d1))) != pow(ABS(d1),1.0/(N1*N2)) \ + || C99CODE (FN1##f(FN2##f(ABS(f1))) != powf(ABS(f1),1.0F/(N1*N2))) \ + || C99CODE (FN1##l(FN2##l(ABS(ld1))) != powl(ABS(ld1),1.0L/(N1*N2)))) \ + link_failure_##FN1##_##FN2() + + ROOT_ROOT(sqrt,2,sqrt,2,); + ROOT_ROOT(sqrt,2,cbrt,3,); + ROOT_ROOT(cbrt,3,sqrt,2,); + ROOT_ROOT(cbrt,3,cbrt,3,fabs); + + /* Test pow(Nroot(x),y) -> pow(x,y/N). */ + /* The `ABS' argument is `fabs' when the transformation only works + for nonnegative arguments. Otherwise it's blank. */ +#define POW_ROOT(FN,N,ABS) \ + extern void link_failure_pow_##FN(void); \ + if (pow(FN(ABS(d1)), d2) != pow(ABS(d1),d2/N) \ + || powf(FN##f(ABS(f1)),f2) != powf(ABS(f1),f2/N) \ + || powl(FN##l(ABS(ld1)),ld2) != powl(ABS(ld1),ld2/N)) \ + link_failure_pow_##FN() + + POW_ROOT(sqrt,2,); + POW_ROOT(cbrt,3,fabs); + + /* Test Nroot(pow(x,y)) -> pow(x,y/N). */ + /* The `ABS' argument is `fabs' when the transformation only works + for nonnegative arguments. Otherwise it's blank. */ +#define ROOT_POW(FN,N,ABS) \ + extern void link_failure_##FN##_pow(void); \ + if (FN(pow(ABS(d1), d2)) != pow(ABS(d1),d2/N) \ + || FN##f(powf(ABS(f1),f2)) != powf(ABS(f1),f2/N) \ + || FN##l(powl(ABS(ld1),ld2)) != powl(ABS(ld1),ld2/N)) \ + link_failure_##FN##_pow() + + ROOT_POW(sqrt,2,fabs); + ROOT_POW(cbrt,3,fabs); + + /* Test pow(pow(x,y),z) -> pow(x,y*z). */ +#define POW_POW \ + extern void link_failure_pow_pow(void); \ + if (pow(pow(fabs(d1), d2), d3) != pow(fabs(d1),d2*d3) \ + || powf(powf(fabs(f1),f2),f3) != powf(fabs(f1),f2*f3) \ + || powl(powl(fabs(ld1),ld2),ld3) != powl(fabs(ld1),ld2*ld3)) \ + link_failure_pow_pow() + + POW_POW; + + /* Test Nroot(x)*Nroot(y) -> Nroot(x*y). */ +#define ROOT_X_ROOT(FN) \ + extern void link_failure_root_x_root(void); \ + if (FN(d1)*FN(d2) != FN(d1*d2) \ + || FN##f(f1)*FN##f(f2) != FN##f(f1*f2) \ + || FN##l(ld1)*FN##l(ld2) != FN##l(ld1*ld2)) \ + link_failure_root_x_root() + + ROOT_X_ROOT(sqrt); + ROOT_X_ROOT(cbrt); + + /* Test pow(x,y)*pow(x,z) -> pow(x,y+z). */ +#define POW_X_POW \ + extern void link_failure_pow_x_pow(void); \ + if (pow(d1,d2)*pow(d1,d3) != pow(d1,d2+d3) \ + || powf(f1,f2)*powf(f1,f3) != powf(f1,f2+f3) \ + || powl(ld1,ld2)*powl(ld1,ld3) != powl(ld1,ld2+ld3)) \ + link_failure_pow_x_pow() + + POW_X_POW; + +} + +int main (void) +{ + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-rounding-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-rounding-1.c new file mode 100644 index 000000000..816cffc04 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-rounding-1.c @@ -0,0 +1,120 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Check that constant folding of the rounding math functions doesn't + break anything and produces the expected results. + + Written by Kaveh Ghazi, 2004-04-29. */ + +/* { dg-do link } */ + +extern int link_error (int); + +#define TEST(FN, VALUE, RESULT) \ + if (__builtin_##FN (VALUE) != RESULT) link_error (__LINE__); \ + if (__builtin_##FN##f (VALUE) != RESULT) link_error (__LINE__); \ + if (__builtin_##FN##l (VALUE) != RESULT) link_error (__LINE__); \ + +int +main (void) +{ + TEST(trunc, 0, 0); + TEST(floor, 0, 0); + TEST(ceil, 0, 0); + TEST(round, 0, 0); + TEST(lround, 0, 0); + TEST(llround, 0, 0); + TEST(lfloor, 0, 0); + TEST(llfloor, 0, 0); + TEST(lceil, 0, 0); + TEST(llceil, 0, 0); + + TEST(trunc, 6, 6); + TEST(floor, 6, 6); + TEST(ceil, 6, 6); + TEST(round, 6, 6); + TEST(lround, 6, 6); + TEST(llround, 6, 6); + TEST(lfloor, 6, 6); + TEST(llfloor, 6, 6); + TEST(lceil, 6, 6); + TEST(llceil, 6, 6); + + TEST(trunc, -8, -8); + TEST(floor, -8, -8); + TEST(ceil, -8, -8); + TEST(round, -8, -8); + TEST(lround, -8, -8); + TEST(llround, -8, -8); + TEST(lfloor, -8, -8); + TEST(llfloor, -8, -8); + TEST(lceil, -8, -8); + TEST(llceil, -8, -8); + + TEST(trunc, 3.2, 3); + TEST(floor, 3.2, 3); + TEST(ceil, 3.2, 4); + TEST(round, 3.2, 3); + TEST(lround, 3.2, 3); + TEST(llround, 3.2, 3); + TEST(lfloor, 3.2, 3); + TEST(llfloor, 3.2, 3); + TEST(lceil, 3.2, 4); + TEST(llceil, 3.2, 4); + + TEST(trunc, -2.8, -2); + TEST(floor, -2.8, -3); + TEST(ceil, -2.8, -2); + TEST(round, -2.8, -3); + TEST(lround, -2.8, -3); + TEST(llround, -2.8, -3); + TEST(lfloor, -2.8, -3); + TEST(llfloor, -2.8, -3); + TEST(lceil, -2.8, -2); + TEST(llceil, -2.8, -2); + + TEST(trunc, 0.01, 0); + TEST(floor, 0.01, 0); + TEST(ceil, 0.01, 1); + TEST(round, 0.01, 0); + TEST(lround, 0.01, 0); + TEST(llround, 0.01, 0); + TEST(lfloor, 0.01, 0); + TEST(llfloor, 0.01, 0); + TEST(lceil, 0.01, 1); + TEST(llceil, 0.01, 1); + + TEST(trunc, -0.7, 0); + TEST(floor, -0.7, -1); + TEST(ceil, -0.7, 0); + TEST(round, -0.7, -1); + TEST(lround, -0.7, -1); + TEST(llround, -0.7, -1); + TEST(lfloor, -0.7, -1); + TEST(llfloor, -0.7, -1); + TEST(lceil, -0.7, 0); + TEST(llceil, -0.7, 0); + + TEST(trunc, 2.5, 2); + TEST(floor, 2.5, 2); + TEST(ceil, 2.5, 3); + TEST(round, 2.5, 3); + TEST(lround, 2.5, 3); + TEST(llround, 2.5, 3); + TEST(lfloor, 2.5, 2); + TEST(llfloor, 2.5, 2); + TEST(lceil, 2.5, 3); + TEST(llceil, 2.5, 3); + + TEST(trunc, -1.5, -1); + TEST(floor, -1.5, -2); + TEST(ceil, -1.5, -1); + TEST(round, -1.5, -2); + TEST(lround, -1.5, -2); + TEST(llround, -1.5, -2); + TEST(lfloor, -1.5, -2); + TEST(llfloor, -1.5, -2); + TEST(lceil, -1.5, -1); + TEST(llceil, -1.5, -1); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-self.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-self.c new file mode 100644 index 000000000..6d1719f75 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-self.c @@ -0,0 +1,10 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* Check that we can use this idiom to define out-of-line copies of built-in + functions. This is used by libgcc/sync.c, for example. */ +void __sync_synchronize (void) +{ + __sync_synchronize (); +} +/* { dg-final { scan-assembler "__sync_synchronize" } } */ +/* { dg-final { scan-assembler "\t(lock|mfence)" } } */ +/* { dg-final { scan-assembler-not "\tcall" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-sin-mpfr-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-sin-mpfr-1.c new file mode 100644 index 000000000..359728708 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-sin-mpfr-1.c @@ -0,0 +1,29 @@ +/* Version 2.2.0 of MPFR had bugs in sin rounding. This test checks + to see if that buggy version was installed. The problem is fixed + in version 2.2.1 and presumably later MPFR versions. + + Origin: Kaveh R. Ghazi 10/23/2006. */ + +/* { dg-do link } */ + +extern void link_error (int, double, double); + +#define TESTIT(ARG,RES) do { \ + if (sizeof (double) == 8 && __builtin_sin(ARG) != RES) \ + link_error(__LINE__, __builtin_sin(ARG), RES); \ + } while (0); + +int main() +{ + TESTIT (-0x1.c0016155c4da3p-1, -0x1.88fc58bcf030dp-1); + + TESTIT (0x1.30654d85c2756p-2, 0x1.2beeb9de27a79p-2); + + TESTIT (0x1.fe68ccaa8e201p+2, 0x1.fc3f0c54e97a7p-1); + + /* This case should always pass. */ + TESTIT (0.0, 0.0); + + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-symmetric-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-symmetric-1.c new file mode 100644 index 000000000..4834d8e2b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-symmetric-1.c @@ -0,0 +1,111 @@ +/* Copyright (C) 2006 Free Software Foundation. + + Verify that built-in math function folding of symmetric even and + odd functions is correctly performed by the compiler. + + Origin: Kaveh R. Ghazi, November 09, 2006. */ + +/* { dg-do link } */ +/* { dg-options "-ffast-math" } */ + +/* All references to link_error should go away at compile-time. */ +extern void link_error(int); + +/* Test that FUNC(-ARG) == FUNC(ARG). */ +#define TESTIT_EVEN(FUNC) do { \ + if (__builtin_##FUNC##f(-xf) != __builtin_##FUNC##f(xf)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC(-x) != __builtin_##FUNC(x)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC##l(-xl) != __builtin_##FUNC##l(xl)) \ + link_error(__LINE__); \ + } while (0) + +/* Test that FUNC(-ARG) == FUNC(ARG), where ARG has a complex type. */ +#define TESTIT_EVEN_C(FUNC) do { \ + if (__builtin_##FUNC##f(-cxf) != __builtin_##FUNC##f(cxf)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC(-cx) != __builtin_##FUNC(cx)) \ + link_error(__LINE__); \ + if (__builtin_##FUNC##l(-cxl) != __builtin_##FUNC##l(cxl)) \ + link_error(__LINE__); \ + } while (0) + +/* Test that FUNC(-VAR) == FUNC(VAR), where VAR has an int type. */ +#define TESTIT_EVEN_I(FUNC,VAR) do { \ + if (__builtin_##FUNC(-VAR) != __builtin_##FUNC(VAR)) \ + link_error(__LINE__); \ + } while (0) + +/* Test that -FUNC(ARG) == FUNC(-ARG). */ +#define TESTIT_ODD(FUNC) do { \ + if (-__builtin_##FUNC##f(-xf) != __builtin_##FUNC##f(xf)) \ + link_error(__LINE__); \ + if (-__builtin_##FUNC(-x) != __builtin_##FUNC(x)) \ + link_error(__LINE__); \ + if (-__builtin_##FUNC##l(-xl) != __builtin_##FUNC##l(xl)) \ + link_error(__LINE__); \ + } while (0) + +/* Test that -FUNC(ARG) == FUNC(-ARG), where ARG has a complex type. */ +#define TESTIT_ODD_C(FUNC) do { \ + if (-__builtin_##FUNC##f(-cxf) != __builtin_##FUNC##f(cxf)) \ + link_error(__LINE__); \ + if (-__builtin_##FUNC(-cx) != __builtin_##FUNC(cx)) \ + link_error(__LINE__); \ + if (-__builtin_##FUNC##l(-cxl) != __builtin_##FUNC##l(cxl)) \ + link_error(__LINE__); \ + } while (0) + +void foo (float xf, double x, long double xl, + __complex__ float cxf, __complex__ double cx, __complex__ long double cxl, + int i, long l, long long ll, __INTMAX_TYPE__ im) +{ + TESTIT_EVEN(cos); + TESTIT_EVEN(cosh); + TESTIT_EVEN(fabs); + + TESTIT_EVEN_C(ccos); + TESTIT_EVEN_C(ccosh); + TESTIT_EVEN_C(cabs); + + TESTIT_EVEN_I(abs, i); + TESTIT_EVEN_I(imaxabs, im); + TESTIT_EVEN_I(labs, l); + TESTIT_EVEN_I(llabs, ll); + + TESTIT_ODD(asin); + TESTIT_ODD(asinh); + TESTIT_ODD(atan); + TESTIT_ODD(atanh); + TESTIT_ODD(cbrt); + TESTIT_ODD(erf); + TESTIT_ODD(llrint); + TESTIT_ODD(llround); + TESTIT_ODD(lrint); + TESTIT_ODD(lround); + TESTIT_ODD(nearbyint); + TESTIT_ODD(rint); + TESTIT_ODD(round); + TESTIT_ODD(sin); + TESTIT_ODD(sinh); + TESTIT_ODD(tan); + TESTIT_ODD(tanh); + TESTIT_ODD(trunc); + + TESTIT_ODD_C(casin); + TESTIT_ODD_C(casinh); + TESTIT_ODD_C(catan); + TESTIT_ODD_C(catanh); + TESTIT_ODD_C(cproj); + TESTIT_ODD_C(csin); + TESTIT_ODD_C(csinh); + TESTIT_ODD_C(ctan); + TESTIT_ODD_C(ctanh); +} + +int main() +{ + foo (1,1,1,1,1,1,1,1,1,1); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-wctype-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-wctype-1.c new file mode 100644 index 000000000..5b4371e14 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-wctype-1.c @@ -0,0 +1,57 @@ +/* Copyright (C) 2004, 2005 Free Software Foundation. + + Verify that built-in wctype function attributes are correctly set + by the compiler. + + Written by Kaveh Ghazi, 2004-03-25. */ + +/* { dg-do link } */ + +/* Use the target type definitions if we can. */ +#ifndef __WINT_TYPE__ +#define __WINT_TYPE__ int +#endif + +#ifndef __WCHAR_TYPE__ +#define __WCHAR_TYPE__ int +#endif + +void test(int i) +{ + /* All of these ctype functions should be const/pure and thus + eliminated. */ +#define TEST_IS_WCTYPE(FN) \ + extern int FN(__WINT_TYPE__); \ + extern void link_failure_##FN(void); \ + if (FN(i) != FN(i)) \ + link_failure_##FN() + +#define TEST_TO_WCTYPE(FN) \ + extern __WINT_TYPE__ FN(__WINT_TYPE__); \ + extern void link_failure_##FN(void); \ + if (FN(i) != FN(i)) \ + link_failure_##FN() + + +#ifdef __OPTIMIZE__ + TEST_IS_WCTYPE(iswalnum); + TEST_IS_WCTYPE(iswalpha); + TEST_IS_WCTYPE(iswblank); + TEST_IS_WCTYPE(iswcntrl); + TEST_IS_WCTYPE(iswdigit); + TEST_IS_WCTYPE(iswgraph); + TEST_IS_WCTYPE(iswlower); + TEST_IS_WCTYPE(iswprint); + TEST_IS_WCTYPE(iswpunct); + TEST_IS_WCTYPE(iswspace); + TEST_IS_WCTYPE(iswupper); + TEST_IS_WCTYPE(iswxdigit); + TEST_TO_WCTYPE(towlower); + TEST_TO_WCTYPE(towupper); +#endif /* __OPTIMIZE__ */ +} + +int main (void) +{ + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtins-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtins-1.c new file mode 100644 index 000000000..c0e8210a1 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtins-1.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-rtl-expand-all" */ +/* { dg-final { cleanup-rtl-dump "expand" } } */ +int isdigit(int c) +{ + return c >= 0; +} + + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/c99-contract-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/c99-contract-1.c new file mode 100644 index 000000000..602308308 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/c99-contract-1.c @@ -0,0 +1,21 @@ +/* Test floating-point contraction occurs only within source language + expressions. */ +/* { dg-do run } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +extern void abort (void); +extern void exit (int); + +volatile float a = 1 + 0x1p-23f, b = 1 - 0x1p-23f, c = -1; + +int +main (void) +{ + float av = a, bv = b, cv = c; + float p = av * bv; + float r = p + cv; + if (r == 0) + exit (0); + else + abort (); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/calleesave-sse.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/calleesave-sse.c new file mode 100644 index 000000000..292791c72 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/calleesave-sse.c @@ -0,0 +1,43 @@ +/* { dg-do run } */ +/* { dg-options "-fno-omit-frame-pointer" } */ + +#define alloca __builtin_alloca +extern void abort (void); + +__attribute__ ((noinline)) static double +bar (double a, double b, double c, double d, char *h) +{ + *h = 0; + return a * b + b + c; +} + +__attribute__ ((noinline)) static int +boo (double a, double b, double c, double d) +{ + return c * b + a + b; +} + +__attribute__ ((noinline)) static double +foo (double a, double b, double c, double d) +{ + int aa = boo (b, c, d, a); + return bar (a, b, c, d, (char *) alloca (aa)) + + bar (d, c, b, a, (char *) alloca (aa)); +} + +int main () +{ + double a = 2.0, b = 3.0, c = 4.0, d = 5.0; + double r1, r2; + int aa; + + aa = boo (b, c, d, a); + r1 = bar (a, b, c, d, (char *) alloca (aa)) + + bar (d, c, b, a, (char *) alloca (aa)); + r2 = foo (a, b, c, d); + + if (r1 != r2) + abort (); + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/cris-asm-mof-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/cris-asm-mof-1.c new file mode 100644 index 000000000..5ebde5ed5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/cris-asm-mof-1.c @@ -0,0 +1,36 @@ +/* { dg-do compile { target cris-*-* crisv32-*-* } } */ +/* { dg-skip-if "" { cris*-*-* } { "-march*" } { "" } } */ +/* { dg-options "-O2 -march=v10" } */ +/* { dg-final { scan-assembler "in-asm: .mof" } } */ +/* { dg-final { scan-assembler "out-asm: .mof" } } */ +/* { dg-final { scan-assembler "in2-asm: .mof" } } */ +/* { dg-final { scan-assembler "out2-asm: .mof" } } */ + +unsigned int +in (unsigned int i) +{ + register int i0 asm ("mof") = i; + asm ("in-asm: %0" : : "x" (i0)); +} + +unsigned int +out (void) +{ + register int o asm ("mof"); + asm ("out-asm: %0" : "=x" (o)); + return o; +} + +unsigned int +in2 (unsigned int i) +{ + asm ("in2-asm: %0" : : "h" (i)); +} + +unsigned int +out2 (void) +{ + unsigned int o; + asm ("out2-asm: %0" : "=h" (o)); + return o; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/cris-volatile-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/cris-volatile-1.c new file mode 100644 index 000000000..6b19852c2 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/cris-volatile-1.c @@ -0,0 +1,72 @@ +/* Copyright (C) 2003 Free Software Foundation. + Check that size-optimizations for move insns (specifically peephole + optimizations) aren't applied to volatile objects in the CRIS port. + Origin: Hans-Peter Nilsson. */ +/* { dg-do compile { target cris-*-* crisv32-*-* } } */ +/* { dg-final { scan-assembler-not {movu\...\[} } } */ +/* { dg-final { scan-assembler-not {move\.[^d].\[} } } */ +/* { dg-final { scan-assembler-not {and\.[^d].\[} } } */ +/* { dg-final { scan-assembler-not {or\.[^d].\[} } } */ + +static const unsigned long c = 0x0000FF00; +unsigned long +a1 (void) +{ + unsigned long m; + m = *(volatile unsigned long*) 0xb00000c8; + m &= c; + return m; +} +extern volatile unsigned long xx; +unsigned long +a2 (void) +{ + unsigned long m; + m = xx; + m &= c; + return m; +} +extern volatile unsigned long yy[]; +unsigned long +a3 (void) +{ + unsigned long m; + m = yy[3]; + m &= 0xfe00; + return m; +} +unsigned long +ac1 (void) +{ + unsigned long m; + m = *(volatile unsigned long*) 0xb00000c8; + m &= 0xfe00; + return m; +} +extern volatile unsigned long xx; +unsigned long +ac2 (void) +{ + unsigned long m; + m = xx; + m &= 0xfe00; + return m; +} +extern volatile unsigned long yy[]; +unsigned long +ac3 (void) +{ + unsigned long m; + m = yy[3]; + m &= 0xfe00; + return m; +} +extern volatile unsigned long yy[]; +unsigned long +oc3 (void) +{ + unsigned long m; + m = yy[3]; + m |= ~0xf; + return m; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/darwin-cfstring-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/darwin-cfstring-3.c new file mode 100644 index 000000000..2d755ec8d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/darwin-cfstring-3.c @@ -0,0 +1,30 @@ +/* Test whether the __builtin__CFStringMakeConstantString + "function" generates compile-time objects with the correct layout. */ +/* Developed by Ziemowit Laski <zlaski@apple.com>. */ + +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-options "-mconstant-cfstrings" } */ + +typedef const struct __CFString *CFStringRef; + +#ifdef __CONSTANT_CFSTRINGS__ +#define CFSTR(STR) ((CFStringRef) __builtin___CFStringMakeConstantString (STR)) +#else +#error __CONSTANT_CFSTRINGS__ not defined +#endif + +extern int cond; +extern const char *func(void); + +CFStringRef s0 = CFSTR("Hello" "there"); + +void foo(void) { + const CFStringRef s1 = CFSTR("Str1"); + + s0 = s1; +} + +/* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+LC.*\n\[ \\t\]*\\.long\[ \\t\]+4\n" { target { *-*-darwin* && { ! lp64 } } } } } */ +/* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+LC.*\n\[ \\t\]*\\.long\[ \\t\]+10\n" { target { *-*-darwin* && { ! lp64 } } } } } */ +/* { dg-final { scan-assembler ".quad\t___CFConstantStringClassReference\n\t.long\t1992\n\t.space 4\n\t.quad\t.*\n\t.quad\t4\n" { target { *-*-darwin* && { lp64 } } } } } */ +/* { dg-final { scan-assembler ".quad\t___CFConstantStringClassReference\n\t.long\t1992\n\t.space 4\n\t.quad\t.*\n\t.quad\t10\n" { target { *-*-darwin* && { lp64 } } } } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/dg-torture.exp b/gcc-4.9/gcc/testsuite/gcc.dg/torture/dg-torture.exp new file mode 100644 index 000000000..cb91c791e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/dg-torture.exp @@ -0,0 +1,7 @@ +# This harness is for tests that should be run at all optimisation levels. + +load_lib gcc-dg.exp + +dg-init +gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.c $srcdir/c-c++-common/torture/*.c]] "" +dg-finish diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/float128-cmp-invalid.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/float128-cmp-invalid.c new file mode 100644 index 000000000..9d37ba25b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/float128-cmp-invalid.c @@ -0,0 +1,19 @@ +/* Test for "invalid" exceptions from __float128 comparisons. */ +/* { dg-do run { target i?86-*-* x86_64-*-* ia64-*-* } } */ +/* { dg-options "" } */ +/* { dg-require-effective-target fenv_exceptions } */ + +#include <fenv.h> +#include <stdlib.h> + +int +main (void) +{ + volatile __float128 a = __builtin_nan (""), b = 0; + volatile int r = a < b; + if (!fetestexcept (FE_INVALID)) + abort (); + if (r) + abort (); + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/float128-div-underflow.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/float128-div-underflow.c new file mode 100644 index 000000000..f721e562b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/float128-div-underflow.c @@ -0,0 +1,19 @@ +/* Test for spurious underflow from __float128 division. */ +/* { dg-do run { target i?86-*-* x86_64-*-* ia64-*-* } } */ +/* { dg-options "" } */ +/* { dg-require-effective-target fenv_exceptions } */ + +#include <fenv.h> +#include <stdlib.h> + +int +main (void) +{ + volatile __float128 a = 0x0.fffp-16382q, b = 0x0.fffp0q, c; + c = a / b; + if (fetestexcept (FE_UNDERFLOW | FE_INEXACT)) + abort (); + if (c != 0x1p-16382q) + abort (); + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/float128-extend-nan.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/float128-extend-nan.c new file mode 100644 index 000000000..60f9bbe94 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/float128-extend-nan.c @@ -0,0 +1,23 @@ +/* Test extensions to __float128 quiet signaling NaNs. */ +/* { dg-do run { target i?86-*-* x86_64-*-* ia64-*-* } } */ +/* { dg-options "-fsignaling-nans" } */ +/* { dg-require-effective-target fenv_exceptions } */ + +#include <fenv.h> +#include <float.h> +#include <stdlib.h> + +volatile long double a = __builtin_nansl (""); + +int +main (void) +{ +#if LDBL_MANT_DIG < 113 + volatile __float128 r = a; + feclearexcept (FE_INVALID); + r += 1; + if (fetestexcept (FE_INVALID)) + abort (); +#endif + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/float128-mul-underflow.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/float128-mul-underflow.c new file mode 100644 index 000000000..e3ebfffc9 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/float128-mul-underflow.c @@ -0,0 +1,21 @@ +/* Test __float128 multiplication uses after-rounding tininess + detection. */ + +/* { dg-do run { target i?86-*-* x86_64-*-* ia64-*-* } } */ +/* { dg-options "" } */ +/* { dg-require-effective-target fenv_exceptions } */ + +#include <fenv.h> +#include <stdlib.h> + +int +main (void) +{ + volatile __float128 a = 0x1.fffffffffffffffp-16382q, b = 0x1.0000000000000008p-1q, c; + c = a * b; + if (fetestexcept (FE_UNDERFLOW)) + abort (); + if (c != 0x1p-16382q) + abort (); + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/float128-truncdf-underflow.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/float128-truncdf-underflow.c new file mode 100644 index 000000000..83b05387e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/float128-truncdf-underflow.c @@ -0,0 +1,27 @@ +/* Test truncation from __float128 to double uses after-rounding + tininess detection. */ + +/* { dg-do run { target i?86-*-* x86_64-*-* ia64-*-* } } */ +/* { dg-options "" } */ +/* { dg-require-effective-target fenv_exceptions } */ + +#include <fenv.h> +#include <stdlib.h> + +int +main (void) +{ + volatile __float128 a = 0x0.fffffffffffffffp-1022q, b = 0x0.fffffffffffff8p-1022q; + volatile double r; + r = (double) a; + if (fetestexcept (FE_UNDERFLOW)) + abort (); + if (r != 0x1p-1022) + abort (); + r = (double) b; + if (!fetestexcept (FE_UNDERFLOW)) + abort (); + if (r != 0x1p-1022) + abort (); + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/float128-truncsf-underflow.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/float128-truncsf-underflow.c new file mode 100644 index 000000000..3f1a71366 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/float128-truncsf-underflow.c @@ -0,0 +1,27 @@ +/* Test truncation from __float128 to float uses after-rounding + tininess detection. */ + +/* { dg-do run { target i?86-*-* x86_64-*-* ia64-*-* } } */ +/* { dg-options "" } */ +/* { dg-require-effective-target fenv_exceptions } */ + +#include <fenv.h> +#include <stdlib.h> + +int +main (void) +{ + volatile __float128 a = 0x0.ffffffffffp-126q, b = 0x0.ffffffp-126q; + volatile float r; + r = (float) a; + if (fetestexcept (FE_UNDERFLOW)) + abort (); + if (r != 0x1p-126f) + abort (); + r = (float) b; + if (!fetestexcept (FE_UNDERFLOW)) + abort (); + if (r != 0x1p-126f) + abort (); + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-compare.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-compare.c new file mode 100644 index 000000000..0d51dfd24 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-compare.c @@ -0,0 +1,23 @@ +/* { dg-do run } */ +/* Check that find_scan_insn properly handles swapped FP comparisons. */ +static double x; +static int exit_code; + +void __attribute__ ((noinline)) +check_int (int a, int b) +{ + exit_code += (a != b); +} + +int +main (void) +{ + x = 0.0; + asm ("" : "+m" (x)); + check_int (__builtin_isgreater (x, 1.0), 0); + check_int (__builtin_isgreaterequal (x, 1.0), 0); + check_int (__builtin_isless (x, 1.0), 1); + check_int (__builtin_islessequal (x, 1.0), 1); + check_int (__builtin_islessgreater (x, 1.0), 1); + return exit_code; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-2.c new file mode 100644 index 000000000..4c00e8fa7 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-2.c @@ -0,0 +1,18 @@ +/* { dg-do run } */ +/* { dg-require-effective-target int128 } */ + +extern void abort (void); + +float __attribute__((noinline)) +f (__uint128_t x) +{ + return x + 1; +} + +int +main (void) +{ + if (f (0xffffffffu) == 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-double.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-double.c new file mode 100644 index 000000000..39ec3cde1 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-double.c @@ -0,0 +1,18 @@ +/* Test floating-point conversions. Standard types and double. */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ +/* { dg-do run } */ +/* { dg-options "" } */ + +#include <float.h> +#include "fp-int-convert.h" + +int +main (void) +{ + TEST_I_F(signed char, unsigned char, double, DBL_MANT_DIG); + TEST_I_F(signed short, unsigned short, double, DBL_MANT_DIG); + TEST_I_F(signed int, unsigned int, double, DBL_MANT_DIG); + TEST_I_F(signed long, unsigned long, double, DBL_MANT_DIG); + TEST_I_F(signed long long, unsigned long long, double, DBL_MANT_DIG); + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-float.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-float.c new file mode 100644 index 000000000..7fca1df7a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-float.c @@ -0,0 +1,18 @@ +/* Test floating-point conversions. Standard types and float. */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ +/* { dg-do run } */ +/* { dg-options "" } */ + +#include <float.h> +#include "fp-int-convert.h" + +int +main (void) +{ + TEST_I_F(signed char, unsigned char, float, FLT_MANT_DIG); + TEST_I_F(signed short, unsigned short, float, FLT_MANT_DIG); + TEST_I_F(signed int, unsigned int, float, FLT_MANT_DIG); + TEST_I_F(signed long, unsigned long, float, FLT_MANT_DIG); + TEST_I_F(signed long long, unsigned long long, float, FLT_MANT_DIG); + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128-timode-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128-timode-2.c new file mode 100644 index 000000000..9990e190c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128-timode-2.c @@ -0,0 +1,21 @@ +/* Test floating-point conversions. __float128 type with TImode: bug + 53317. */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ +/* { dg-do run { target i?86-*-* x86_64-*-* ia64-*-* } } */ +/* { dg-require-effective-target int128 } */ +/* { dg-options "" } */ + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + volatile unsigned long long a = 0x1000000000000ULL; + volatile unsigned long long b = 0xffffffffffffffffULL; + unsigned __int128 c = (((unsigned __int128) a) << 64) | b; + __float128 d = c; + if (d != 0x1.000000000000ffffffffffffffffp112q) + abort (); + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128-timode-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128-timode-3.c new file mode 100644 index 000000000..944494d9b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128-timode-3.c @@ -0,0 +1,23 @@ +/* Test for correct rounding of conversions from __int128 to + __float128. */ +/* { dg-do run { target i?86-*-* x86_64-*-* ia64-*-* } } */ +/* { dg-require-effective-target int128 } */ +/* { dg-options "-frounding-math" } */ + +#include <fenv.h> +#include <stdlib.h> + +int +main (void) +{ + volatile unsigned long long h = -1ULL; + volatile unsigned __int128 u128 = (((unsigned __int128) h) << 64) | h; + volatile __int128 s128 = u128 >> 1; + fesetround (FE_TOWARDZERO); + __float128 ru = u128, rs = s128; + if (ru != 0x1.ffffffffffffffffffffffffffffp127q) + abort (); + if (rs != 0x1.ffffffffffffffffffffffffffffp126q) + abort (); + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128-timode.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128-timode.c new file mode 100644 index 000000000..8318f8ad8 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128-timode.c @@ -0,0 +1,15 @@ +/* Test floating-point conversions. __float128 type with TImode. */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ +/* { dg-do run { target i?86-*-* x86_64-*-* ia64-*-* } } */ +/* { dg-options "" } */ + +#include "fp-int-convert.h" + +#define FLOAT128_MANT_DIG 113 + +int +main (void) +{ + TEST_I_F(TItype, UTItype, __float128, FLOAT128_MANT_DIG); + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128.c new file mode 100644 index 000000000..bc5e5adeb --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128.c @@ -0,0 +1,19 @@ +/* Test floating-point conversions. __float128 type. */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ +/* { dg-do run { target i?86-*-* x86_64-*-* ia64-*-* } } */ +/* { dg-options "" } */ + +#include "fp-int-convert.h" + +#define FLOAT128_MANT_DIG 113 + +int +main (void) +{ + TEST_I_F(signed char, unsigned char, __float128, FLOAT128_MANT_DIG); + TEST_I_F(signed short, unsigned short, __float128, FLOAT128_MANT_DIG); + TEST_I_F(signed int, unsigned int, __float128, FLOAT128_MANT_DIG); + TEST_I_F(signed long, unsigned long, __float128, FLOAT128_MANT_DIG); + TEST_I_F(signed long long, unsigned long long, __float128, FLOAT128_MANT_DIG); + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-float80-timode.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-float80-timode.c new file mode 100644 index 000000000..7600994b4 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-float80-timode.c @@ -0,0 +1,16 @@ +/* Test floating-point conversions. __float80 type with TImode. */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ +/* { dg-do run { target i?86-*-* x86_64-*-* ia64-*-* } } */ +/* { dg-options "" } */ +/* { dg-options "-mmmx" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +#include "fp-int-convert.h" + +#define FLOAT80_MANT_DIG 64 + +int +main (void) +{ + TEST_I_F(TItype, UTItype, __float80, FLOAT80_MANT_DIG); + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-float80.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-float80.c new file mode 100644 index 000000000..3e25f904d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-float80.c @@ -0,0 +1,19 @@ +/* Test floating-point conversions. __float80 type. */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ +/* { dg-do run { target i?86-*-* x86_64-*-* ia64-*-* } } */ +/* { dg-options "" } */ + +#include "fp-int-convert.h" + +#define FLOAT80_MANT_DIG 64 + +int +main (void) +{ + TEST_I_F(signed char, unsigned char, __float80, FLOAT80_MANT_DIG); + TEST_I_F(signed short, unsigned short, __float80, FLOAT80_MANT_DIG); + TEST_I_F(signed int, unsigned int, __float80, FLOAT80_MANT_DIG); + TEST_I_F(signed long, unsigned long, __float80, FLOAT80_MANT_DIG); + TEST_I_F(signed long long, unsigned long long, __float80, FLOAT80_MANT_DIG); + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-long-double.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-long-double.c new file mode 100644 index 000000000..bb189a34c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-long-double.c @@ -0,0 +1,18 @@ +/* Test floating-point conversions. Standard types and long double. */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ +/* { dg-do run } */ +/* { dg-options "" } */ + +#include <float.h> +#include "fp-int-convert.h" + +int +main (void) +{ + TEST_I_F(signed char, unsigned char, long double, LDBL_MANT_DIG); + TEST_I_F(signed short, unsigned short, long double, LDBL_MANT_DIG); + TEST_I_F(signed int, unsigned int, long double, LDBL_MANT_DIG); + TEST_I_F(signed long, unsigned long, long double, LDBL_MANT_DIG); + TEST_I_F(signed long long, unsigned long long, long double, LDBL_MANT_DIG); + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode.c new file mode 100644 index 000000000..3a60d01ff --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode.c @@ -0,0 +1,21 @@ +/* Test floating-point conversions. TImode types. */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ +/* { dg-do run } */ +/* { dg-options "" } */ + +#include <float.h> +#include "fp-int-convert.h" + +int +main (void) +{ + TEST_I_F(TItype, UTItype, float, FLT_MANT_DIG); + TEST_I_F(TItype, UTItype, double, DBL_MANT_DIG); + /* Disable the long double tests when using IBM Extended Doubles. + They have variable precision, but constants calculated by gcc's + real.c assume fixed precision. */ +#if DBL_MANT_DIG != LDBL_MANT_DIG && LDBL_MANT_DIG != 106 + TEST_I_F(TItype, UTItype, long double, LDBL_MANT_DIG); +#endif + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert.h b/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert.h new file mode 100644 index 000000000..8ac9c3de1 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/fp-int-convert.h @@ -0,0 +1,89 @@ +/* Test floating-point conversions. */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ + +#include <limits.h> +extern void abort (void); +extern void exit (int); + +/* Not all platforms support TImode integers; logic as in + gcc.dg/titype-1.c. */ +#if (defined(__LP64__) && !defined(__hppa__)) || defined(_WIN64) || defined(__SPU__) +typedef int TItype __attribute__ ((mode (TI))); +typedef unsigned int UTItype __attribute__ ((mode (TI))); +#else +typedef long TItype; +typedef unsigned long UTItype; +#endif + +/* TEST_I_F(I, U, F, P) tests conversions between the pair of signed + and unsigned integer types I and U and the floating-point type F, + where P is the binary precision of the floating point type. We + test conversions of the values 0, 1, 0x7...f, 0x8...0, 0xf...f. We + also test conversions of values half way between two + representable values (rounding both ways), just above half way, and + just below half way. */ +#define TEST_I_F(I, U, F, P) \ +do { \ + TEST_I_F_VAL (I, F, (I)0, 1); \ + TEST_I_F_VAL (I, F, (I)1, 1); \ + TEST_I_F_VAL (I, F, (I)(((U)~(U)0) >> 1), P_OK1 (P, I)); \ + TEST_I_F_VAL (I, F, (I)(U)~(((U)~(U)0) >> 1), 1); \ + TEST_I_F_VAL (I, F, (I)(U)~(U)0, P_OK (P, I)); \ + TEST_I_F_VAL (I, F, HVAL0S (P, I), P_OK (P, I)); \ + TEST_I_F_VAL (I, F, HVAL0S (P, I) + 1, P_OK (P, I)); \ + TEST_I_F_VAL (I, F, HVAL0S (P, I) - 1, P_OK (P, I)); \ + TEST_I_F_VAL (I, F, HVAL1S (P, I), P_OK (P, I)); \ + TEST_I_F_VAL (I, F, HVAL1S (P, I) + 1, P_OK (P, I)); \ + TEST_I_F_VAL (I, F, HVAL1S (P, I) - 1, P_OK (P, I)); \ + TEST_I_F_VAL (I, F, -HVAL0S (P, I), P_OK (P, I)); \ + TEST_I_F_VAL (I, F, -HVAL0S (P, I) + 1, P_OK (P, I)); \ + TEST_I_F_VAL (I, F, -HVAL0S (P, I) - 1, P_OK (P, I)); \ + TEST_I_F_VAL (I, F, -HVAL1S (P, I), P_OK (P, I)); \ + TEST_I_F_VAL (I, F, -HVAL1S (P, I) + 1, P_OK (P, I)); \ + TEST_I_F_VAL (I, F, -HVAL1S (P, I) - 1, P_OK (P, I)); \ + TEST_I_F_VAL (U, F, (U)0, 1); \ + TEST_I_F_VAL (U, F, (U)1, 1); \ + TEST_I_F_VAL (U, F, (U)(((U)~(U)0) >> 1), P_OK1 (P, U)); \ + TEST_I_F_VAL (U, F, (U)~(((U)~(U)0) >> 1), 1); \ + TEST_I_F_VAL (U, F, (U)~(U)0, P_OK (P, U)); \ + TEST_I_F_VAL (U, F, HVAL0U (P, U), P_OK (P, U)); \ + TEST_I_F_VAL (U, F, HVAL0U (P, U) + 1, P_OK (P, U)); \ + TEST_I_F_VAL (U, F, HVAL0U (P, U) - 1, P_OK (P, U)); \ + TEST_I_F_VAL (U, F, HVAL1U (P, U), P_OK (P, U)); \ + TEST_I_F_VAL (U, F, HVAL1U (P, U) + 1, P_OK (P, U)); \ + TEST_I_F_VAL (U, F, HVAL1U (P, U) - 1, P_OK (P, U)); \ +} while (0) + +#define P_OK(P, T) ((P) >= sizeof(T) * CHAR_BIT) +#define P_OK1(P, T) ((P) >= sizeof(T) * CHAR_BIT - 1) +#define HVAL0U(P, U) (U)(P_OK (P, U) \ + ? (U)1 \ + : (((U)1 << (sizeof(U) * CHAR_BIT - 1)) \ + + ((U)1 << (sizeof(U) * CHAR_BIT - 1 - P)))) +#define HVAL1U(P, U) (U)(P_OK (P, U) \ + ? (U)1 \ + : (((U)1 << (sizeof(U) * CHAR_BIT - 1)) \ + + ((U)3 << (sizeof(U) * CHAR_BIT - 1 - P)))) +#define HVAL0S(P, S) (S)(P_OK1 (P, S) \ + ? (S)1 \ + : (((S)1 << (sizeof(S) * CHAR_BIT - 2)) \ + + ((S)1 << (sizeof(S) * CHAR_BIT - 2 - P)))) +#define HVAL1S(P, S) (S)(P_OK1 (P, S) \ + ? (S)1 \ + : (((S)1 << (sizeof(S) * CHAR_BIT - 2)) \ + + ((S)3 << (sizeof(S) * CHAR_BIT - 2 - P)))) + +#define TEST_I_F_VAL(IT, FT, VAL, PREC_OK) \ +do { \ + static volatile IT ivin, ivout; \ + static volatile FT fv1, fv2; \ + ivin = (VAL); \ + fv1 = (VAL); \ + fv2 = ivin; \ + ivout = fv2; \ + if (ivin != (VAL) \ + || ((PREC_OK) && ivout != ivin) \ + || ((PREC_OK) && ivout != (VAL)) \ + || fv1 != (VAL) || fv2 != (VAL) || fv1 != fv2) \ + abort (); \ +} while (0) diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/inline-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/inline-1.c new file mode 100644 index 000000000..c7144ca68 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/inline-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "--param ggc-min-heapsize=0 --param ggc-min-expand=0" } */ +/* This used to ICE because we forgot to update the statement after folding + and the eh info. */ +/* PR tree-opt/30385 */ + +static inline void g(int t) +{ + int a; + while (a < f()) + ; +} +void h(int t) +{ + g(t); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/inline-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/inline-2.c new file mode 100644 index 000000000..0d341bfad --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/inline-2.c @@ -0,0 +1,35 @@ +/* { dg-do link } */ + +extern inline void foo2 (void) __attribute__((always_inline,gnu_inline)); +extern inline void foo1 (void) __attribute__((always_inline,gnu_inline)); +void bar1 (void); +void bar2 (void); + +extern inline void __attribute__((always_inline,gnu_inline)) +foo2 (void) +{ + bar2 (); +} + +void +bar1 (void) +{ + foo2 (); +} + +void +bar2 (void) +{ + foo1 (); +} + +extern inline void __attribute__((always_inline,gnu_inline)) +foo1 (void) +{ + bar1 (); +} + +int main() +{ + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/ipa-pta-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/ipa-pta-1.c new file mode 100644 index 000000000..aae987de3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/ipa-pta-1.c @@ -0,0 +1,46 @@ +/* { dg-do compile { target { nonpic } } } */ +/* { dg-options "-fipa-pta -fdump-ipa-pta" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-fno-fat-lto-objects" } { "" } } */ + +struct X { char x; char y; }; + +char *q; + +static void __attribute__((noinline)) +bar (char *p) +{ + q = p; +} + +void test1 (char a1, char b, char c, char d, char e, char f, char g, char h) +{ + char *p = &a1; + p++; + bar (p); +} + +void test2 (struct X a2, char b, char c, char d, char e, char f, char g, char h) +{ + char *p = &a2.x; + p++; + bar (p); +} + +void test3 (struct X a3, char b, char c, char d, char e, char f, char g, char h) +{ + char *p = &a3.y; + bar (p); +} + +void test4 (int a4, char b, char c, char d, char e, char f, char g, char h) +{ + char *p = (char *)&a4; + p++; + p++; + p++; + p++; + bar (p); +} + +/* { dg-final { scan-ipa-dump "bar.arg0 = { test4.arg0 test3.arg0 test2.arg0 test1.arg0 }" "pta" } } */ +/* { dg-final { cleanup-ipa-dump "pta" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/ipa-pta-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/ipa-pta-2.c new file mode 100644 index 000000000..768c99e82 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/ipa-pta-2.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-fipa-pta" } */ + +int **x; + +static int __attribute__((noinline,noclone)) +foo (int **p) +{ + int a = 1; + **p = 0; + *x = &a; + return **p; +} + +extern void abort (void); +int main() +{ + int b; + int *p = &b; + x = &p; + if (foo (&p) != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/ldist-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/ldist-1.c new file mode 100644 index 000000000..b6a0f28ba --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/ldist-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-ftree-loop-distribute-patterns" } */ + +void foo (volatile int *p, int n) +{ + int i; + for (i = 0; i < n; ++i) + p[i] = 0; +} + +/* { dg-final { scan-assembler-not "memset" } } */ +/* { dg-final { cleanup-tree-dump "ldist" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/matrix-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/matrix-1.c new file mode 100644 index 000000000..1b88599bd --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/matrix-1.c @@ -0,0 +1,90 @@ +/* { dg-do run } */ +/* { dg-options "-fwhole-program" } */ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <string.h> + +void mem_init (void); +int ARCHnodes, ARCHnodes1; +int ***vel; + +/* The whole matrix VEL is flattened (3 dimensions). */ +/*--------------------------------------------------------------------------*/ + +int +main (int argc, char **argv) +{ + int i, j, k, id; + + ARCHnodes = 2; + ARCHnodes1 = 4; + +/* Dynamic memory allocations and initializations */ + mem_init (); + + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + for (k = 0; k < ARCHnodes1; k++) + printf ("[%d][%d][%d]=%d ", i, j, k, vel[i][j][k]); + printf ("\n"); + } + printf ("\n"); + } + for (i = 0; i < ARCHnodes; i++) + for (j = 0; j < 3; j++) + free (vel[i][j]); + + for (i = 0; i < ARCHnodes; i++) + free (vel[i]); + + free (vel); + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* Dynamic memory allocations and initializations */ + +void +mem_init (void) +{ + + int i, j, k,d; + + d = 0; + vel = (int ***) malloc (ARCHnodes * sizeof (int **)); + + for (i = 0; i < ARCHnodes; i++) + { + vel[i] = (int **) malloc (3 * sizeof (int *)); + if (vel[i] == (int **) NULL) + { + fprintf (stderr, "malloc failed for vel[%d]\n", i); + fflush (stderr); + exit (0); + } + } + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int)); + } + } + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + for (k = 0; k < ARCHnodes1; k++) + { + vel[i][j][k] = d; + d++; + } + } + } +} + +/*--------------------------------------------------------------------------*/ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/matrix-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/matrix-2.c new file mode 100644 index 000000000..5013671af --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/matrix-2.c @@ -0,0 +1,113 @@ +/* { dg-do run } */ +/* { dg-options "-fwhole-program" } */ + + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <string.h> + +void mem_init (void); +int ARCHnodes, ARCHnodes1; +int ***vel; + +/* The last dimension of VEL escapes because of + the assignment : vel[1][1] =... + Only the two external dimensions are flattened. */ + + +/*--------------------------------------------------------------------------*/ + +int +main (int argc, char **argv) +{ + int i, j, k; + + ARCHnodes = 2; + ARCHnodes1 = 4; + +/* Dynamic memory allocations and initializations */ + + mem_init (); + + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + for (k = 0; k < ARCHnodes1; k++) + printf ("[%d][%d][%d]=%d ", i, j, k, vel[i][j][k]); + printf ("\n"); + } + printf ("\n"); + } + for (i = 0; i < ARCHnodes; i++) + for (j = 0; j < 3; j++) + printf ("%x\n",vel[i][j]); + /*if (i!=1 || j!=1)*/ + /*if (i==1 && j==1) + continue; + else + free (vel[i][j]);*/ + + for (i = 0; i < ARCHnodes; i++) + free (vel[i]); + + free (vel); + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* Dynamic memory allocations and initializations */ + +void +mem_init (void) +{ + + int i, j, k,d; + + d = 0; + vel = (int ***) malloc (ARCHnodes * sizeof (int **)); + + for (i = 0; i < ARCHnodes; i++) + { + vel[i] = (int **) malloc (3 * sizeof (int *)); + if (vel[i] == (int **) NULL) + { + fprintf (stderr, "malloc failed for vel[%d]\n", i); + fflush (stderr); + exit (0); + } + } + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int)); + printf ("%x %d %d\n",vel[i][j], ARCHnodes1, sizeof (int)); + } + } + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + printf ("%x\n",vel[i][j]); + } + } + + printf ("again:\n\n"); + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + printf ("%x\n",vel[i][j]); + /*for (k = 0; k < ARCHnodes1; k++) + { + vel[i][j][k] = d; + d++; + }*/ + } + } + /*vel[1][1] = vel[0][1];*/ +} + +/*--------------------------------------------------------------------------*/ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/matrix-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/matrix-3.c new file mode 100644 index 000000000..c646899a3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/matrix-3.c @@ -0,0 +1,97 @@ +/* { dg-do compile } */ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <string.h> + +void mem_init (void); +int ARCHnodes, ARCHnodes1; +int ***vel; +void just_a_call (int *); + +/* The last dimension of VEL escapes because it was sent + as argumet to just_a_call(). (external function) + Only the two external dimensions are flattened. + Run with -c. */ + + +/*--------------------------------------------------------------------------*/ + +int +main (int argc, char **argv) +{ + int i, j, k; + + ARCHnodes = 2; + ARCHnodes1 = 4; + +/* Dynamic memory allocations and initializations */ + + mem_init (); + + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + for (k = 0; k < ARCHnodes1; k++) + printf ("[%d][%d][%d]=%d ", i, j, k, vel[i][j][k]); + printf ("\n"); + } + printf ("\n"); + } + for (i = 0; i < ARCHnodes; i++) + for (j = 0; j < 3; j++) + free (vel[i][j]); + + for (i = 0; i < ARCHnodes; i++) + free (vel[i]); + + free (vel); + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* Dynamic memory allocations and initializations */ + +void +mem_init (void) +{ + + int i, j, k,d; + + d = 0; + vel = (int ***) malloc (ARCHnodes * sizeof (int **)); + + for (i = 0; i < ARCHnodes; i++) + { + vel[i] = (int **) malloc (3 * sizeof (int *)); + if (vel[i] == (int **) NULL) + { + fprintf (stderr, "malloc failed for vel[%d]\n", i); + fflush (stderr); + exit (0); + } + } + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int)); + } + } + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + for (k = 0; k < ARCHnodes1; k++) + { + vel[i][j][k] = d; + d++; + } + } + } + just_a_call (vel[1][1]); +} + +/*--------------------------------------------------------------------------*/ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/matrix-4.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/matrix-4.c new file mode 100644 index 000000000..586443ce2 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/matrix-4.c @@ -0,0 +1,95 @@ +/* { dg-do compile } */ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <string.h> + +void mem_init (void); +int ARCHnodes, ARCHnodes1; +int ***vel; +void just_a_call (int ****); + +/* Address of VEL is taken. + It is not flattened. */ + + +/*--------------------------------------------------------------------------*/ + +int +main (int argc, char **argv) +{ + int i, j, k; + + ARCHnodes = 2; + ARCHnodes1 = 4; + +/* Dynamic memory allocations and initializations */ + + mem_init (); + + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + for (k = 0; k < ARCHnodes1; k++) + printf ("[%d][%d][%d]=%d ", i, j, k, vel[i][j][k]); + printf ("\n"); + } + printf ("\n"); + } + for (i = 0; i < ARCHnodes; i++) + for (j = 0; j < 3; j++) + free (vel[i][j]); + + for (i = 0; i < ARCHnodes; i++) + free (vel[i]); + + free (vel); + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* Dynamic memory allocations and initializations */ + +void +mem_init (void) +{ + + int i, j, k,d; + + d = 0; + vel = (int ***) malloc (ARCHnodes * sizeof (int **)); + + for (i = 0; i < ARCHnodes; i++) + { + vel[i] = (int **) malloc (3 * sizeof (int *)); + if (vel[i] == (int **) NULL) + { + fprintf (stderr, "malloc failed for vel[%d]\n", i); + fflush (stderr); + exit (0); + } + } + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int)); + } + } + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + for (k = 0; k < ARCHnodes1; k++) + { + vel[i][j][k] = d; + d++; + } + } + } + just_a_call (&vel); +} + +/*--------------------------------------------------------------------------*/ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/matrix-5.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/matrix-5.c new file mode 100644 index 000000000..9b17567f4 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/matrix-5.c @@ -0,0 +1,96 @@ +/* { dg-do run } */ +/* { dg-options "-fwhole-program" } */ + + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <string.h> + +void mem_init (void); +int ARCHnodes, ARCHnodes1; +int ***vel; + +/* The two inner dimesions of matrix escape because of the + assignment vel[1]= ... + VEL is not Flattened. */ + +/*--------------------------------------------------------------------------*/ + +int +main (int argc, char **argv) +{ + int i, j, k; + + ARCHnodes = 2; + ARCHnodes1 = 4; + +/* Dynamic memory allocations and initializations */ + + mem_init (); + + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + for (k = 0; k < ARCHnodes1; k++) + printf ("[%d][%d][%d]=%d ", i, j, k, vel[i][j][k]); + printf ("\n"); + } + printf ("\n"); + } + for (i = 0; i < ARCHnodes-1; i++) + for (j = 0; j < 3; j++) + free (vel[i][j]); + + for (i = 0; i < ARCHnodes-1; i++) + free (vel[i]); + + free (vel); + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* Dynamic memory allocations and initializations */ + +void +mem_init (void) +{ + + int i, j, k,d; + + d = 0; + vel = (int ***) malloc (ARCHnodes * sizeof (int **)); + + for (i = 0; i < ARCHnodes; i++) + { + vel[i] = (int **) malloc (3 * sizeof (int *)); + if (vel[i] == (int **) NULL) + { + fprintf (stderr, "malloc failed for vel[%d]\n", i); + fflush (stderr); + exit (0); + } + } + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int)); + } + } + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + for (k = 0; k < ARCHnodes1; k++) + { + vel[i][j][k] = d; + d++; + } + } + } + vel[1] = vel[0]; +} + +/*--------------------------------------------------------------------------*/ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/matrix-6.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/matrix-6.c new file mode 100644 index 000000000..cad63ddab --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/matrix-6.c @@ -0,0 +1,97 @@ +/* { dg-do run } */ +/* { dg-options "-fwhole-program" } */ + + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <string.h> + +void mem_init (void); +int ARCHnodes, ARCHnodes1; +int ***vel; + +/* The last dimension of VEL escapes because of + the assignment : *vel[1] =... + Only the two external dimensions are flattened. */ + +/*--------------------------------------------------------------------------*/ + +int +main (int argc, char **argv) +{ + int i, j, k; + + ARCHnodes = 2; + ARCHnodes1 = 4; + +/* Dynamic memory allocations and initializations */ + + mem_init (); + + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + for (k = 0; k < ARCHnodes1; k++) + printf ("[%d][%d][%d]=%d ", i, j, k, vel[i][j][k]); + printf ("\n"); + } + printf ("\n"); + } + for (i = 0; i < ARCHnodes; i++) + for (j = 0; j < 3; j++) + if (!(i == 1 && j == 0)) + free (vel[i][j]); + + for (i = 0; i < ARCHnodes; i++) + free (vel[i]); + + free (vel); + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* Dynamic memory allocations and initializations */ + +void +mem_init (void) +{ + + int i, j, k,d; + + d = 0; + vel = (int ***) malloc (ARCHnodes * sizeof (int **)); + + for (i = 0; i < ARCHnodes; i++) + { + vel[i] = (int **) malloc (3 * sizeof (int *)); + if (vel[i] == (int **) NULL) + { + fprintf (stderr, "malloc failed for vel[%d]\n", i); + fflush (stderr); + exit (0); + } + } + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int)); + } + } + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + for (k = 0; k < ARCHnodes1; k++) + { + vel[i][j][k] = d; + d++; + } + } + } + *vel[1] = &d; +} + +/*--------------------------------------------------------------------------*/ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/memcpy-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/memcpy-1.c new file mode 100644 index 000000000..290c78923 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/memcpy-1.c @@ -0,0 +1,22 @@ +/* { dg-do run } */ +/* { dg-additional-options "-mtune=pentiumpro" { target ia32 } } */ +/* { dg-additional-options "-minline-all-stringops" { target { i?86-*-* x86_64-*-* } } } */ + +static void __attribute__((noinline, noclone)) +my_memcpy (char *dest, const char *src, int n) +{ + __builtin_memcpy (dest, src, n); +} + +int +main (void) +{ + char a1[4], a2[4]; + __builtin_memset (a1, 'a', 4); + __builtin_memset (a2, 'b', 4); + my_memcpy (a2, a1, 4); + if (a2[0] != 'a') + __builtin_abort (); + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/mips-clobber-at.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/mips-clobber-at.c new file mode 100644 index 000000000..7f936984a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/mips-clobber-at.c @@ -0,0 +1,4 @@ +/* "$1" used to be mapped to the internal frame pointer. */ +/* { dg-do compile { target mips*-*-* } } */ +/* { dg-options "" } */ +int foo () { asm volatile ("#" ::: "$1"); } diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/mips-div-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/mips-div-1.c new file mode 100644 index 000000000..6345000fe --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/mips-div-1.c @@ -0,0 +1,9 @@ +/* Check that hard-float MIPS code doesn't use library calls for 1.0/x. */ +/* { dg-options "-fno-delayed-branch" } */ +/* { dg-do compile { target mips*-*-* } } */ + +float f1 (float x) { return 1.0f / x; } +double f2 (double x) { return 1.0 / x; } + +/* { dg-final { scan-assembler-not {lwc1.*__divsf3} } } */ +/* { dg-final { scan-assembler-not {ldc1.*__divdf3} } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/mips-hilo-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/mips-hilo-2.c new file mode 100644 index 000000000..dbe949307 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/mips-hilo-2.c @@ -0,0 +1,27 @@ +/* Due to a reload inheritance bug, the asm statement in f() would be passed + the low part of u.ll on little-endian 32-bit targets. */ +/* { dg-do run { target mips*-*-* } } */ + +extern void abort (void); +extern void exit (int); + +unsigned int g; + +unsigned __attribute__ ((nomips16)) long long f (unsigned int x) +{ + union { unsigned long long ll; unsigned int parts[2]; } u; + + u.ll = ((unsigned long long) x * x); + asm ("mflo\t%0" : "=r" (g) : "l" (u.parts[1])); + return u.ll; +} + +int __attribute__ ((nomips16)) main () +{ + union { unsigned long long ll; unsigned int parts[2]; } u; + + u.ll = f (0x12345678); + if (g != u.parts[1]) + abort (); + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/mips-sdata-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/mips-sdata-1.c new file mode 100644 index 000000000..8ffd4d848 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/mips-sdata-1.c @@ -0,0 +1,10 @@ +/* Check that sdata-accesses are applied regardless of size or ABI. */ +/* { dg-options -mexplicit-relocs } */ +/* { dg-do compile { target mips*-*-elf* } } */ + +struct s { int x[4]; }; +struct s my_struct __attribute__((__section__(".sdata"))); + +int f() { return my_struct.x[0]; } + +/* { dg-final { scan-assembler {gp_?rel\(my_struct} } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/nested-fn-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/nested-fn-1.c new file mode 100644 index 000000000..99e852344 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/nested-fn-1.c @@ -0,0 +1,74 @@ +/* PR middle-end/15345, c/16450 */ +/* Test whether unused nested functions aren't emitted into the assembly. */ +/* { dg-do compile } */ +/* { dg-options "-g0" } */ +/* { dg-require-effective-target trampolines } */ + +int +fn1 (int x) +{ + int i = x; + inline __attribute__((always_inline)) int + should_not_appear1 (void) + { + return i; + } + return should_not_appear1 (); +} + +int +fn2 (int x) +{ + int i = x; + inline __attribute__((always_inline)) int + should_not_appear2 (void) + { + return i; + } + return x; +} + +extern void check (void *p); + +int +fn3 (int x) +{ + int i = x; + inline int + should_appear1 (void) + { + char *p = __builtin_alloca (i); + check (p); + return i; + } + return should_appear1 (); +} + +int +fn4 (int x) +{ + int i = x; + inline int + should_not_appear3 (void) + { + char *p = __builtin_alloca (i); + check (p); + return i; + } + return 0 ? should_not_appear3 () : 1; +} + +int +fn5 (int x) +{ + int i = x; + inline int + should_appear2 (void) + { + return i; + } + check (should_appear2); + return i; +} + +/* { dg-final { scan-assembler-not "should_not_appear" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr16104-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr16104-1.c new file mode 100644 index 000000000..ad5eda65f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr16104-1.c @@ -0,0 +1,79 @@ +/* PR rtl-optimization/16104 */ +/* { dg-do run { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-msse2" } */ +/* { dg-require-effective-target sse2_runtime } */ + +extern void abort (void); + +typedef int V2SI __attribute__ ((vector_size (8))); +typedef unsigned int V2USI __attribute__ ((vector_size (8))); +typedef short V2HI __attribute__ ((vector_size (4))); +typedef unsigned int V2UHI __attribute__ ((vector_size (4))); + +int +test1 (void) +{ + return (long long) (V2SI) 0LL; +} + +int +test2 (V2SI x) +{ + return (long long) x; +} + +V2SI +test3 (void) +{ + return (V2SI) (long long) (int) (V2HI) 0; +} + +V2SI +test4 (V2HI x) +{ + return (V2SI) (long long) (int) x; +} + +V2SI +test5 (V2USI x) +{ + return (V2SI) x; +} + +void +__attribute__ ((noinline)) +do_test (void) +{ + if (sizeof (short) != 2 || sizeof (int) != 4 || sizeof (long long) != 8) + return; + + if (test1 () != 0) + abort (); + + V2SI x = { 2, 2 }; + if (test2 (x) != 2) + abort (); + + union { V2SI x; int y[2]; V2USI z; long long l; } u; + u.x = test3 (); + if (u.y[0] != 0 || u.y[1] != 0) + abort (); + + V2HI y = { 4, 4 }; + union { V2SI x; long long y; } v; + v.x = test4 (y); + if (v.y != 0x40004) + abort (); + + V2USI z = { 6, 6 }; + u.x = test5 (z); + if (u.y[0] != 6 || u.y[1] != 6) + abort (); +} + +int +main (void) +{ + do_test (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr17526.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr17526.c new file mode 100644 index 000000000..58b479143 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr17526.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-options "-fno-pcc-struct-return" { target i?86-*-* } } */ + +void abort(void); + +typedef struct { int i; } A; + +A __attribute__((noinline)) +foo(void) +{ + A a = { -1 }; + return a; +} + +void __attribute__((noinline)) +bar(A *p) +{ + *p = foo(); +} + +int main(void) +{ + A a; + bar(&a); + if (a.i != -1) abort(); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr17933-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr17933-1.c new file mode 100644 index 000000000..02c597b0a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr17933-1.c @@ -0,0 +1,14 @@ +/* PR rtl-optimization/17933. + Test-case from the ObjC test-suite, execute/class_self-2.m, + translated to C from and reduced by Andrew Pinski. */ + +struct d +{ int a; }; +void abort(void); +typedef struct d (*f) (int i); +f ff(void); +void test1() +{ + f t = ff(); + t(0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr18582-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr18582-1.c new file mode 100644 index 000000000..619593905 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr18582-1.c @@ -0,0 +1,24 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-msse3" } */ +typedef char v16qi __attribute__((vector_size (16))); +typedef float v4sf __attribute__((vector_size (16))); +typedef double v2df __attribute__((vector_size (16))); + +extern char ca[]; +extern float fa[]; +extern double da[]; + +extern v16qi cva[]; +extern v4sf fva[]; +extern v2df dva[]; + +void +foo (void) +{ + cva[0] = __builtin_ia32_loaddqu (ca); + cva[0] = __builtin_ia32_lddqu (ca); + + fva[0] = __builtin_ia32_loadups (fa); + + dva[0] = __builtin_ia32_loadupd (da); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr19462-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr19462-1.c new file mode 100644 index 000000000..8e140356f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr19462-1.c @@ -0,0 +1,56 @@ +/* { dg-do compile } */ +/* PR rtl-optimization/19462 + Delayed branch bug: return insns generated in presence of + current_function_epilogue_delay_list. See also PR target/7042. */ + +/* The test is from newlib/libc/string/wcscspn.c, which has the following + copyright and licensing notice, which by inclusion this file supposedly + complies with: + + * Copyright (c)1999 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ + + +unsigned long +wcscspn(const long *s, const long *set) +{ + const long *p; + const long *q; + + p = s; + while (*p) + { + q = set; + while (*q) + { + if (*p == *q) + goto done; + q++; + } + p++; + } + +done: + return (p - s); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr19683-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr19683-1.c new file mode 100644 index 000000000..05bf17418 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr19683-1.c @@ -0,0 +1,42 @@ +/* From PR rtl-optimization/19683. On little-endian MIPS targets, + reload would incorrectly inherit the high part of the multiplication + result. */ +/* { dg-do run { target mips*-*-* } } */ + +extern void abort (void); +extern void exit (int); + +#define REPEAT10(X, Y) \ + X(Y##0); X(Y##1); X(Y##2); X(Y##3); X(Y##4); \ + X(Y##5); X(Y##6); X(Y##7); X(Y##8); X(Y##9) + +#define REPEAT30(X) REPEAT10 (X, 0); REPEAT10 (X, 1); REPEAT10 (X, 2) +#define IN(X) unsigned int x##X = ptr[0] +#define OUT(X) ptr[0] = x##X + +union u { unsigned long long ll; unsigned int i[2]; }; + +unsigned int __attribute__ ((nomips16)) +foo (volatile unsigned int *ptr) +{ + union u u; + int result; + + u.ll = (unsigned long long) ptr[0] * ptr[0]; + REPEAT30 (IN); + REPEAT30 (OUT); + asm ("#" : "=l" (result) : "l" (u.i[1])); + return result; +} + +int __attribute__ ((nomips16)) +main (void) +{ + unsigned int array[] = { 1000 * 1000 * 1000 }; + union u u; + + u.ll = (unsigned long long) array[0] * array[0]; + if (foo (array) != u.i[1]) + abort (); + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr20314-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr20314-1.c new file mode 100644 index 000000000..8a69c2dca --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr20314-1.c @@ -0,0 +1,56 @@ +/* PR inline-asm/20314 */ +/* { dg-do compile { target i?86-*-* x86_64-*-* powerpc*-*-* ia64-*-* } } */ + +int +f1 (void) +{ + int x = 4, y; + __asm__ volatile ("" : "+r,r" (x), "=r,r" (y) + : "%r,r" (x), "m,r" (8), "r,r" (2)); + return x; +} + +int +f2 (void) +{ + int x = 4, y; + __asm__ volatile ("" : "=r,r" (x), "=r,r" (y) + : "%0,0" (x), "m,r" (8), "r,r" (2)); + return x; +} + +int +f3 (void) +{ + int x = 4, y; + __asm__ volatile ("" : "+r,r" (x), "=r,r" (y) + : "%m,r" (8), "r,r" (2)); + return x; +} + +int +f4 (void) +{ + int x = 4, y; + __asm__ volatile ("" : "+r" (x), "=r" (y) + : "r" (x), "r" (8), "r" (2)); + return x; +} + +int +f5 (void) +{ + int x = 4, y; + __asm__ volatile ("" : "=r" (x), "=r" (y) + : "0" (x), "r" (8), "r" (2)); + return x; +} + +int +f6 (void) +{ + int x = 4, y; + __asm__ volatile ("" : "+r" (x), "=r" (y) + : "r" (8), "r" (2)); + return x; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr20314-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr20314-2.c new file mode 100644 index 000000000..aac02ddfa --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr20314-2.c @@ -0,0 +1,47 @@ +/* PR inline-asm/20314 */ +/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } } */ +/* { dg-do compile { target ia64-*-* powerpc*-*-* } } */ + +int a, b, c, d, e, f, g, h, i, j, k, l; + +void +f1 (void) +{ + __asm__ volatile ("" + : [a] "+r" (a), [b] "+r" (b), [c] "+r" (c), [d] "+r" (d), + [e] "+r" (e), [f] "+r" (f), [g] "+r" (g), [h] "+r" (h), + [i] "+r" (i), [j] "+r" (j), [k] "+r" (k), [l] "+r" (l)); +} + +void +f2 (void) +{ + __asm__ volatile ("" + : [a] "+r,m" (a), [b] "+r,m" (b), [c] "+r,m" (c), [d] "+r,m" (d), + [e] "+r,m" (e), [f] "+r,m" (f), [g] "+r,m" (g), [h] "+r,m" (h), + [i] "+r,m" (i), [j] "+r,m" (j), [k] "+r,m" (k), [l] "+r,m" (l)); +} + +void +f3 (void) +{ + __asm__ volatile ("" + : [a] "=r" (a), [b] "=r" (b), [c] "=r" (c), [d] "=r" (d), + [e] "=r" (e), [f] "=r" (f), [g] "=r" (g), [h] "=r" (h), + [i] "=r" (i), [j] "=r" (j), [k] "=r" (k), [l] "=r" (l) + : "[a]" (a), "[b]" (b), "[c]" (c), "[d]" (d), + "[e]" (e), "[f]" (f), "[g]" (g), "[h]" (h), + "[i]" (i), "[j]" (j), "[k]" (k), "[l]" (l)); +} + +void +f4 (void) +{ + __asm__ volatile ("" + : [a] "=r,m" (a), [b] "=r,m" (b), [c] "=r,m" (c), [d] "=r,m" (d), + [e] "=r,m" (e), [f] "=r,m" (f), [g] "=r,m" (g), [h] "=r,m" (h), + [i] "=r,m" (i), [j] "=r,m" (j), [k] "=r,m" (k), [l] "=r,m" (l) + : "[a],m" (a), "[b],m" (b), "[c],m" (c), "[d],m" (d), + "[e],m" (e), "[f],m" (f), "[g],m" (g), "[h],m" (h), + "[i],m" (i), "[j],m" (j), "[k],m" (k), "[l],m" (l)); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr21817-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr21817-1.c new file mode 100644 index 000000000..d90d3239c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr21817-1.c @@ -0,0 +1,16 @@ +/* hppa*-*-hpux* needs -fno-common so that value can be given a 16 + byte alignment. */ + +/* { dg-do compile } */ +/* { dg-options "-fno-common" { target { hppa*-*-hpux* } } } */ + +typedef float v4sf __attribute__((vector_size(16))); +v4sf value; +void foo(void) +{ + unsigned int band; + for(band=0; band < 2; band++) + { + value += (v4sf){1e9f,1e9f,1e9f,1e9f}; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr23424-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr23424-1.c new file mode 100644 index 000000000..91950d77a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr23424-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +extern char *x; +extern void foo (void); +void f (char *s, char *se, char *mp, char *y) +{ + while (s != se) + { + char *p; + foo (); + p = s + *mp; + *y++ = *p; + s = p; + } + + x = s; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr23821.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr23821.c new file mode 100644 index 000000000..04847d65a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr23821.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-fno-fat-lto-objects" } { "" } } */ +/* At -O1 DOM threads a jump in a non-optimal way which leads to + the bogus propagation. */ +/* { dg-skip-if "" { *-*-* } { "-O1" } { "" } } */ +/* { dg-options "-fdump-tree-ivcanon-details" } */ + +int a[199]; + +extern void abort (void); + +int +main () +{ + int i, x; + for (i = 0; i < 199; i++) + { + x = a[i]; + if (x != i) + abort (); + } + return 0; +} + +/* Verify that we do not propagate the equivalence x == i into the + induction variable increment. */ + +/* { dg-final { scan-tree-dump "Added canonical iv" "ivcanon" } } */ +/* { dg-final { cleanup-tree-dump "ivcanon" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr24257.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr24257.c new file mode 100644 index 000000000..d685df63d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr24257.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-fgcse -fgcse-sm" } */ + +typedef struct A { + int buf, left; +} A; + +static void flush(A *s, int n) +{ + s->buf <<= n; + + while (s->left < 32) { + s->buf <<= 8; + s->left += 8; + } + + s->buf=0; +} + +void oof(A *s, int n) +{ + s->buf = n; + s->left = n; + + flush(s, n); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr24626-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr24626-1.c new file mode 100644 index 000000000..331c55ec3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr24626-1.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ + +typedef long +(*bla)(int *node); + +static long F2(void *tree, long blk, bla after_node_func) +{ + long call_result = 0; + int *node; + + + if (call_result = after_node_func(node)) + goto error_free_node; + + T(node); + return 0; + +error_free_node: + T(node); +error: + return call_result; +} + +long F1(void *tree) +{ + return F2(tree, F3(tree), (void *)0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr24626-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr24626-2.c new file mode 100644 index 000000000..e48d3b31c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr24626-2.c @@ -0,0 +1,54 @@ +/* { dg-do compile } */ + +typedef unsigned int u_int8_t __attribute__ ((__mode__ (__QI__))); +typedef unsigned int u_int32_t __attribute__ ((__mode__ (__SI__))); +typedef u_int32_t db_pgno_t; +typedef struct __db DB; +typedef struct __db_env DB_ENV; +typedef struct __db_mpoolfile DB_MPOOLFILE; +typedef struct __dbc DBC; +struct __db { + DB_MPOOLFILE *mpf; + db_pgno_t meta_pgno; + struct __cq_aq { + } s_links; +}; +struct __db_env { + struct { + } xa_txn; + u_int32_t flags; +}; +typedef enum { MU_REMOVE, MU_RENAME, MU_OPEN } mu_action; +typedef struct __dbpginfo { + u_int8_t type; +} PAGE; +int __db_master_update(mdbp, sdbp, txn, subdb, type, action, newname, flags) + DB *mdbp, *sdbp; +{ + DB_ENV *dbenv; + DBC *dbc, *ndbc; + PAGE *p, *r; + int modify, ret, t_ret; + if ((ret = __db_cursor(mdbp, txn, &dbc, + (((dbenv)->flags & (0x0000002)) + && modify) ? 35 : 0)) != 0) + goto err; + switch (action) { + case MU_REMOVE: + if ((ret = __memp_fget(mdbp->mpf, &sdbp->meta_pgno, 0, &p)) != 0) + goto err; + if ((((PAGE *)p)->type) == 9) { + if ((ret = __db_free(dbc, r)) != 0) { } + } + if ((ret = __db_free(dbc, p)) != 0) { + p = ((void *)0); + goto err; + } + p = ((void *)0); + } + err: + if (ndbc != ((void *)0) && (t_ret = __db_c_close(ndbc)) != 0 && ret == 0) + ret = t_ret; + return (ret); +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr24626-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr24626-3.c new file mode 100644 index 000000000..778068268 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr24626-3.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ + +long fff(int*); + +long F2(int *node) +{ + long call_result = 0; + + if (call_result = fff(node)) + goto error_free_node; + + T(node); + return 0; + +error_free_node: + T(node); + return call_result; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr24626-4.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr24626-4.c new file mode 100644 index 000000000..a66801661 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr24626-4.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-fmodulo-sched" } */ + +int foo(short* vec1, short* vec2, short* vec3,int len ) +{ + int temp,i; + for (i=0; i<len; i++) { + temp = vec1[i] * 2; + temp += vec2[i] * 3 ; + vec3[i] = temp; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr24750-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr24750-1.c new file mode 100644 index 000000000..58b1ea2ef --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr24750-1.c @@ -0,0 +1,73 @@ +extern void free (void *); +extern int unknown; +extern int n0; +extern short *s0; +extern int n1; +extern short *s1; +extern short *s2; +extern int *n2; +extern int *n3; +extern int n4; +extern short *n5; +extern int *n6; +extern int n7; +extern char *unc; + +void +f (short *sp) +{ + int j = 0; + int i = 0; + int n8 = 0; + int n9 = 0; + short *s3 = sp; + short s4 = (short) unknown; + short s5 = (short) unknown; + char *c0 = unc; + int n10 = 0; + int n11 = 0; + int u0 = unknown; + int k = 0; + + for (n8 = 1; n8 <= n7; n8++) + { + for (i = 1; i <= n0; i++) + c0[i] = 0; + for (i = 1; i <= u0; i++) { } + for (i = sp[0]; i != -32767; i = sp[i]) + if (s4 == u0) + for (j = 1; j <= u0; j++) + if (!c0[s3[j]]) + break; + } + for (n9 = 1; n9 <= n0; n9++) s1[unknown + n9] = n9; + for (i = 1; i <= n1; i++) + for (j = 1; j <= s4; j++) + s3[j] = s1[s3[j]]; + for (n8 = 1; n8 <= n7; n8++) + for (i = 1; i <= s5; i++) + s3[i] = s1[s3[i]]; + for (n9 = 1; n9 <= n0; n9++) sp[s1[n9]] = unknown; + for (n10 = 2; n10 < n4; n10++) { } + for (k = 1; k <= unknown; k++) + { + s4 = s0[n5[u0]]; + for (i = 1; i <= s4; i++) { } + for (j = 1; j <= s4; j++) + if (n2[1] != 0) + if (i == unknown) + unknown = n3[unknown]; + n6[u0] = n10; + } + for (k = n7; k >= n11; k--) + if (n2[k] == -32767) + break; + free (c0); + + for (i = 1; i <= n7; i++) + { + for (j = 1; j <= s4; j++) { } + for (n8 = s2[unknown]; n8 != -32767; n8 = s2[n8]) { } + for (j = 1; j <= s5; j++) { } + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr24912-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr24912-1.c new file mode 100644 index 000000000..947175f9d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr24912-1.c @@ -0,0 +1,10 @@ +void foo(void); +void +bar (unsigned char *p) +{ + int j; + j = *(p) ; + j += ((signed char) (*p) ) << 8; + if (j) + foo(); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr25183.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr25183.c new file mode 100644 index 000000000..0157b806c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr25183.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +enum err { + err_IO = 0x8a450000, /* { dg-warning "int" } */ + err_NM, + err_EOF, + err_SE, + err_PT +}; +static enum err E_; +int error() +{ + switch (E_) { + case err_IO : break; + case err_NM : break; + case err_EOF : break; + case err_SE : break; + case err_PT : break; + default : return 0; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr25481.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr25481.c new file mode 100644 index 000000000..3072e5ecb --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr25481.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ + +struct s { + int *blah; +}; + +static struct s array[] = { + { 0 } +}; + +void +foo (struct s *p) +{ + unsigned int n = 1; + struct s *q = &array[n]; + while (p < q) + p++; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr25654.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr25654.c new file mode 100644 index 000000000..03761e93c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr25654.c @@ -0,0 +1,37 @@ +/* { dg-do run } */ + +extern void abort (void) __attribute__((noreturn)); + +union setconflict +{ + short a[20]; + int b[10]; +}; + +int +main () +{ + int sum = 0; + { + union setconflict a; + short *c; + c = a.a; + asm ("": "=r" (c):"0" (c)); + *c = 0; + asm ("": "=r" (c):"0" (c)); + sum += *c; + } + { + union setconflict a; + int *c; + c = a.b; + asm ("": "=r" (c):"0" (c)); + *c = 1; + asm ("": "=r" (c):"0" (c)); + sum += *c; + } + + if (sum != 1) + abort(); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr25706-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr25706-1.c new file mode 100644 index 000000000..49bb32722 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr25706-1.c @@ -0,0 +1,35 @@ +/* { dg-do assemble } */ +/* Invalid assembly generated due to port bug. */ +struct tcp_opt { + unsigned int window_clamp; + unsigned int rcv_ssthresh; + unsigned short advmss; +}; +extern int sysctl_tcp_app_win; +void tcp_init_buffer_space(struct tcp_opt *tp, int maxwin) +{ + if (tp->window_clamp >= maxwin) + if (sysctl_tcp_app_win && maxwin>4*tp->advmss) + tp->window_clamp + = ({ + int _x = maxwin; + typeof(4*tp->advmss) _y = (4*tp->advmss); + _x > _y ? _x : _y; + }); + + if (sysctl_tcp_app_win + && tp->window_clamp > 2*tp->advmss + && tp->window_clamp + tp->advmss > maxwin) + tp->window_clamp + = ({ + unsigned short _x = maxwin; + unsigned short _y = (maxwin-tp->advmss); + _x > _y ? _x : _y; + }); + tp->rcv_ssthresh + = ({ + unsigned int _x = (tp->rcv_ssthresh); + unsigned int _y = (tp->window_clamp); + _x < _y ? _x : _y; + }); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr25718-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr25718-1.c new file mode 100644 index 000000000..8333a33a5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr25718-1.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* PR 25718: invalid constant operand to the "bound" insn; error at + assembly time. We'll make sure the code is correct to: run a few + example values. */ + +extern void exit (int); +extern void abort (void); +unsigned __attribute__ ((__noinline__)) foo(unsigned a) +{ + unsigned l; + l = (a >= (~0u - 512) ? (~0u - 512) : a); + return l; +} + +int +main (void) +{ + if (foo ((unsigned) -512) != (unsigned) -513 + || foo ((unsigned) -514) != (unsigned) -514 + || foo ((unsigned) -513) != (unsigned) -513 + || foo ((unsigned) -1) != (unsigned) -513 + || foo (513) != 513 + || foo (0) != 0) + abort (); + + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr25947-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr25947-1.c new file mode 100644 index 000000000..8af6f8d46 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr25947-1.c @@ -0,0 +1,22 @@ +/* PR target/25947: define_split in cris.md caused unrecognized insn. */ +/* { dg-options "-fpic" { target fpic } } */ +/* { dg-skip-if "requires unsupported run-time relocation" { spu-*-* } { "-O0" } { "" } } */ + +extern char *rl_line_buffer; +extern int rl_point; +extern int rl_end; +static const char *vi_motion = " hl^$0ftFT;,%wbeWBE|"; +void +rl_vi_complete (int ignore, int key) +{ + if ((rl_point < rl_end) + && + (!(((rl_line_buffer[rl_point]) == ' ') + || ((rl_line_buffer[rl_point]) == '\t')))) + { + if (! + (((rl_line_buffer[rl_point + 1]) == ' ') + || ((rl_line_buffer[rl_point + 1]) == '\t'))) + rl_vi_end_word (1, 'E'); + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26222.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26222.c new file mode 100644 index 000000000..b580db673 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26222.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-tree-pre -fno-tree-loop-im" } */ + +void putShort (int, int); + +int t2; +void f(int t1) +{ + int clutOffset = 52 + 256 * 3 * 2; + int x, y, z; + for (x = 0; x < 16; x++) + for (y = 0; y < 16; y++) + for (z = 0; z < 16; z++) + { + int offset = clutOffset + z * 6 + y * 16 * 6 + x * 16 * 16 * 6; + double xf = ((double) x) / ((double) 16 - 1.0); + double tt = xf; + putShort(offset, tt); + } +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26258.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26258.c new file mode 100644 index 000000000..e9acd55cc --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26258.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ + +extern void abort(void); + +typedef struct Foo { int a; int b; } Foo; + +Foo foo(Foo first, Foo last, _Bool ret_first) +{ + Foo t; + Foo *t1 = (ret_first ? &first : &last); + first.a = 2; + last.b = 3; + t.a = t1->a; + t.b = t1->b; + t.a += first.a; + t.b += last.b; + return t; +} + +int main() +{ + Foo first = (Foo){1, 2}; + Foo last = (Foo){3, 4}; + Foo ret = foo(first, last, 0); + if (ret.b != 6) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26515.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26515.c new file mode 100644 index 000000000..a051e2e53 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26515.c @@ -0,0 +1,27 @@ +/* { dg-options "-march=v10" { target cris*-*-* } } */ +struct i +{ + long long i_size; + struct a *i_mapping; +}; +struct p +{ + struct a *mapping; + long index; +}; +extern void b (struct p*, unsigned); +extern void u (struct p*); +void +block_page_mkwrite (struct i *i, struct p *p) +{ + unsigned end = 0; + long long size = 0; + size = i->i_size; + if ((p->mapping != i->i_mapping)) + goto out_unlock; + if (((p->index + 1) << 13) > size) + end = size & ~(~(((1UL) << 13) - 1)); + b (p, end); +out_unlock: + u (p); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26565.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26565.c new file mode 100644 index 000000000..d45272df3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26565.c @@ -0,0 +1,30 @@ +/* { dg-do run } */ +/* m32c is already packed. */ +/* { dg-skip-if "" { "m32c-*-*" } { "*" } { "" } } */ + +void *memcpy(void *dest, const void *src, __SIZE_TYPE__ n); + +struct timeval { + long tv_sec; +}; + +struct outdata { + long align; + char seq; + struct timeval tv __attribute__((packed)); /* { dg-warning "attribute ignored" "" { target default_packed } } */ +}; + +void send_probe(struct outdata *outdata, struct timeval *tp) __attribute__((noinline)); +void send_probe(struct outdata *outdata, struct timeval *tp) +{ + memcpy(&outdata->tv, tp, sizeof outdata->tv); +} + +struct timeval t; +struct outdata outdata; + +int main() +{ + send_probe(&outdata, &t); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26587.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26587.c new file mode 100644 index 000000000..ad5d60f3a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26587.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ +/* { dg-require-effective-target int32plus } */ + +extern void abort(void); +typedef unsigned int BF_word; +typedef BF_word BF_key[16 + 2]; +static struct { + BF_key P; +} BF_current; +int main(void) +{ + BF_word L; + BF_word tmp4, *ptr; + BF_word i; + for (i = 0; i < 16 + 2; i++) + BF_current.P[i] = i * 0x98765432; + L = 0; + ptr = BF_current.P; + do { + ptr += 2; + L ^= BF_current.P[0]; + tmp4 = L >> 24; + L = tmp4 ^ BF_current.P[16 + 1]; + *(ptr - 2) = L; + } while (ptr < &BF_current.P[16 + 2]); + if (L != 0x1fdb9752) + abort(); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26630.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26630.c new file mode 100644 index 000000000..96bab36a0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26630.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-require-effective-target int32plus } */ + +extern void abort(void); +int main() +{ + int a1 = 40000; + int c1 = ( ((int)(short)(a1-10000)) + 10000)*2; + if (c1 != 80000) + abort(); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26672.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26672.c new file mode 100644 index 000000000..b13b5dcae --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26672.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ + +int printf(const char *format, ...); +extern const char help_string[]; +void app_opts(void) { + printf("%s", help_string); +} +const char help_string[] = "foo\n"; diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26763-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26763-1.c new file mode 100644 index 000000000..37054e7a4 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26763-1.c @@ -0,0 +1,18 @@ +/* { dg-do run } */ + +extern void abort(void); + +int try (int *a) +{ + return a + -1 > a; +} + +int main(void) +{ + int bla[100]; + + if (try (bla + 50)) + abort (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26763-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26763-2.c new file mode 100644 index 000000000..d8155fb08 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26763-2.c @@ -0,0 +1,18 @@ +/* { dg-do run } */ + +extern void abort(void); + +int try (char *a, int d) +{ + return a + d > a; +} + +int main(void) +{ + char bla[100]; + + if (try (bla + 50, -1)) + abort (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26869.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26869.c new file mode 100644 index 000000000..6743319d1 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26869.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ + +_Complex float f (_Complex float b, _Complex float c) +{ + _Complex float a = 1.0 + 0.0i; + return a / c; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26898-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26898-1.c new file mode 100644 index 000000000..619412929 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26898-1.c @@ -0,0 +1,15 @@ +/* { dg-do link } */ +/* { dg-options "-fstrict-overflow" } */ + +#include <limits.h> + +extern void link_error(void); +int main() +{ + int i0, i1; + if (!(i0 + 1 < i1 + 1 == i0 < i1)) + link_error (); + if (!(i0 + INT_MIN < i1 - INT_MAX == i0 < i1 - -1)) + link_error (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26898-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26898-2.c new file mode 100644 index 000000000..508fde4ce --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26898-2.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ + +#include <limits.h> + +int a = 0, b = INT_MAX - 1; +extern void abort(void); +int main() +{ + if (a - 1 > b + 1) + abort(); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26998.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26998.c new file mode 100644 index 000000000..d50c34473 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr26998.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ + +int decCompareOp (int result) +{ + if (result != (int)0x80000000) + { + result = -result; + return (result > 0); + } + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27116-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27116-2.c new file mode 100644 index 000000000..9c748b245 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27116-2.c @@ -0,0 +1,13 @@ +/* { dg-do run } */ + +extern void abort(void); + +int main (void) +{ + volatile long int n; + n = -2; + + if ((-2147483647L - 1L) / (-n) != -1073741824L) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27116.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27116.c new file mode 100644 index 000000000..70eeb1a86 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27116.c @@ -0,0 +1,15 @@ +/* { dg-do run } */ + +extern void abort(void); + +int f(int a, int b) +{ + return (-1 - a) / (-b); +} + +int main() +{ + if (f(__INT_MAX__, 2) != __INT_MAX__/2 + 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27136.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27136.c new file mode 100644 index 000000000..32b7bf123 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27136.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-ffast-math" } */ + +void foo() +{ + double x; + + for (x = 2; x < 10; x *= x) + ; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27184.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27184.c new file mode 100644 index 000000000..cfb6ed2a8 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27184.c @@ -0,0 +1,22 @@ +/* Copyright 2006 Free Software Foundation */ + +/* Make sure a and a1 alias each other. + Incomplete array types used to not be unified, which broke aliasing. */ + +/* { dg-do run } */ + +typedef long atype[]; +typedef long atype1[]; +int NumSift (atype *a, atype1 *a1) +{ + (*a)[0] = 0; + (*a1)[0] = 1; + return (*a)[0]; +} +int main(void) +{ + long a[2]; + if (!NumSift(&a, &a)) + __builtin_abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27302-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27302-2.c new file mode 100644 index 000000000..5c201b3d2 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27302-2.c @@ -0,0 +1,52 @@ +/* { dg-do run } */ +/* { dg-options "-fstrict-overflow" } */ + +extern void link_error (void); + +void test0 (int a, int b) +{ + if ((a < b) != (b > a)) + link_error (); + + if ((a - 1 < b) != (a <= b)) + link_error (); + if ((a - 2 < b) != (a - 1 <= b)) + link_error (); + if ((a + -1 < b) != (a <= b)) + link_error (); + if ((a + -2 < b) != (a + -1 <= b)) + link_error (); + + if ((a + 1 > b) != (a >= b)) + link_error (); + if ((a + 2 > b) != (a + 1 >= b)) + link_error (); + if ((a - -1 > b) != (a >= b)) + link_error (); + if ((a - -2 > b) != (a - -1 >= b)) + link_error (); + + if ((a + 1 <= b) != (a < b)) + link_error (); + if ((a + 2 <= b) != (a + 1 < b)) + link_error (); + if ((a - -1 <= b) != (a < b)) + link_error (); + if ((a - -2 <= b) != (a - -1 < b)) + link_error (); + + if ((a - 1 >= b) != (a > b)) + link_error (); + if ((a - 2 >= b) != (a - 1 > b)) + link_error (); + if ((a + -1 >= b) != (a > b)) + link_error (); + if ((a + -2 >= b) != (a + -1 > b)) + link_error (); +} + +int main() +{ + test0 (1, 2); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27302.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27302.c new file mode 100644 index 000000000..0e41fc385 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27302.c @@ -0,0 +1,15 @@ +/* { dg-do run } */ + +extern void link_error (void); + +void test0 (int a, int b) +{ + if ((a < b) != (b > a)) + link_error (); +} + +int main() +{ + test0 (1, 2); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27409.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27409.c new file mode 100644 index 000000000..430e6c8cc --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27409.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ + +typedef struct { + struct { } z; +} thang_t; + +struct { + short e; + thang_t f; + int g; +} my_struct; + +void function(int blaz) +{ + thang_t *fp = &my_struct.f; + foo(fp); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27603.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27603.c new file mode 100644 index 000000000..8cb0235ab --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27603.c @@ -0,0 +1,16 @@ +/* { dg-do run } */ + +void exit (int); +void abort (void); +int a; +int main() +{ + int j; + for (j = 0; j < 6; j++) + { + if ((unsigned)j - 3 <= 1) + exit (0); + a = 1000 * (6 - j); + } + abort (); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27743.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27743.c new file mode 100644 index 000000000..47d70457c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27743.c @@ -0,0 +1,16 @@ +/* { dg-do run { target { stdint_types } } } */ + +#include <stdint.h> +extern void abort(void); + +int32_t bar (int32_t a) +{ + return ((uint32_t) ((a) >> 2)) >> 15; +} + +int main() +{ + if (bar (0xffff3000) != 0x1ffff) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27773.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27773.c new file mode 100644 index 000000000..e30e540ff --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr27773.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ + +_Complex float f(_Complex float a, float b) +{ + return a - a*b; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr28045.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr28045.c new file mode 100644 index 000000000..f2d16646c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr28045.c @@ -0,0 +1,22 @@ +/* { dg-do run } */ + +extern void abort(void); +struct a +{ + unsigned int bits : 1; + signed long val : ((sizeof(long) * 8) - 1); +}; +int Fnegate (struct a b) +{ + if ((-((long)b.val)) <= ((long) ((1UL << ((sizeof(long) * 8) - 2)) -1UL)) + && (-((long)b.val)) >= (-(((long) ((1UL << ((sizeof(long) * 8) - 2)) -1UL))) - 1)) + return 0 ; + abort (); +} +int main () +{ + struct a b = {1, 1}; + Fnegate (b); + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr28230.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr28230.c new file mode 100644 index 000000000..5ecc0c716 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr28230.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-fwrapv" } */ + +void foo( unsigned long long bb, unsigned short tn, unsigned e, unsigned* w ); +void foo( unsigned long long bb, unsigned short tn, unsigned e, unsigned* w ) +{ + unsigned n = tn + bb; + do { + e = (e > n) ? e : *w; + n -= (e > n) ? n : e; + if (*w) + *w = 0; + } while ( n ); +} +int main() +{ + unsigned w = 0; + foo( 0, 0, 0, &w ); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr28268.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr28268.c new file mode 100644 index 000000000..f143c0804 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr28268.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ + +int __attribute__((vector_size(8))) a; + +void foo() +{ + a += a*a; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr28814.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr28814.c new file mode 100644 index 000000000..cc3c9f6ce --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr28814.c @@ -0,0 +1,17 @@ +/* { dg-do compile { target { ilp32 || lp64 } } } */ + +struct w49 +{ + union + { + } + value; +}; +f9887 (struct w49 a23040) +{ + unsigned long r9887; + if (((struct structure_type24753 *) (r9887 - 1)) == ((void *) 0)) + { + backtrace ("stalin.sc", 7222, 248274); + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr28900.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr28900.c new file mode 100644 index 000000000..75555f46e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr28900.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-ftree-vectorize" } */ + +int synths_ ( float * rc) +{ + float r1, r2; + int i; + for (i = 0; i < 128; ++i) + { + r2 = rc[i]; + r1 = ((r2) <= (.99f) ? (r2) : (.99f)); + rc[i] = ((r1) >= (-.99f) ? (r1) : (-.99f)); + } +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr29119.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr29119.c new file mode 100644 index 000000000..63e5d8693 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr29119.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ + +void ldt_add_entry(void) +{ + __asm__ ("" :: "m"(({unsigned __v; __v;}))); +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr29446.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr29446.c new file mode 100644 index 000000000..5571c71e8 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr29446.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ + +void f(_Bool D917, int j0, int ubound1, int ubound5) +{ + int i, j = j0; + int (*abc)[3]; + i = 1; + while (1) + { + if (j <= 3) + while (1) + { + if (i != j) + { + if (ubound1 <= 0) + return; + (*abc)[1] = 0; + } + else + { + if (j > ubound1) + return; + if (ubound5 <= 0) + return; + } + j = j + 1; + if (D917) + break; + } + i = i + 1; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr29584.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr29584.c new file mode 100644 index 000000000..4cb51d275 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr29584.c @@ -0,0 +1,28 @@ +/* PR middle-end/29584 */ +/* { dg-do compile { target { ilp32 || lp64 } } } */ + +extern void *foo1 (void); +extern void foo2 (void); +extern void foo3 (void *, void *); +extern int foo4 (void); + +void +bar (void) +{ + int i; + void *s; + for (i = 1; i < 4; i++) + { + if (foo4 ()) + foo2 (); + switch (0x8000000UL + i * 0x400) + { + case 0x80000000UL ... 0x80000000UL + 0x3a000000UL - 1: + s = 0; + break; + default: + s = foo1 (); + } + foo3 ((void *) (0x8000000UL + i * 0x400), s); + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr30313.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr30313.c new file mode 100644 index 000000000..aefeb7866 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr30313.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ + +static inline void bar(){} + +struct S +{ +#if __INT_MAX__ == 32767 + signed int i: 16; +#elif __INT_MAX__ == 2147483647 + signed int i: 32; +#elif __INT_MAX__ == 9223372036854775807 + signed int i: 64; +#else +#error Please add support for your target here +#endif +}; + +int main() +{ + struct S x = {32}; + sizeof(x.i+0); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr30364-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr30364-1.c new file mode 100644 index 000000000..64ee7e44e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr30364-1.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ + +#include <limits.h> +extern void abort (void); + +int f(int a, int b) +{ + if (a > INT_MAX - 15) return 0; + if (b > INT_MAX - 15) return 0; + + int c = (a - 20) + (b - 20); + return c > INT_MAX - 15; +} + +int main() +{ + if (f (INT_MAX - 15, 41) != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr30364-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr30364-2.c new file mode 100644 index 000000000..d8b678d53 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr30364-2.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ + +#include <limits.h> +extern void abort (void); + +int f(unsigned int a, unsigned int b) +{ + if (a > INT_MAX - 15) return 0; + if (b > INT_MAX - 15) return 0; + + int c = (a - 20) + (b - 20); + return c > INT_MAX - 15; +} + +int main() +{ + if (f (INT_MAX - 15, 41) != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr30364-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr30364-3.c new file mode 100644 index 000000000..ae96ba39f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr30364-3.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ +/* { dg-options "-fwrapv" } */ + +#include <limits.h> +extern void abort (void); + +int f(int a, int b) +{ + if (a > INT_MAX - 15) return 0; + if (b > INT_MAX - 15) return 0; + + int c = (a - 20) + (b - 20); + return c > INT_MAX - 15; +} + +int main() +{ + if (f (INT_MAX - 15, 41) != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr30375.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr30375.c new file mode 100644 index 000000000..435c38f13 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr30375.c @@ -0,0 +1,37 @@ +/* { dg-do run } */ + +typedef struct _s { + int a; + int b; + int c; + int d; +} s; + +extern void abort(void); + +void __attribute__((noinline)) g(s *p) +{ + if (p->d != 0) + abort (); +} + +char *c = (void*)0; +void __attribute__((noinline)) f(void) { if (c) *c = 1; } + +void test_signed_msg_encoding(void) +{ + s signInfo = { sizeof(signInfo), 0 }; + + signInfo.b = 1; + signInfo.c = 0; + g(&signInfo); + signInfo.d = 1; + f(); +} + +int main() +{ + test_signed_msg_encoding (); + test_signed_msg_encoding (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr30665-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr30665-1.c new file mode 100644 index 000000000..4650408d5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr30665-1.c @@ -0,0 +1,24 @@ +/* PR target/30665: bug in cris.md peephole2 condition. + Testcase for trunk. */ +/* { dg-do run } */ + +extern void abort (void); +extern void exit (int); + +int __attribute__ ((__noinline__)) f (unsigned *p, int *x) +{ + int y = *p++ & 0xfff; + *x++ = y; + *x = *p; + return y; +} + +int main (void) +{ + unsigned u[2] = { 0x3aad, 0x5ad1 }; + int x[2] = {17689, 23456}; + + if (f (u, x) != 0xaad || x[0] != 0xaad || x[1] != 0x5ad1) + abort (); + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr30665-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr30665-2.c new file mode 100644 index 000000000..a2cbf024c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr30665-2.c @@ -0,0 +1,57 @@ +/* PR target/30665: bug in cris.md peephole2 condition. + Original reduced testcase (fails on 3.2.1 derivate, not on trunk). */ +/* { dg-do run } */ + +extern void abort (void); +extern void exit (int); + +struct t +{ + unsigned int a : 12; + unsigned int b : 12; + unsigned int dummy1 : 8; +}; + +struct area +{ + int xa; + int xb; +}; + +struct c +{ + struct area ii; +}; + +static struct c c; + +void __attribute__ ((__noinline__)) g(int a) +{ + if (a != 79) + abort (); +} + +void __attribute__ ((__noinline__)) h(struct t tt) +{ + if (tt.a != 20 || tt.b != 79) + abort (); +} + +void __attribute__ ((__noinline__)) s(void); + +int main(int argc, char **argv) +{ + c.ii.xa = 20; + c.ii.xb = 79; + + s(); + + exit (0); +} + +void __attribute__ ((__noinline__)) s(void) +{ + struct t ii_x = { .a = c.ii.xa, .b = c.ii.xb }; + g(c.ii.xb); + h(ii_x); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr31115.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr31115.c new file mode 100644 index 000000000..1395a34b3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr31115.c @@ -0,0 +1,22 @@ +/* { dg-do run } */ + +extern void exit(int); +extern void abort(); +void foo (int e1) +{ + if (e1 < 0) + { + e1 = -e1; + if (e1 >>= 4) + { + if (e1 >= 1 << 5) + exit(0); + } + } +} + +int main() +{ + foo(-(1<<9)); + abort(); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr31254.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr31254.c new file mode 100644 index 000000000..cec301273 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr31254.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ + +struct timespec +{ + long tv_sec; + long tv_nsec; +}; +struct inode +{ + struct timespec i_atime; + struct timespec i_mtime; +}; +struct afs_vnode +{ + struct inode vfs_inode; +}; +static inline + struct inode *AFS_VNODE_TO_I (struct afs_vnode *vnode) +{ + return &vnode->vfs_inode; +}; +afs_inode_map_status (struct afs_vnode *vnode) +{ + struct inode *inode = AFS_VNODE_TO_I (vnode); + inode->i_atime = inode->i_mtime; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr32897.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr32897.c new file mode 100644 index 000000000..3dc43ece0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr32897.c @@ -0,0 +1,27 @@ +/* { dg-options "-G0" { target mips*-*-* } } */ + +volatile int g[32]; +long long gll; +double gd; + +#define MULTI(X) \ + X( 1), X( 2), X( 3), X( 4), X( 5), X( 6), X( 7), X( 8), X( 9), X(10), \ + X(11), X(12), X(13), X(14), X(15), X(16), X(17), X(18), X(19), X(20), \ + X(21), X(22), X(23), X(24), X(25), X(26), X(27), X(28), X(29), X(30) + +#define DECLARE(INDEX) x##INDEX +#define COPY_IN(INDEX) x##INDEX = g[INDEX] +#define COPY_OUT(INDEX) g[INDEX] = x##INDEX + +void +test (int n) +{ + union { long long l; double d; } u = { 0x12345678 }; + gll = u.l; + int MULTI (DECLARE); + MULTI (COPY_IN); + MULTI (COPY_OUT); + MULTI (COPY_OUT); + MULTI (COPY_OUT); + gd = u.d; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr33560.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr33560.c new file mode 100644 index 000000000..7eea1e3f6 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr33560.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ + +struct T +{ + int a, b; +} t; + +__attribute__((noinline)) struct T *f (struct T *p) +{ + struct T *q = __builtin_malloc (sizeof (struct T)); + *q = *p; + return q; +} + +int main (void) +{ + struct T *p; + + t.a = 1; + t.b = 2; + p = f (&t); + t.a = 3; + + if (p->a != 1) + __builtin_abort (); + + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr33563.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr33563.c new file mode 100644 index 000000000..33e78521c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr33563.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ + +struct T +{ + int a, b; +} t, q; + +int main (void) +{ + struct T *p; + + t.a = 1; + t.b = 2; + q = t; + t.a = 3; + + if (q.a != 1) + __builtin_abort (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr33655.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr33655.c new file mode 100644 index 000000000..2f9da65ae --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr33655.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +typedef struct { + unsigned long attr; + int chars[2]; +} cchar_t; +typedef struct _win_st { + cchar_t _bkgrnd; +} WINDOW; +void render_char(WINDOW *win, cchar_t ch) +{ + if ((ch).chars[0] == L' ' + && (ch).chars[1] == L'\0') + win->_bkgrnd = ch; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr33848.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr33848.c new file mode 100644 index 000000000..c3b85e9e5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr33848.c @@ -0,0 +1,43 @@ +/* &&foo should be hoisted, but on most targets, excess register pressure + forces it to be rematerialized before "data != &&foo". On targets that + have a "branch if registers are equal" instruction, this leads to the + branch having two LABEL_REFs: one for the branch target and one for + &&foo. When reloading &&foo into a register, reload would wrongly + say that &&foo was the target of the branch, and the real target would + then be removed as dead. */ +/* { dg-do link } */ +#define NVARS 30 +#define MULTI(X) \ + X( 0), X( 1), X( 2), X( 3), X( 4), X( 5), X( 6), X( 7), X( 8), X( 9), \ + X(10), X(11), X(12), X(13), X(14), X(15), X(16), X(17), X(18), X(19), \ + X(20), X(21), X(22), X(23), X(24), X(25), X(26), X(27), X(28), X(29) + +#define DECLARE(INDEX) i##INDEX = gv[INDEX] +#define COPY(INDEX) gv[INDEX] = i##INDEX + +volatile int gv[NVARS]; +void *volatile data; + +int +main (void) +{ + __label__ foo; + + if (gv[0] == 1) + goto foo; + data = &&foo; + do + { + int MULTI (DECLARE); + MULTI (COPY); + MULTI (COPY); + MULTI (COPY); + if (data != &&foo) + gv[0] = 1; + else + gv[1] = 2; + } + while (gv[0] > 0); + foo: + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr33870.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr33870.c new file mode 100644 index 000000000..9c0e30d94 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr33870.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ + +struct X { + int i; + int a[4]; +} m; + +int a[4]; + +int __attribute__((noinline)) foo(int b) +{ + int (*p)[4] = b ? &a : &m.a; + a[3] = 0; + (*p)[3] = 1; + return (*p)[3] + (*p)[2] + (*p)[1] + a[0] + a[3]; +} + +extern void abort (void); + +int main() +{ + int i; + for (i = 0; i < 4; ++i) + a[i] = 0; + if (foo(1) != 2) + abort (); + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr34174-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr34174-1.c new file mode 100644 index 000000000..0f1ed067f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr34174-1.c @@ -0,0 +1,44 @@ +/* { dg-do run } */ +/* Based on PR target/27386 testcase by Joerg Wunsch. */ + +extern void abort (void); +extern void exit (int); + +#if __INT_MAX__ >= 9223372036854775807LL +typedef unsigned int uint64_t; +#elif __LONG_MAX__ >= 9223372036854775807LL +typedef unsigned long int uint64_t; +#elif __LONG_LONG_MAX__ >= 9223372036854775807LL +typedef unsigned long long int uint64_t; +#else +int +main (void) +{ + exit (0); +} +#endif + +uint64_t a, b, c; + +int +foo (uint64_t x, uint64_t y, uint64_t z, int i) +{ + a = x; + b = y; + c = z; + return 2 * i; +} + +int +main (void) +{ + if (foo (1234512345123ull, 3456734567345ull, 7897897897897ull, 42) != 84) + abort (); + if (a != 1234512345123ull) + abort (); + if (b != 3456734567345ull) + abort (); + if (c != 7897897897897ull) + abort (); + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr34330.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr34330.c new file mode 100644 index 000000000..0ed2f9fb3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr34330.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target pthread } */ +/* { dg-options "-ftree-parallelize-loops=4 -ftree-vectorize" } */ + +struct T +{ + int t; + struct { short s1, s2, s3, s4; } *s; +}; + +void +foo (int *a, int *b, int *c, int *d, struct T *e) +{ + int i; + for (i = 0; i < e->t; i++) + { + e->s[i].s1 = a[i]; + e->s[i].s2 = b[i]; + e->s[i].s3 = c[i]; + e->s[i].s4 = d[i]; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35227.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35227.c new file mode 100644 index 000000000..d951d250f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35227.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ + +mandel(double _Complex C) +{ + int py; + C = (__extension__ 1.0iF) * (double)py; + return cabs(C); /* { dg-warning "incompatible" } */ +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35400.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35400.c new file mode 100644 index 000000000..285dc72e3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35400.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-Wtype-limits" } */ + +struct A +{ + struct A *p; +}; + +int foo(const struct A *q) +{ + return q->p == q; +} + +void bar(int); + +void baz() +{ + struct A a; + + while (foo(&a)) + bar(foo(&a)); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35634.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35634.c new file mode 100644 index 000000000..73f860f2b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35634.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ + +void abort (void); +void exit (int); + +void foo (int i) +{ + static int n; + if (i < -128 || i > 127) + abort (); + if (++n > 1000) + exit (0); +} + +int main () +{ + signed char c; + for (c = 0; ; c++) foo (c); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35771-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35771-1.c new file mode 100644 index 000000000..b3fd554da --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35771-1.c @@ -0,0 +1,9 @@ +/* { dg-do run { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-msse2" } */ +/* { dg-require-effective-target sse2_runtime } */ + +typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__)); + +#define TYPE __m128 + +#include "pr35771.h" diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35771-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35771-2.c new file mode 100644 index 000000000..a033caefd --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35771-2.c @@ -0,0 +1,9 @@ +/* { dg-do run { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-msse2" } */ +/* { dg-require-effective-target sse2_runtime } */ + +typedef double __m128d __attribute__ ((__vector_size__ (16), __may_alias__)); + +#define TYPE __m128d + +#include "pr35771.h" diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35771-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35771-3.c new file mode 100644 index 000000000..fcbe86cb1 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35771-3.c @@ -0,0 +1,9 @@ +/* { dg-do run { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-msse2" } */ +/* { dg-require-effective-target sse2_runtime } */ + +typedef long long __m128i __attribute__ ((__vector_size__ (16), __may_alias__)); + +#define TYPE __m128i + +#include "pr35771.h" diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35771.h b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35771.h new file mode 100644 index 000000000..7b921c41b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35771.h @@ -0,0 +1,30 @@ +typedef TYPE __attribute__((aligned(1))) unaligned; + +extern void abort (void); + + +TYPE __attribute__((noinline)) +foo (TYPE a1, TYPE a2, TYPE a3, TYPE a4, + TYPE a5, TYPE a6, TYPE a7, TYPE a8, + int b1, int b2, int b3, int b4, int b5, int b6, int b7, unaligned y) +{ + return y; +} + +void +do_test (void) +{ + unaligned x; + TYPE y = { 0 }; + x = y; + y = foo (y, y, y, y, y, y, y, y, 1, 2, 3, 4, 5, 6, -1, x); + if (__builtin_memcmp (&y, &x, sizeof (y)) != 0) + abort (); +} + +int +main (void) +{ + do_test (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35833.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35833.c new file mode 100644 index 000000000..2e740f29f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35833.c @@ -0,0 +1,22 @@ +/* { dg-do run } */ +/* { dg-options "-ftree-vrp" } */ + +struct S {struct S *field;}; +struct S True, False, Z; +static inline int f(void) {return 1;} +static inline int g(struct S **obj) { + return f() && *obj == &Z; +} +struct S **h(struct S **x) { + if (x) + return g(x) ? &True.field : &False.field; + else + return &True.field; +} +extern void abort (void); +int main() +{ + if (h(&False.field) != &False.field) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35842.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35842.c new file mode 100644 index 000000000..05b26d84c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr35842.c @@ -0,0 +1,12 @@ +/* { dg-do compile { target { *-*-mingw* } } } */ +extern __attribute__((dllimport)) const int SSL_ImplementedCiphers[]; +extern void SSL_GetCipherSuiteInfo(int cipherSuite); +void nsCipherInfo(int SSL_NumImplementedCiphers) +{ + int i; + for (i = 0; i < SSL_NumImplementedCiphers; ++i) + { + const int i_id = SSL_ImplementedCiphers[i]; + SSL_GetCipherSuiteInfo(i_id); + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36066.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36066.c new file mode 100644 index 000000000..0e1d1ce30 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36066.c @@ -0,0 +1,54 @@ +/* { dg-do compile } */ +/* { dg-options "-funsafe-loop-optimizations -ftree-vrp" } */ + +typedef int FLAC__int32; +typedef int FLAC__bool; +typedef struct { } FLAC__Subframe; +typedef enum { FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT = 0, FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE = 1, FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE = 2, FLAC__CHANNEL_ASSIGNMENT_MID_SIDE = 3 } FLAC__ChannelAssignment; +typedef struct { + struct FLAC__StreamEncoderProtected *protected_; + struct FLAC__StreamEncoderPrivate *private_; +} FLAC__StreamEncoder; +typedef struct FLAC__StreamEncoderProtected { + FLAC__bool loose_mid_side_stereo; + unsigned channels; + unsigned blocksize; +} FLAC__StreamEncoderProtected; +typedef struct FLAC__StreamEncoderPrivate { + FLAC__int32 *integer_signal[(8u)]; + FLAC__Subframe subframe_workspace_mid_side[2][2]; + unsigned best_subframe_mid_side[2]; + unsigned loose_mid_side_stereo_frame_count; +} FLAC__StreamEncoderPrivate; +static void get_wasted_bits_(FLAC__int32 signal[], unsigned samples) +{ + unsigned i; + FLAC__int32 x = 0; + for(i = 0; i < samples && !(x&1); i++) + x |= signal[i]; +} +FLAC__Subframe * process_subframes_(FLAC__StreamEncoder *encoder, unsigned *bits) +{ + unsigned channel; + FLAC__Subframe *left_subframe = 0; + FLAC__ChannelAssignment channel_assignment; + for(channel = 0; channel < encoder->protected_->channels; channel++) + get_wasted_bits_(encoder->private_->integer_signal[channel], encoder->protected_->blocksize); + if(encoder->protected_->loose_mid_side_stereo && encoder->private_->loose_mid_side_stereo_frame_count > 0) + channel_assignment = FLAC__CHANNEL_ASSIGNMENT_MID_SIDE; + else { + FLAC__ChannelAssignment ca = (FLAC__ChannelAssignment)1; + unsigned min_bits = bits[0]; + for(channel_assignment = (FLAC__ChannelAssignment)0; (int)ca <= 3; ca = (FLAC__ChannelAssignment)((int)ca + 1)) + if(bits[ca] < min_bits) + channel_assignment = ca; + } + switch(channel_assignment) { + case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT: + case FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE: + case FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE: + case FLAC__CHANNEL_ASSIGNMENT_MID_SIDE: + left_subframe = &encoder->private_->subframe_workspace_mid_side[0][encoder->private_->best_subframe_mid_side[0]]; + } + return left_subframe; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36227.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36227.c new file mode 100644 index 000000000..462b2c4f0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36227.c @@ -0,0 +1,17 @@ +/* { dg-do run { target { stdint_types } } } */ + +#include <stdint.h> +extern void abort (void); +int main() +{ + int i = 1; + int *p = &i; + uintptr_t iptr; + + iptr = (uintptr_t)p - (uintptr_t)&iptr; + p = (int *)((uintptr_t)&iptr + iptr); + if (*p != 1) + abort (); + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36244.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36244.c new file mode 100644 index 000000000..b1b14be18 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36244.c @@ -0,0 +1,40 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target pthread } */ +/* { dg-options "-O3 -ftree-parallelize-loops=4" } */ + +struct p7prior_s { + int mnum; /* number of mat emission Dirichlet mixtures */ + float mq[200]; /* probabilities of mnum components */ + float m[200][20]; /* match emission terms per mix component */ +}; + +struct p7prior_s *default_amino_prior(void); +struct p7prior_s *P7AllocPrior(void); + +struct p7prior_s * +default_amino_prior(void) +{ + struct p7prior_s *pri; + int x, q; + + static float defmq[5] = { + 0.178091, 0.056591, 0.0960191, 0.0781233, 0.0834977 }; + static float defm[5][6] = { + { 0.270671, 0.039848, 0.017576, 0.016415, 0.014268, 0.216147 }, + { 0.021465, 0.010300, 0.011741, 0.010883, 0.385651, 0.029156 }, + { 0.561459, 0.045448, 0.438366, 0.764167, 0.087364, 0.583402 }, + { 0.070143, 0.011140, 0.019479, 0.094657, 0.013162, 0.073732 }, + { 0.041103, 0.014794, 0.005610, 0.010216, 0.153602, 0.012049 } + }; + + pri = P7AllocPrior(); + pri->mnum = 5; + for (q = 0; q < pri->mnum; q++) + { + pri->mq[q] = defmq[q]; + for (x = 0; x < 6; x++) + pri->m[q][x] = defm[q][x]; + } + return pri; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-1.c new file mode 100644 index 000000000..9cd02c57a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-1.c @@ -0,0 +1,35 @@ +/* { dg-do run } */ +/* { dg-options "-fno-tree-sra" } */ + +extern void abort (void); +struct Bar { + struct Foo { + int *p; + } x; + int *q; +}; +struct Foo __attribute__((noinline)) +bar(int *p) +{ + struct Foo f; + f.p = p; + return f; +} +void __attribute__((noinline)) +foo(struct Foo f) +{ + *f.p = 0; +} +int main() +{ + int a, b; + a = 0; + b = 1; + struct Bar f; + f.x = bar (&b); + f.q = &a; + foo(f.x); + if (b != 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-10.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-10.c new file mode 100644 index 000000000..ed7017728 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-10.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ + +#if (__SIZEOF_LONG_LONG__ == __SIZEOF_POINTER__) +typedef unsigned long long uintptr_t; +#elif (__SIZEOF_LONG__ == __SIZEOF_POINTER__) +typedef unsigned long uintptr_t; +#elif (__SIZEOF_INT__ == __SIZEOF_POINTER__) +typedef unsigned int uintptr_t; +#else +#error Add target support here +#endif + +void __attribute__((noinline)) +foo(uintptr_t l) +{ + int *p = (int *)l; + *p = 1; +} + +extern void abort (void); +int main() +{ + int b = 0; + uintptr_t l = (uintptr_t)&b; + foo(l); + if (b != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-2.c new file mode 100644 index 000000000..2653182a5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-2.c @@ -0,0 +1,37 @@ +/* { dg-do run } */ +/* { dg-options "-fno-tree-sra" } */ + +extern void abort (void); +struct Foo { + int *p; +}; +struct Bar { + struct Foo *x; + int *q; +}; +struct Foo __attribute__((noinline)) +bar(int *p) +{ + struct Foo f; + f.p = p; + return f; +} +void __attribute__((noinline)) +foo(struct Foo f) +{ + *f.p = 0; +} +int main() +{ + int a, b; + a = 0; + b = 1; + struct Bar f; + struct Foo g = bar (&b); + f.x = &g; + f.q = &a; + foo(*f.x); + if (b != 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-3.c new file mode 100644 index 000000000..d5ad93e1b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-3.c @@ -0,0 +1,36 @@ +/* { dg-do run } */ + +extern void abort (void); +struct Foo { + int *p; +}; +struct Bar { + struct Foo *x; + int *q; +}; +struct Foo __attribute__((noinline)) +bar(int *p) +{ + struct Foo f; + f.p = p; + return f; +} +void __attribute__((noinline)) +foo(struct Foo f) +{ + *f.p = 0; +} +int main() +{ + int a, b; + a = 0; + b = 1; + struct Bar f; + struct Foo g = bar (&b); + f.x = &g; + f.q = &a; + foo(*f.x); + if (b != 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-4.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-4.c new file mode 100644 index 000000000..5f3b83349 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-4.c @@ -0,0 +1,33 @@ +/* { dg-do run } */ + +extern void abort (void); +struct Foo { + int *p; + int *q; +}; +struct Foo __attribute__((noinline)) +bar(int *p) +{ + struct Foo f; + f.p = p; + return f; +} +void __attribute__((noinline)) +foo(struct Foo f) +{ + *f.p = 0; +} +int main() +{ + int a, b; + a = 0; + b = 1; + struct Foo f; + f = bar (&b); + f.q = &a; + foo(f); + if (b != 0) + abort (); + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-5.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-5.c new file mode 100644 index 000000000..0061ef418 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-5.c @@ -0,0 +1,34 @@ +/* { dg-do run } */ +/* { dg-options "-fno-tree-sra" } */ + +extern void abort (void); +struct Foo { + int *p; + int *q; +}; +struct Foo __attribute__((noinline)) +bar(int *p) +{ + struct Foo f; + f.p = p; + return f; +} +void __attribute__((noinline)) +foo(struct Foo f) +{ + *f.p = 0; +} +int main() +{ + int a, b; + a = 0; + b = 1; + struct Foo f; + f = bar (&b); + f.q = &a; + foo(f); + if (b != 0) + abort (); + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-6.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-6.c new file mode 100644 index 000000000..c55e3ff3f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-6.c @@ -0,0 +1,30 @@ +/* { dg-do run } */ +/* { dg-options "-fno-tree-sra" } */ + +extern void abort (void); +struct Foo { + int *p; +} x; +struct Foo __attribute__((noinline)) +bar(int *p) +{ + struct Foo f; + f.p = p; + return f; +} +void __attribute__((noinline)) +foo() +{ + *x.p = 0; +} +int main() +{ + int b; + b = 1; + struct Foo g = bar (&b); + x = g; + foo(); + if (b != 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-7.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-7.c new file mode 100644 index 000000000..103694e15 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-7.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ + +extern void abort (void); +struct Foo { + int *p; +} x; +struct Foo __attribute__((noinline)) +bar(int *p) +{ + struct Foo f; + f.p = p; + return f; +} +void __attribute__((noinline)) +foo() +{ + *x.p = 0; +} +int main() +{ + int b; + b = 1; + struct Foo g = bar (&b); + x = g; + foo(); + if (b != 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-8.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-8.c new file mode 100644 index 000000000..9f77ea137 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-8.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-fno-tree-sra" } */ + +extern void abort (void); +struct Foo { + int *p; +} x; +void __attribute__((noinline)) +foo() +{ + *x.p = 0; +} +int main() +{ + int b; + struct Foo g; + b = 1; + g.p = &b; + x = g; + foo(); + if (b != 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-9.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-9.c new file mode 100644 index 000000000..5588eadae --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36373-9.c @@ -0,0 +1,23 @@ +/* { dg-do run } */ + +extern void abort (void); +struct Foo { + int *p; +} x; +void __attribute__((noinline)) +foo() +{ + *x.p = 0; +} +int main() +{ + int b; + struct Foo g; + b = 1; + g.p = &b; + x = g; + foo(); + if (b != 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36400.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36400.c new file mode 100644 index 000000000..1dedc0aa1 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36400.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-ffat-lto-objects" } */ + +struct barstruct { char const* some_string; }; + +void changethepointer(struct barstruct***); + +void baz() +{ + struct barstruct bar1; + struct barstruct* barptr = &bar1; + struct barstruct** barptr2 = &barptr; + changethepointer(&barptr2); + barptr->some_string = "Everything OK"; +} + +/* { dg-final { scan-assembler "Everything OK" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36891.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36891.c new file mode 100644 index 000000000..ab58e43b9 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36891.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-ffast-math" } */ +/* { dg-options "-ffast-math -msse" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-require-effective-target sse { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-options "-ffast-math -mabi=altivec" { target { { powerpc*-*-linux* } && ia32 } } } */ + +#define __vector __attribute__((vector_size(16) )) +__vector float f(void); +void g(__vector float); +void RRB( __vector float vdist, __vector float vx) +{ + int detail; + for(detail = 0; detail < 5;++detail) + { + __vector float frand = f(); + __vector float pullperc = frand/ vdist; + __vector float pullx = vx * pullperc; + g(pullx); + } +} + +/* Ignore a warning that is irrelevant to the purpose of this test. */ +/* { dg-prune-output ".*GCC vector returned by reference.*" } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36978.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36978.c new file mode 100644 index 000000000..cd1af4ebc --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr36978.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-funswitch-loops" } */ + +unsigned short status; +void foo (const _Bool flag) +{ + if (status == 2 || status == 7) + { + while (status != 2 && (status != 7 || !flag)) + { + } + } +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr37731-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr37731-1.c new file mode 100644 index 000000000..5c156b1f9 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr37731-1.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ + +extern void abort (); + +unsigned long long xh = 1; + +int +main () +{ + unsigned long long yh = 0xffffffffull; + unsigned long long z = xh * yh; + + if (z != yh) + abort (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr37731-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr37731-2.c new file mode 100644 index 000000000..a7f8f1e02 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr37731-2.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ + +extern void abort (); + +long long xh = 1; + +int +main () +{ + long long yh = 0xffffffffll; + long long z = xh * yh; + + if (z != yh) + abort (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr37868.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr37868.c new file mode 100644 index 000000000..5204c5a59 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr37868.c @@ -0,0 +1,39 @@ +/* { dg-do run } */ +/* { dg-options "-fno-strict-aliasing" } */ +/* { dg-skip-if "unaligned access" { arc*-*-* epiphany-*-* nds32*-*-* sparc*-*-* sh*-*-* tic6x-*-* } "*" "" } */ + +extern void abort (void); +#if (__SIZEOF_INT__ <= 2) +struct X { + unsigned char pad : 4; + unsigned int a : 16; + unsigned int b : 8; + unsigned int c : 6; +} __attribute__((packed)); +#else +struct X { + unsigned char pad : 4; + unsigned int a : 32; + unsigned int b : 24; + unsigned int c : 6; +} __attribute__((packed)); + +#endif + + +int main (void) +{ + struct X x; + unsigned int bad_bits; + + x.pad = -1; + x.a = -1; + x.b = -1; + x.c = -1; + + bad_bits = ((unsigned int)-1) ^ *(1+(unsigned int *) &x); + if (bad_bits != 0) + abort (); + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr37969.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr37969.c new file mode 100644 index 000000000..cbb6f0598 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr37969.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-funswitch-loops" } */ + +void foo(double); +void CreateDefaultTexture(double mnMinimum, double mnMaximum, + unsigned short nCreateWhat) +{ + double d = 0.0; + for(;;) + { + if(nCreateWhat & (0x0001) + && mnMinimum != 0.0) + d = mnMinimum; + if(nCreateWhat & (0x0002) + && mnMaximum != 0.0) + d = mnMaximum; + foo(d); + } +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr38271.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr38271.c new file mode 100644 index 000000000..2c64a9b34 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr38271.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized" } */ + +struct xxx { + short a; + short b; + void *c; +}; + +void bar(struct xxx); + +void foo(struct xxx *p, int i) +{ + struct xxx s0 = *p; + struct xxx s = s0; + if (s.a) i++; + bar(s); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr38405.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr38405.c new file mode 100644 index 000000000..3f93445cd --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr38405.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ + +extern void abort (); +extern int printf (char *__format, ...); + +struct vpiBinaryConst { + int signed_flag :1; + int sized_flag :1; +}; + +int binary_get(int code, struct vpiBinaryConst *rfp) +{ + switch (code) { + case 1: + return rfp->signed_flag ? 1 : 0; + default: + printf("error: %d not supported\n", code); + return code; + } +} + +int main(void) +{ + struct vpiBinaryConst x={1,0}; + int y=binary_get(1, &x); + if (y!=1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr38774.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr38774.c new file mode 100644 index 000000000..b62619416 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr38774.c @@ -0,0 +1,16 @@ +/* PR rtl-optimization/38774 */ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-options "-march=i686" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +extern int bar (void); +volatile int g; + +int +foo (void) +{ + int a = 1 >= bar (); + if ((1 > 9223372036854775807LL - a && 1 - a ? : 1 + a) & 1) + return g; + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr38948.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr38948.c new file mode 100644 index 000000000..98ed493cb --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr38948.c @@ -0,0 +1,101 @@ +/* { dg-options "-fno-tree-sra" } */ +/* { dg-options "-fno-tree-sra -march=v32" { target cris-*-* } } */ +typedef unsigned char byte; +typedef unsigned int uint; +typedef int bool; +typedef struct gs_const_string_s +{ + const byte *data; +} +gs_const_string; +struct gs_matrix_s +{ + float xx, xy, yx, yy, tx, ty; +}; +typedef struct gs_matrix_s gs_matrix; +typedef long fixed; +typedef struct gs_fixed_point_s +{ + fixed x, y; +} +gs_fixed_point; +typedef struct gs_matrix_fixed_s +{ + int x; +} +gs_matrix_fixed; +static int +append_simple (const byte * glyph, const gs_matrix_fixed * pmat, void * ppath) +{ + int numContours = + (int) (((((uint) ((glyph)[0]) << 8) + (glyph)[1]) ^ 0x8000) - 0x8000); + const byte *pends = glyph + 10; + int code = 0; + { + uint i = 0; + uint np = 0; + gs_fixed_point pt = {0}; + uint reps = 0; + for (i = 0, np = 0; i < numContours; ++i) + { + bool move = ((bool) 1); + uint last_point = + (((uint) ((pends + i * 2)[0]) << 8) + (pends + i * 2)[1]); + int off_curve = 0; + gs_fixed_point cpoints[3]; + for (; np <= last_point; --reps, ++np) + { + if (move) + { + cpoints[0] = pt; + move = ((bool) 0); + } + else + { + switch (off_curve++) + { + default: + cpoints[2].x = ((cpoints[1].x + pt.x) / 2); + cpoints[2].y = ((cpoints[1].y + pt.y) / 2); + code = + gx_path_add_curve_notes (ppath, + ((cpoints[0].x + + 2 * cpoints[1].x) / 3), + ((cpoints[0].y + + 2 * cpoints[1].y) / 3), + ((2 * cpoints[1].x + + cpoints[2].x) / 3), + ((2 * cpoints[1].y + + cpoints[2].y) / 3), + cpoints[2].x, cpoints[2].y, + 0); + cpoints[0] = cpoints[2]; + case 0: + cpoints[1] = pt; + } + } + } + } + } +} +int +append_outline (uint glyph_index, const gs_matrix_fixed *pmat, void *ppath) +{ + gs_const_string glyph_string = {0}; + int numContours = 0; + numContours = + (int) (((((uint) ((glyph_string.data)[0]) << 8) + + (glyph_string.data)[1]) ^ 0x8000) - 0x8000); + if (numContours >= 0) + return append_simple (glyph_string.data, pmat, ppath); + { + uint flags = 0; + do + { + gs_matrix_fixed mat = {0}; + gs_matrix scale_mat = {0}; + gs_matrix_multiply (&scale_mat, (const gs_matrix *) &mat, (gs_matrix *) & mat); + } + while (flags & 32); + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39074-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39074-2.c new file mode 100644 index 000000000..d18930a4d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39074-2.c @@ -0,0 +1,35 @@ +/* { dg-do run } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-options "-fdump-tree-alias" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-fno-fat-lto-objects" } { "" } } */ + +#include <stdint.h> + +int i; +uintptr_t __attribute__((noinline,const)) bar(int ***p) { return (uintptr_t)p; } +void __attribute__((noinline)) +foo(void) +{ + int *y; + int **a = &y, **x; + int ***p; + uintptr_t b; + b = bar(&a); + p = (int ***)b; + x = *p; + *x = &i; /* *ANYTHING = &i has to make sure that y points to i. */ + *y = 0; +} +extern void abort (void); +int main() +{ + i = 1; + foo (); + if (i != 0) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "y.._. = { i }" "alias" } } */ +/* { dg-final { scan-tree-dump "y.._., points-to vars: { D..... }" "alias" } } */ +/* { dg-final { cleanup-tree-dump "alias" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39074-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39074-3.c new file mode 100644 index 000000000..7c7604826 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39074-3.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-require-effective-target stdint_types } */ + +#include <stdint.h> + +uintptr_t __attribute__((noinline,const)) bar(int ***p) { return (uintptr_t)p; } +extern void abort (void); +int main() +{ + int i, j; + int *y = &j; + int **a = &y, **x; + int ***p; + uintptr_t b; + b = bar(&a); + p = (int ***)b; + x = *p; + *x = &i; + i = 1; + *y = 0; + if (i != 0) + abort (); + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39074.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39074.c new file mode 100644 index 000000000..5d46f3120 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39074.c @@ -0,0 +1,34 @@ +/* { dg-do run } */ +/* { dg-options "-fdump-tree-alias" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-fno-fat-lto-objects" } { "" } } */ + +typedef __INTPTR_TYPE__ intptr_t; + +int i; +void __attribute__((noinline)) +foo(long b, intptr_t q) +{ + int *y; + int **a = &y, **x; + int ***p; + if (b) + p = (int ***)q; + else + p = &a; + x = *p; + *x = &i; /* *ANYTHING = &i has to make sure that y points to i. */ + *y = 0; +} +extern void abort (void); +int main() +{ + i = 1; + foo (0, 0); + if (i != 0) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "y.._. = { i }" "alias" } } */ +/* { dg-final { scan-tree-dump "y.._., points-to vars: { D..... }" "alias" } } */ +/* { dg-final { cleanup-tree-dump "alias" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39132.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39132.c new file mode 100644 index 000000000..f6e2907e0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39132.c @@ -0,0 +1,34 @@ +/* { dg-do run } */ +/* { dg-options "-ftree-loop-distribution" } */ + +extern void abort(void); + +struct epic_private +{ + unsigned int *rx_ring; + unsigned int rx_skbuff[5]; +}; + +int +main (void) +{ + struct epic_private ep; + unsigned int rx_ring[5]; + int i; + + ep.rx_skbuff[0] = 5; + + ep.rx_ring = rx_ring; + + for (i = 0; i < 5; i++) + { + ep.rx_ring[i] = i; + ep.rx_skbuff[i] = 0; + } + + if (ep.rx_skbuff[0] != 0) + abort (); + + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39204.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39204.c new file mode 100644 index 000000000..1389a52ec --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39204.c @@ -0,0 +1,131 @@ +/* { dg-do compile } */ +/* { dg-options "-w" } */ + +__extension__ typedef __SIZE_TYPE__ size_t; +typedef unsigned char __u_char; +typedef unsigned short int __u_short; +typedef unsigned int __u_int; +typedef unsigned long int __u_long; +typedef signed char __int8_t; +typedef unsigned char __uint8_t; +typedef signed short int __int16_t; +typedef unsigned short int __uint16_t; +typedef signed int __int32_t; +typedef unsigned int __uint32_t; +__extension__ typedef signed long long int __int64_t; +__extension__ typedef unsigned long long int __uint64_t; +__extension__ typedef long long int __quad_t; +__extension__ typedef unsigned long long int __u_quad_t; +__extension__ typedef __u_quad_t __dev_t; +__extension__ typedef unsigned int __uid_t; +__extension__ typedef unsigned int __gid_t; +__extension__ typedef unsigned long int __ino_t; +__extension__ typedef __u_quad_t __ino64_t; +__extension__ typedef unsigned int __mode_t; +__extension__ typedef unsigned int __nlink_t; +__extension__ typedef long int __off_t; +__extension__ typedef __quad_t __off64_t; +__extension__ typedef int __pid_t; +__extension__ typedef struct { + int __val[2]; +} __fsid_t; +__extension__ typedef long int __clock_t; +__extension__ typedef unsigned int __id_t; +typedef struct _IO_FILE FILE; +typedef struct _IO_FILE __FILE; +typedef struct { + int __count; + union { + unsigned int __wch; + char __wchb[4]; + } + __value; +} __mbstate_t; +typedef struct { + __off_t __pos; + __mbstate_t __state; +} _G_fpos_t; +typedef struct { + __off64_t __pos; + __mbstate_t __state; +} _G_fpos64_t; +typedef unsigned int _G_uint16_t __attribute__ ((__mode__ (__HI__))); +typedef struct _IO_FILE _IO_FILE; +extern struct _IO_FILE_plus _IO_2_1_stderr_; +extern int fputs (__const char *__restrict __s, FILE * __restrict __stream); +extern char *strstr (__const char *__haystack, __const char *__needle) + __attribute__ ((__nonnull__ (1, 2))); + extern char *rindex (__const char *__s, int __c) __attribute__ ((__nonnull__ (1))); +extern size_t strlen (__const char *__s) __attribute__ ((__nothrow__)) + __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); + char *mystrlwr (char *string); + char *m_replace_filename (const char *path, const char *filename); + typedef struct LINE { + char *text; + struct LINE *next; + int flags; + } LINE; +typedef struct TOC { + char *text; + char *alt; + struct TOC *next; + int root; + int texinfoable; + int htmlable; + int otherfile; +} TOC; +static int _empty_count; +extern char *_word_substitution[256]; +static void _output_sorted_nested_toc (TOC ** list, unsigned int num_items); +static char *_do_text_substitution (char *input); +static int _toc_scmp (const void *e1, const void *e2) +{ + TOC *t1 = *((TOC **) e1); + TOC *t2 = *((TOC **) e2); + return mystricmp (t1->text, t2->text); +} +static void _output_buffered_text (void) { if (_empty_count) ; } +void _post_process_filename (char *filename) +{ + int code_scanning = 0; + char *new_filename, *p; + char *line; + FILE *f1 = 0, *f2 = 0; + if (!new_filename || strlen (new_filename) < 2) + new_filename[strlen (filename) - 1] = 'x'; + if (!f1 || !f2) + while ((line = m_fgets (f1))) + { + line = _do_text_substitution (line); + fputs (line, f2); + } + if (remove (filename)) + cancel: + if (f1) + if (f2) + if (new_filename) + ; +} +static void _close_html_file (FILE * file) +{ + int f; + for (f = 0; _word_substitution[f]; f++) + ; +} +static __attribute__((always_inline)) +char * _do_text_substitution (char *input) +{ + int start, end, middle, f; + char *temp, *found, *reader; + for (f = 0; _word_substitution[f]; f++) + { + reader = input; + while ((found = strstr (reader, _word_substitution[f]))) + { + start = found - input; + input = temp; + reader = temp + start + middle; + } + } + return input; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39241.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39241.c new file mode 100644 index 000000000..860a04d73 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39241.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-w" } */ + +static inline int +foo (float f) +{ + return *((int *) &f) - 1; +} + +float +bar (float x, float y, float *z) +{ + float c = y < 0.002f ? 0.002f : y; + float d = x < c ? c : x; + return z[foo (c)] + z[foo (d * 255.0f)]; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39678.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39678.c new file mode 100644 index 000000000..5411fbbc1 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39678.c @@ -0,0 +1,27 @@ +/* PR target/39678 */ +/* { dg-do run } */ +/* { dg-options "-Wno-psabi" } */ + +struct X { + signed char c; + __complex__ float val; +}; + +struct X __attribute__((noinline)) +foo (float *p) +{ + struct X x; + x.c = -3; + __real x.val = p[0]; + __imag x.val = p[1]; + return x; +} +extern void abort (void); +float a[2] = { 3., -2. }; +int main() +{ + struct X x = foo(a); + if (x.c != -3 || __real x.val != a[0] || __imag x.val != a[1]) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39829.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39829.c new file mode 100644 index 000000000..da15a56e1 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39829.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-w" } */ + +void foo (void * DAG_temp117584) +{ + char uA; + void* pA; + void* pB; + void* pC; + do { + int DAG_temp117585; + int DAG_temp117586; + void ** __indir_union1 = (void**)DAG_temp117584; + DAG_temp117585 = (long)*__indir_union1; + DAG_temp117586 = DAG_temp117585; + if ( DAG_temp117586 != (int)268435456 ) + pA = (void*)&uA; + pB = (void*)&pA; + pC = pB; + union __block_indir0_u { struct { long val; } __indir_struct; } + * __indir_union = (union __block_indir0_u*)pC; + f(__indir_union->__indir_struct.val); + + DAG_temp117584 += 64; + } while (1); +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39855.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39855.c new file mode 100644 index 000000000..6d75c38a9 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39855.c @@ -0,0 +1,24 @@ +/* PR c/39855 */ +/* { dg-do run { target { int32plus } } } */ + +extern void abort (void); + +int i, j, k; + +int +foo (void) +{ + return ++i; +} + +int +main () +{ + if (__CHAR_BIT__ != 8 || sizeof (int) != 4) + return 0; + j = foo () << 30 << 2; + k = (unsigned) foo () >> 16 >> 16; + if (i != 2 || j != 0 || k != 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39903-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39903-1.c new file mode 100644 index 000000000..1a67dd795 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39903-1.c @@ -0,0 +1,24 @@ +/* PR target/39903 */ +/* { dg-do run } */ +/* { dg-options "-Wno-psabi" } */ + +struct X { + double d; + double b[]; +}; + +struct X __attribute__((noinline)) +foo (double d) +{ + struct X x; + x.d = d; + return x; +} +extern void abort (void); +int main() +{ + struct X x = foo(3.0); + if (x.d != 3.0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39903-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39903-2.c new file mode 100644 index 000000000..0cd74029b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr39903-2.c @@ -0,0 +1,24 @@ +/* PR target/39903 */ +/* { dg-do run } */ +/* { dg-options "-Wno-psabi" } */ + +struct X { + float d; + float b[]; +}; + +struct X __attribute__((noinline)) +foo (float d) +{ + struct X x; + x.d = d; + return x; +} +extern void abort (void); +int main() +{ + struct X x = foo(3.0); + if (x.d != 3.0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr40328.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr40328.c new file mode 100644 index 000000000..e378e63c0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr40328.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-tree-sra" } */ + +_Complex float foo(void) +{ + _Complex float a[64] = {}; + _Complex float x; + x = a[1]; + return x; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr40470-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr40470-1.c new file mode 100644 index 000000000..cb2510e88 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr40470-1.c @@ -0,0 +1,22 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-msse4" } */ +#include <nmmintrin.h> +__m128i load (char *); +char * +foo (char *p1, char *p2, + int bmsk, __m128i mask1, __m128i mask2) +{ + int len = 0; + __m128i frag1, frag2; + int cmp_s; + if( !p2[0]) return p1; + if( !p1[0] ) return NULL; + frag2 = load (p2); + frag1 = load (p1); + frag2 = _mm_blendv_epi8(frag2, mask2, mask1); + frag1 = _mm_blendv_epi8(frag1, mask2, mask1); + cmp_s = _mm_cmpistrs(frag2, frag1, 0x0c); + if( cmp_s ) + __asm("bsfl %[bmsk], %[len]" : [len] "=r" (len) : [bmsk] "r" (bmsk) ); + return p1 + len; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr40470-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr40470-2.c new file mode 100644 index 000000000..b0414bbea --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr40470-2.c @@ -0,0 +1,27 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-msse4" } */ +#include <nmmintrin.h> +__m128i load (char *); +char * +foo (const unsigned char *s1, const unsigned char *s2, + int bmsk, __m128i frag2) +{ + int len = 0; + char *p1 = (char *) s1; + char *p2 = (char *) s2; + __m128i frag1, fruc, mask; + int cmp_c, cmp_s; + if( !p2[0]) return (char *) s1; + if( !p1[0] ) return NULL; + if( p2[1]) frag2 = load (p2); + frag1 = load (p1); + fruc = _mm_loadu_si128 ((__m128i *) s1); + mask = _mm_cmpistrm(fruc, frag2, 0x44); + frag2 = _mm_blendv_epi8(frag2, mask, mask); + frag1 = _mm_blendv_epi8(frag1, mask, mask); + cmp_c = _mm_cmpistrc(frag2, frag1, 0x0c); + cmp_s = _mm_cmpistrs(frag2, frag1, 0x0c); + if( cmp_s & cmp_c ) + __asm("bsfl %[bmsk], %[len]" : [len] "=r" (len) : [bmsk] "r" (bmsk) ); + return p2 + len; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr40470-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr40470-3.c new file mode 100644 index 000000000..5c4c361de --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr40470-3.c @@ -0,0 +1,22 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-msse4" } */ +#include <nmmintrin.h> +__m128i load (char *); +char * +foo (char *p1, char *p2, + int bmsk, __m128i mask1, __m128i mask2) +{ + int len = 0; + __m128i frag1, frag2; + int cmp_s; + if( !p2[0]) return p1; + if( !p1[0] ) return NULL; + frag2 = load (p2); + frag1 = load (p1); + frag2 = _mm_blendv_epi8(frag2, mask2, mask1); + frag1 = _mm_blendv_epi8(frag1, mask1, mask2); + cmp_s = _mm_cmpistrs(frag2, frag1, 0x0c); + if( cmp_s ) + __asm("bsfl %[bmsk], %[len]" : [len] "=r" (len) : [bmsk] "r" (bmsk) ); + return p1 + len; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr40470-4.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr40470-4.c new file mode 100644 index 000000000..f9d0e5095 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr40470-4.c @@ -0,0 +1,29 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-msse4" } */ +#include <nmmintrin.h> +__m128i load (char *); +char * +foo (const unsigned char *s1, const unsigned char *s2, + int bmsk, __m128i frag2) +{ + int len = 0; + char *p1 = (char *) s1; + char *p2 = (char *) s2; + __m128i frag1, fruc1, fruc2, mask1, mask2; + int cmp_c, cmp_s; + if( !p2[0]) return (char *) s1; + if( !p1[0] ) return NULL; + if( p2[1]) frag2 = load (p2); + frag1 = load (p1); + fruc1 = _mm_loadu_si128 ((__m128i *) s1); + fruc2 = _mm_loadu_si128 ((__m128i *) s2); + mask1 = _mm_cmpistrm(fruc1, frag2, 0x44); + mask2 = _mm_cmpistrm(fruc2, frag1, 0x14); + frag2 = _mm_blendv_epi8(frag2, mask1, mask2); + frag1 = _mm_blendv_epi8(frag1, mask2, mask1); + cmp_c = _mm_cmpistrc(frag2, frag1, 0x0c); + cmp_s = _mm_cmpistrs(frag2, frag1, 0x0c); + if( cmp_s & cmp_c ) + __asm("bsfl %[bmsk], %[len]" : [len] "=r" (len) : [bmsk] "r" (bmsk) ); + return p2 + len; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr41094.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr41094.c new file mode 100644 index 000000000..2a4e9616c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr41094.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ +/* { dg-options "-ffast-math" } */ + +#include <math.h> + +extern void abort (void); + +double foo(void) +{ + double x = -4.0; + return pow (x * x, 0.25); +} + +int main() +{ + if (foo() != 2.0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr41261.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr41261.c new file mode 100644 index 000000000..8e601555c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr41261.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-fprofile-arcs" } */ + +extern void relocate_kernel(); +void machine_kexec(void *control_page) +{ + __builtin_memcpy(control_page, relocate_kernel, 2048); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr41555.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr41555.c new file mode 100644 index 000000000..c201fda0c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr41555.c @@ -0,0 +1,119 @@ +/* { dg-do run } */ +/* { dg-options "-std=c99" } */ + +#include <stdint.h> +#include <limits.h> + +extern void abort (void); + +static uint64_t safe_div_func_uint64_t_u_u (uint64_t _ui1, uint64_t _ui2) +{ + if (_ui2==0) return _ui1; + return _ui1 / _ui2; +} + +static int64_t safe_div_func_int64_t_s_s (int64_t _si1, int64_t _si2) +{ + if (_si2==0 || (_si1==INT64_MIN && _si2==-1)) return _si1; + return _si1 / _si2; +} + +#define safe_add_macro_int8_t_s_s(si1,si2) \ + ((((((int8_t)(si1))>((int8_t)0)) && (((int8_t)(si2))>((int8_t)0)) && (((int8_t)(si1)) > ((INT8_MAX)-((int8_t)(si2))))) \ + || ((((int8_t)(si1))<((int8_t)0)) && (((int8_t)(si2))<((int8_t)0)) && (((int8_t)(si1)) < ((INT8_MIN)-((int8_t)(si2)))))) \ + ? ((int8_t)(si1)) \ + : (((int8_t)(si1)) + ((int8_t)(si2))) \ + ) + +static int8_t +safe_add_func_int8_t_s_s(int8_t _si1, int8_t _si2) +{ + return safe_add_macro_int8_t_s_s(_si1,_si2); +} + +#define safe_rshift_macro_uint64_t_u_s(left,right) \ + (((((int)(right)) < ((uint64_t)0)) \ + || (((int)(right)) >= sizeof(uint64_t)*CHAR_BIT)) \ + ? ((uint64_t)(left)) \ + : (((uint64_t)(left)) >> ((int)(right)))) + +static uint64_t +safe_rshift_func_uint64_t_u_s(uint64_t _left, int _right) +{ + return safe_rshift_macro_uint64_t_u_s(_left,_right); +} + +#define safe_mul_macro_int32_t_s_s(si1,si2) \ + ((((((int32_t)(si1)) > ((int32_t)0)) && (((int32_t)(si2)) > ((int32_t)0)) && (((int32_t)(si1)) > ((INT32_MAX) / ((int32_t)(si2))))) || \ + ((((int32_t)(si1)) > ((int32_t)0)) && (((int32_t)(si2)) <= ((int32_t)0)) && (((int32_t)(si2)) < ((INT32_MIN) / ((int32_t)(si1))))) || \ + ((((int32_t)(si1)) <= ((int32_t)0)) && (((int32_t)(si2)) > ((int32_t)0)) && (((int32_t)(si1)) < ((INT32_MIN) / ((int32_t)(si2))))) || \ + ((((int32_t)(si1)) <= ((int32_t)0)) && (((int32_t)(si2)) <= ((int32_t)0)) && (((int32_t)(si1)) != ((int32_t)0)) && (((int32_t)(si2)) < ((INT32_MAX) / ((int32_t)(si1)))))) \ + ? ((int32_t)(si1)) \ + : ((int32_t)(si1)) * ((int32_t)(si2))) + +static int32_t +safe_mul_func_int32_t_s_s (int32_t _si1, int32_t _si2) +{ + return safe_mul_macro_int32_t_s_s(_si1,_si2); +} + +static int8_t g_39; +static volatile uint8_t g_46; +static uint8_t g_47; +static uint8_t *g_62; +static uint8_t g_79; +static int8_t g_101 = -1L; +static uint8_t *g_114; +static uint8_t *g_126; +static uint8_t g_133; + +static uint16_t func_35 (int32_t * p_36, uint64_t p_37, uint32_t p_38); +static uint16_t func_35 (int32_t * p_36, uint64_t p_37, uint32_t p_38) +{ + if (g_62 != 0) + abort (); + for (g_39 = 1; g_39 < 0; g_39 = 1) + { + } + return 1; +} + +static int32_t func_19 (int32_t p_20); +static int32_t func_19 (int32_t p_20) +{ + if (1 != + safe_div_func_uint64_t_u_u ((safe_div_func_int64_t_s_s (p_20, 1)), + g_101)) + { + func_35 (0, 1 <= (safe_add_func_int8_t_s_s (g_47, g_46)) > p_20 < 1, 1); + g_133 = 1; + if (g_114 != 0) + abort (); + if (g_126 != 0) + abort (); + } + return 1; +} + +static uint8_t func_2 (int32_t p_6); +static uint8_t func_2 (int32_t p_6) +{ + for (1; p_6 > 1; 1) + return 0; + func_19 (g_79); + if (safe_mul_func_int32_t_s_s + ((0, 1 < (safe_rshift_func_uint64_t_u_s (1 ^ p_6, 1))), + (func_35 (&p_6, 1, 1) < 1))) + { + } + return 1; +} + +int main (void) +{ + func_2 (1); + if (g_133 != 1) + abort (); + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr41993.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr41993.c new file mode 100644 index 000000000..890e36561 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr41993.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx -mvzeroupper" { target { i?86-*-* x86_64-*-* } } } */ + +short retframe_short (void *rframe) +{ + __builtin_return (rframe); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr42363.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr42363.c new file mode 100644 index 000000000..9c9da1373 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr42363.c @@ -0,0 +1,84 @@ +/* PR middle-end/pr42363, extended from the test for PR middle-end/37913. */ +/* { dg-do compile } */ +/* { dg-options "-g" } */ + +void foo (void) __attribute__ ((noreturn)); + +static int __attribute__ ((noreturn)) +bar (void) +{ + foo (); +} + +int +baz (void) +{ + int i = bar (); + return i + 1; +} + +int fooz (void) __attribute__ ((noreturn)); + +static int __attribute__ ((noreturn)) +bart (void) +{ + return fooz (); /* { dg-warning "noreturn" } */ +} + +int bazr (void) +{ + int i = bart (); + return i + 1; +} + +static inline int +bard (void) +{ + return fooz (); +} + +int bizr (void) +{ + int i, j; + + i = j = bard (); + + return i + 1; +} + +/* This might be regarded as pure and folded, rather than inlined. + It's pure evil. */ +static int __attribute__ ((pure, const, noreturn)) +barf (void) +{ +} /* { dg-warning "does return" } */ + +static int __attribute__ ((pure, const)) +bark (void) +{ + barf (); +} + +int buzr (void) +{ + int i, j; + + i = j = bark () + bark (); + + return i + 1; +} + +int buzt (void) +{ + int i, j; + + i = j = barf () + barf (); + + return i + 1; +} + +void bust (void) +{ + while (barf ()) + ; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr42667.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr42667.c new file mode 100644 index 000000000..eac80014b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr42667.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-w" } */ + +extern int strlen(const char *); +void WriteTextDots(int len); + +void OnDisplay(char * string) +{ + if (!string) + string = "(none)"; + WriteTextDots(strlen(string)); +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr42878-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr42878-1.c new file mode 100644 index 000000000..8c21f0f60 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr42878-1.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-options "-fcompare-debug" } */ + +struct S { + int i; +}; + +extern struct S *e1(void); +extern int e2(int i); + +static inline void f1() +{ + int i; + struct S *s; + for (i = 0; i < 10; i++) + s = e1(); + e2(s->i); +} + +static inline void f2(int i) +{ + int j = j; + j = e2(i); +} + +void foo(int i) +{ + f1(); + f2(i); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr42878-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr42878-2.c new file mode 100644 index 000000000..67e413a2c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr42878-2.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-fcompare-debug" } */ + +extern void error(void) __attribute__((noreturn)); + +struct S { + struct S *s; +}; + +static inline unsigned char f2() +{ + error(); +} + +static inline void f1() +{ + int builtin_optab; + if (!f2() && builtin_optab) + error(); +} + +extern void f4(struct S *s); + +static inline void f3(struct S *s) +{ + f4(s->s->s); +} + +void expand_builtin(struct S *s, int cond) +{ + if (cond) + f1(); + f3(s); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr42898-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr42898-2.c new file mode 100644 index 000000000..ee2de9675 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr42898-2.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-optimized" } */ +/* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } } */ + +struct hardware { + int parm1:8; + int :4; + int parm2:4; + int parm3:15; + int parm4:1; +}; + +const struct hardware h = { + .parm1=42, + .parm2=13, + .parm3=11850, + .parm4=1, +}; + +void f1(volatile struct hardware *ptr) +{ + *ptr = h; +} + +/* { dg-final { scan-tree-dump-times "\\*ptr" 1 "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr42898.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr42898.c new file mode 100644 index 000000000..d87c45dfb --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr42898.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-optimized" } */ +/* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } } */ + +struct hardware { + int parm1:8; + int :4; + int parm2:4; + int parm3:15; + int parm4:1; +}; + +void f1(volatile struct hardware *ptr) +{ + *ptr=(struct hardware) { + .parm1=42, + .parm2=13, + .parm3=11850, + .parm4=1, + }; +} + +/* { dg-final { scan-tree-dump-times "\\*ptr" 1 "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr42952.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr42952.c new file mode 100644 index 000000000..db8782af3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr42952.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ +/* { dg-options "-fno-tree-ccp -fno-tree-fre" } */ + +extern void abort (void); + +static int g[1]; + +static int * const p = &g[0]; +static int * const q = &g[0]; + +int main(void) +{ + g[0] = 1; + *p = 0; + *p = *q; + if (g[0] != 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43000.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43000.c new file mode 100644 index 000000000..c11233750 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43000.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-fwrapv" } */ + +int __attribute__((noinline)) +foo (long i, long j) +{ + if (i >= 1) + if (j > -(long)(((unsigned long)(long)-1)>>1)) + { + long x; + j--; + x = i + j; + if (x >= 0) + return 1; + } + return 0; +} +extern void abort (void); +int main() +{ + if (foo (1, 1) != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43002.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43002.c new file mode 100644 index 000000000..f28a9102b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43002.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall -fwrapv" } */ + +long A[4], B[100]; + +void foo(void) +{ + int i, j, k = 3; + while (A[k] && k > 0) k--; /* k = {0, 1, 2, 3} */ + for (i = 3 - k; i >= 0; i--) /* i = {0..3-k} */ + for (j = 0; j <= k; j++) { /* line 8; j = {0..k} */ + B[i + j] = 0; /* line 9; i + j = {0..3-k+k} = {0..3} */ + for (j = 0; j <= k; j++); /* only one iteration is done, with j == 0 */ + } +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43017.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43017.c new file mode 100644 index 000000000..257945290 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43017.c @@ -0,0 +1,99 @@ +/* { dg-do run } */ +/* { dg-options "-fwrapv" } */ + +signed char foo(unsigned char c2) +{ + signed char c2_22; + + if (c2 <= 63 || c2 == 127) + goto bb43; + else + goto bb20; + +bb20: + if (c2 > 252) + goto bb43; + else + goto bb21; + +bb21: + /*...*/; + +bb24: + c2_22 = (signed char)c2; + if (c2_22 >= 0) + goto bb25; + else + goto bb26; + +bb25: + c2 = (unsigned char)(c2_22 - 64); + goto bb27; + +bb26: + c2 = (unsigned char)(c2_22 - 65); + +bb27: + if (c2 <= 93) + goto bb28; + else + goto bb29; + +bb28: + c2 = c2 + 33; + goto bb30; + +bb29: + c2 = (unsigned char)((signed char)c2 - 61); + +bb30: + return c2; + +bb43: + return -1; +} +extern void abort (void); +int main() +{ + signed char res[256] = { + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, 78, 79, 80, + 81, 82, 83, 84, 85, 86, 87, 88, + 89, 90, 91, 92, 93, 94, 95, -1, + 96, 97, 98, 99, 100, 101, 102, 103, + 104, 105, 106, 107, 108, 109, 110, 111, + 112, 113, 114, 115, 116, 117, 118, 119, + 120, 121, 122, 123, 124, 125, 126, 33, + 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 73, + 74, 75, 76, 77, 78, 79, 80, 81, + 82, 83, 84, 85, 86, 87, 88, 89, + 90, 91, 92, 93, 94, 95, 96, 97, + 98, 99, 100, 101, 102, 103, 104, 105, + 106, 107, 108, 109, 110, 111, 112, 113, + 114, 115, 116, 117, 118, 119, 120, 121, + 122, 123, 124, 125, 126, -1, -1, -1 + }; + unsigned int c; + for (c = 0; c <= 255; ++c) + { + if (foo (c) != res[c]) + abort (); + } + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43165.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43165.c new file mode 100644 index 000000000..991c3d118 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43165.c @@ -0,0 +1,18 @@ +/* PR debug/43165 */ +/* { dg-options "-g" } */ +/* { dg-require-effective-target int32plus } */ + +struct __attribute__((packed)) S +{ + unsigned char a; + unsigned short b; + unsigned short c; + unsigned d : 24; +}; + +void +foo (struct S p) +{ + for (; p.c; p.c++) + ; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43360.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43360.c new file mode 100644 index 000000000..9ed9872db --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43360.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ + +int l_5_5_2 = 4; +int g_3[1][1]; + +void func_1 (void) +{ + for (g_3[0][0] = 1; g_3[0][0] < 8; g_3[0][0] += 7) { + int *l_6 = &g_3[0][0]; + *l_6 = l_5_5_2; + } +} + +int main (void) +{ + func_1 (); + if (g_3[0][0] != 11) + __builtin_abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43560.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43560.c new file mode 100644 index 000000000..44abb80b1 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43560.c @@ -0,0 +1,34 @@ +/* { dg-do run } */ +/* { dg-require-weak "" } */ + +int g_6[1][2] = {{1,1}}; +int g_34 = 0; +int *const g_82 = &g_6[0][1]; +int *g_85[2][1] __attribute__((weak)); + +void __attribute__((noinline)) +func_4 (int x) +{ + int i; + for (i = 0; i <= x; i++) { + if (g_6[0][1]) { + *g_82 = 1; + } else { + int **l_109 = &g_85[1][0]; + if (&g_82 != l_109) { + } else { + *l_109 = &g_6[0][1]; + } + *g_82 = 1; + } + } +} + +int main (void) +{ + g_85[0][0] = &g_34; + g_85[1][0] = &g_34; + func_4(1); + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43781.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43781.c new file mode 100644 index 000000000..37fe5a367 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43781.c @@ -0,0 +1,45 @@ +/* { dg-do compile } */ + +typedef int int32_t; +typedef unsigned char uint8_t; + +struct S0 +{ + uint8_t f3; +}; + +struct S2 +{ + uint8_t f5; +}; + +struct S0 g_22 = { + 0 +}; + +int32_t g_91; +const struct S2 *g_314; +const struct S2 **g_313 = &g_314; +struct S2 g_320[2] = { + 0 +}; + +void +int32func (uint64p_34) +{ + for (g_22.f3 = 0; g_22.f3 <= 0; g_22.f3) + { + lbl_491:{ + if (1) + { + int32_t *l_453[2][7][7][1][1]; + int i, j, k, l, m; + for (m; m; m++) + l_453[i][j][k][l][m]; + } + *g_313 = 0; + if (g_91) + goto lbl_491; + } + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43879-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43879-3.c new file mode 100644 index 000000000..5ee80d518 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43879-3.c @@ -0,0 +1,41 @@ +/* { dg-do run } */ +/* { dg-options "-fipa-pta" } */ + +typedef unsigned long ulong; + +int __attribute__((noinline, noclone)) +f4 (int a, int b, int c, int d, int e) +{ + return a + b + c + d + e; +} + +void __attribute__((noinline, noclone)) +f3 (int *p) +{ + *p = f4(1, 2, 3, 4, 5); +} + +void __attribute__((noinline, noclone)) +f2 () +{ + int unused; + f3 (&unused); +} + +void __attribute__((noinline, noclone)) +f1 (ulong e, ulong f) +{ + if (e > 5 || f > 5) __builtin_abort(); + f2 (); +} + + +int main() +{ + ulong e, f; + for (e = 5; e > 0; e--) + for (f = 5; f > 0; f--) + f1(e, f); + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43879_1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43879_1.c new file mode 100644 index 000000000..151a184cb --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43879_1.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-options "-fipa-pta" } */ +/* { dg-additional-sources "pr43879_2.c" } */ + +void bar(int c) +{ + static int x = 1; + if (c != x) __builtin_abort(); + x--; +} + +void baz(int *i) +{ + (*i)--; +} + +struct TBL { + int (*p)(int *i); +}; +extern struct TBL tbl; + +int main() +{ + int c = 1; + return tbl.p(&c); +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43879_2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43879_2.c new file mode 100644 index 000000000..8155653a6 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr43879_2.c @@ -0,0 +1,17 @@ +struct TBL { + int (*p)(int *i); +}; + +extern void bar(int i); +extern void baz(int *i); + +static int foo(int *i) +{ + bar(*i); + baz(i); + bar(*i); + return *i; +} + +struct TBL tbl = { foo }; + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr44050.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr44050.c new file mode 100644 index 000000000..931eff6ff --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr44050.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ +/* { dg-options "-fno-tree-pta" } */ + +static void __attribute__((noinline)) +foo (int *i, int n) +{ + *i = n; +} + +int +main (void) +{ + int i = 0; + foo (&i, 1); + + if (i != 1) + __builtin_abort (); + + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr44695.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr44695.c new file mode 100644 index 000000000..85bb4c7b9 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr44695.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +typedef unsigned char uint8_t; + +static uint8_t +safe_div_func_uint8_t_u_u (uint8_t ui1, uint8_t ui2) +{ + return ui2 ? ui2 : (ui1 / ui2); +} + +int +int81 (int x) +{ + return safe_div_func_uint8_t_u_u (1, 8 & x); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr44806.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr44806.c new file mode 100644 index 000000000..8b67b10f5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr44806.c @@ -0,0 +1,91 @@ +/* { dg-do run } */ +/* { dg-options "-std=c99" } */ + +#include <stdint.h> + +extern void abort (void); + +#define N_DEV_BITS_4 5 +#define N_INO_BITS_4 (32 - N_DEV_BITS_4 - 2 - 1) + +#define N_DEV_BITS_8 8 +#define N_INO_BITS_8 (64 - N_DEV_BITS_8 - 2 - 1) + +struct dev_ino_4 +{ + uint32_t mode:2; + uint32_t short_ino:N_INO_BITS_4; + uint32_t mapped_dev:N_DEV_BITS_4; + uint32_t always_set:1; +}; + +struct dev_ino_8 +{ + uint32_t mode:2; + uint64_t short_ino:N_INO_BITS_8; + uint32_t mapped_dev:N_DEV_BITS_8; + uint32_t always_set:1; +}; + +struct dev_ino_full +{ + uint32_t mode:2; + uint32_t dev; + uint32_t ino; +}; + +enum di_mode +{ + DI_MODE_4 = 1, + DI_MODE_8 = 2, + DI_MODE_FULL = 3 +}; + +struct di_ent +{ + union + { + struct dev_ino_4 di4; + struct dev_ino_8 di8; + struct dev_ino_full full; + uint32_t u32; + uint64_t u64; + void *ptr; + } u; +}; + +static struct di_ent +decode_ptr (struct di_ent const *v) +{ + struct di_ent di; + di.u.ptr = (void *) v; + return di; +} + +static int +di_ent_equal (void const *x, void const *y) +{ + struct di_ent a = decode_ptr (x); + struct di_ent b = decode_ptr (y); + if (a.u.di4.mode != b.u.di4.mode) + return 0; + + if (a.u.di4.mode == DI_MODE_4) + return (a.u.di4.short_ino == b.u.di4.short_ino + && a.u.di4.mapped_dev == b.u.di4.mapped_dev); + + if (a.u.di8.mode == DI_MODE_8) + return (a.u.di8.short_ino == b.u.di8.short_ino + && a.u.di8.mapped_dev == b.u.di8.mapped_dev); + + return (a.u.full.ino == b.u.full.ino + && a.u.full.dev == b.u.full.dev); +} + +int +main () +{ + if (di_ent_equal ((void *) 0x80143c4d, (void *) 0x80173851) != 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr44807.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr44807.c new file mode 100644 index 000000000..aa24a4c32 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr44807.c @@ -0,0 +1,40 @@ +/* { dg-do compile } */ + +struct jobstats +{ + int j_jobslots; +}; +struct jobstats js; +int *jobs; + +typedef int sh_job_map_func_t (int *, int, int, int); + +static void +map_over_jobs (sh_job_map_func_t func) +{ + int i; + int set, oset; + if (js.j_jobslots) + return; + sigemptyset (&set); + sigaddset (set, 17); + sigemptyset (&oset); + sigprocmask (0, set, oset); + for (i = 0; js.j_jobslots; i++) + if (jobs[i]) + func (jobs, 0, 0, 0); + sigprocmask (oset, ((void *) 0)); +} + +int +print_job (int *job, int format, int state, int job_index) +{ + map_over_jobs (print_job); +} + +void +list_running_jobs (void) +{ + map_over_jobs (print_job); +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr44913.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr44913.c new file mode 100644 index 000000000..eef61fbfb --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr44913.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ + +void __attribute__((noinline,noclone)) +foo (int *a, int n) +{ + int *lasta = a + n; + for (; a != lasta; a++) + { + *a *= 2; + a[1] = a[-1] + a[-2]; + } +} +extern void abort (void); +int main() +{ + int a[16] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; + int r[16] = { 1, 2, 6, 6, 16, 24, 44, 80, 136, 248, 432, 768, 1360, 2400, 4256, 3760 }; + unsigned i; + foo (&a[2], 13); + for (i = 0; i < 8; ++i) + if (a[i] != r[i]) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr44977.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr44977.c new file mode 100644 index 000000000..66fd7d1bf --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr44977.c @@ -0,0 +1,41 @@ +/* { dg-do compile } */ +/* { dg-options "-w" } */ + +static unsigned short +foo (unsigned short ui1, unsigned short ui2) +{ + return ui1 - ui2; +} + +static unsigned short +bar (unsigned ui1, unsigned short ui2) +{ + return ui1 + ui2; +} + +struct S1 +{ + const short f3; +}; +int g_31; +short g_67; +struct S1 g_68[2][5][9][1][1] = { +}; + +int func_90 (int); + +int int329 (int * const *const int32p_81, short ** p_82) +{ + short l_169[8]; + for (g_31 = 0; g_31 <= 0; g_31 = foo (g_31, 1)) + { + short l_85; +lbl_89:g_67 ^= l_85; + for (l_85 = 0; l_85 >= 0; l_85 = bar) + if (g_31) + goto lbl_89; + func_90 (1), g_68[0][2][2][0][0].f3, 0; + } + return l_169[6]; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45017.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45017.c new file mode 100644 index 000000000..f2e02bcea --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45017.c @@ -0,0 +1,24 @@ +/* { dg-do run { target i?86-*-* x86_64-*-* } } */ + +int tester(char *bytes) +{ + union { + struct { + unsigned int r1:4; + unsigned int r2:4; + } fmt; + char value[1]; + } ovl; + + ovl.value[0] = bytes[0]; + return ovl.fmt.r1; +} +extern void abort (void); +int main() +{ + char buff = 0x2f; + if (tester(&buff) != 0x0f) + abort (); + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45623.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45623.c new file mode 100644 index 000000000..693a8c4c7 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45623.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ +/* { dg-options "-std=c99" } */ + +#include <stdint.h> + +extern void abort (void); + +char *s1 = "foo"; +char *s2 = "bar"; + +char **ss1 = &s1; + +typedef union jsval_layout +{ + uint64_t asBits; + char **ptr; +} jsval_layout; + +int main() +{ + jsval_layout l, m; + l.ptr = ss1; + m.asBits = l.asBits; + char ** data = m.ptr; + *data = s2; + if (s1 != s2) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45636.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45636.c new file mode 100644 index 000000000..0566de86e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45636.c @@ -0,0 +1,77 @@ +/* { dg-do run } */ +/* { dg-require-effective-target mempcpy } */ +/* PR fortran/45636 */ + +typedef __SIZE_TYPE__ size_t; +void *memcpy (void *__restrict__, const void *__restrict__, size_t); +void *mempcpy (void *__restrict__, const void *__restrict__, size_t); +void *memset (void *, int, size_t); +int memcmp (const void *, const void *, size_t); +extern void abort (void); + +struct A { int i; char c[32]; } a[2]; + +__attribute__((noinline, noclone)) int +f1 (char *p, int q, int z) +{ + memcpy (p, "abcd", 4); + if (q) + z = z + 123; + else + z *= 114; + memset (p + 4, ' ', 2); + return z; +} + +__attribute__((noinline, noclone)) void +f2 (void) +{ + char *p = mempcpy (&a[0].c[13], "123456", 4); + memset (p, '7', 3); +} + +__attribute__((noinline, noclone)) void +f3 (struct A *p) +{ + p++; + char *q = &p->c[10]; + memcpy (q + 4, "__1234567" + 2, 7); + memset (&p->c[21], '9', 3); +} + +__attribute__((noinline, noclone)) void +f4 (void) +{ + memcpy (&a[0].c[10], "0123456789", 10); + memset (&a[0].c[13], ' ', 3); +} + +__attribute__((noinline, noclone)) void +check (const char *p, const char *str, size_t size) +{ + const char *q; + for (q = (const char *) &a; q < p; q++) + if (*q) + abort (); + if (memcmp (p, str, size) != 0) + abort (); + for (q = p + size; q < (const char *) (&a[0] + 2); q++) + if (*q) + abort (); + memset (&a, '\0', sizeof a); +} + +int +main (void) +{ + if (f1 (&a[0].c[7], 1, 2) != 125) + abort (); + check (&a[0].c[7], "abcd ", 6); + f2 (); + check (&a[0].c[13], "1234777", 7); + f3 (&a[0]); + check (&a[1].c[14], "1234567999", 10); + f4 (); + check (&a[0].c[10], "012 6789", 10); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45678-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45678-1.c new file mode 100644 index 000000000..9abc7fd75 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45678-1.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ +/* { dg-options "-fno-common" { target { { hppa*-*-hpux* } && { ! lp64 } } } } */ + +typedef float V __attribute__ ((vector_size (16))); +V g; +float d[4] = { 4, 3, 2, 1 }; + +int +main () +{ + V e; + __builtin_memcpy (&e, &d, sizeof (d)); + V f = { 5, 15, 25, 35 }; + e = e * f; + g = e; + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45678-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45678-2.c new file mode 100644 index 000000000..037fc2a52 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45678-2.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ +/* { dg-options "-fno-common" { target { { hppa*-*-hpux* } && { ! lp64 } } } } */ + +typedef float V __attribute__ ((vector_size (16))); +V g; + +int +main () +{ + float d[4] = { 4, 3, 2, 1 }; + V e; + __builtin_memcpy (&e, &d, sizeof (d)); + V f = { 5, 15, 25, 35 }; + e = e * f; + g = e; + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45704.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45704.c new file mode 100644 index 000000000..51456cec4 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45704.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-optimized" } */ +/* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } } */ + +struct st { + int ptr; +}; + +int foo(struct st *st) +{ + int v = *(volatile int *)&st->ptr; + return v & 0xff; +} + +/* { dg-final { scan-tree-dump-times "={v}" 1 "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45720.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45720.c new file mode 100644 index 000000000..9de8d1117 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45720.c @@ -0,0 +1,50 @@ +/* { dg-do run } */ +/* { dg-options "-ftree-vectorize" } */ + +float val[256]; +float x; +void __attribute__((noinline,noclone)) +foo(int len, int beg) +{ + int i; + for (i = len - 1; i >= beg; --i) + x += val[i] * 2; +} +void __attribute__((noinline,noclone)) +bar(void) +{ + int i; + for (i = 255; i >= 0; --i) + x += val[i] * 2; + for (i = 254; i >= 0; --i) + x += val[i] * 2; + for (i = 253; i >= 0; --i) + x += val[i] * 2; + for (i = 252; i >= 0; --i) + x += val[i] * 2; +} +float y[256]; +void __attribute__((noinline,noclone)) +foobar(void) +{ + int i; + for (i = 0; i < 252; ++i) + { + float l = 0; + l += val[255 - i] * 2; + l += val[254 - i] * 2; + l += val[253 - i] * 2; + l += val[252 - i] * 2; + y[i] = l; + } +} +int main() +{ + foo(256-1, 0); + foo(256-2, 0); + foo(256-3, 0); + foo(256-4, 0); + bar(); + foobar(); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45732.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45732.c new file mode 100644 index 000000000..04ceaa279 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45732.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ + +typedef char chars[5]; +const chars bad_chars[] = { "" }; + +int foo () +{ + const chars *c = bad_chars; + return c[0][0]; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45764.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45764.c new file mode 100644 index 000000000..ac8c075db --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45764.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-skip-if "Too much RAM needed" { "avr-*-*" } { "*" } { "" } } */ + +int result[64][16]; + +int main() +{ + double dbuf[1000] = {0.0}; + int ibuf[900]; + int i, j; + + double d1 = 0.0; + double d2 = 0.0; + for (i = 0; i < 900; ++i) { + ibuf[i] = (int)(d2 - d1); + d1 += dbuf[i]; + d2 += dbuf[i + 64]; + } + + for (i = 0; i < 64; ++i) { + for (j = 0; j < 8; ++j) { + result[i][ j] = ibuf[64 - i + 64 * j]; + result[i][15 - j] = ibuf[ i + 64 * j]; + } + } + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45830.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45830.c new file mode 100644 index 000000000..fe6294bb7 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45830.c @@ -0,0 +1,99 @@ +/* PR tree-optimization/45830 */ +/* { dg-do run } */ +/* { dg-additional-options "-fno-tree-switch-conversion" { target avr-*-* } } */ + +extern void abort (void); + +long long va, vb, vc, vd, ve; + +__attribute__((noinline)) int +foo (int x) +{ + long long a, b, c, d, e; + switch (x) + { + case 0: + case 3: + case 1: + case 2: + case 4: + a = 1; + b = 129; + c = -12; + d = -4; + e = 128; + break; + case 23: + case 26: + case 19: + case 65: + case 5: + a = 2; + b = 138; + c = 115; + d = 128; + e = -16; + break; + case 21: + case 20: + case 22: + case 38: + case 27: + case 66: + case 45: + case 47: + a = 3; + b = 6; + c = 127; + d = 25; + e = 257; + break; + default: + a = 0; + b = 18; + c = 0; + d = 64; + e = 32768L; + break; + } + va = a; + vb = b; + vc = c; + vd = d; + ve = e; +} + +int +bar (int x) +{ + if (x < 0) + return 3; + if (x < 5) + return 0; + if (x == 5 || x == 19 || x == 23 | x == 26 || x == 65) + return 1; + if ((x >= 20 && x <= 22) || x == 27 || x == 38 + || x == 45 || x == 47 || x == 66) + return 2; + return 3; +} + +long long expected[] = +{ 1, 129, -12, -4, 128, 2, 138, 115, 128, -16, + 3, 6, 127, 25, 257, 0, 18, 0, 64, 32768L }; + +int +main (void) +{ + int i, v; + for (i = -4; i < 70; i++) + { + foo (i); + v = bar (i); + if (va != expected[5 * v] || vb != expected[5 * v + 1] + || vc != expected[5 * v + 2] || vd != expected[5 * v + 3] + || ve != expected[5 * v + 4]) + abort (); + } + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45860.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45860.c new file mode 100644 index 000000000..4a48bc559 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45860.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ + +void +foo (char *str, int i) +{ + static const char text[] = ""; + str[i] = 0; + if (i & 1) + __builtin_strcpy (str + i, text); +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45865.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45865.c new file mode 100644 index 000000000..f2e31dbab --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45865.c @@ -0,0 +1,54 @@ +/* { dg-do compile } */ + +typedef struct rtx_def *rtx; +enum machine_mode { + VOIDmode, + CCFPmode, + CCFPUmode, + MAX_MACHINE_MODE +}; +enum mode_class { + MODE_CC, + MODE_FLOAT, + MODE_COMPLEX_FLOAT, + MODE_VECTOR_FLOAT +}; +extern const enum mode_class mode_class[(int) MAX_MACHINE_MODE]; +enum rtx_code { + UNKNOWN, + GEU, + ORDERED, + CONST_INT +}; +struct rtx_def { + unsigned int code: 16; + unsigned int mode : 8; +}; +extern enum rtx_code reverse_condition (enum rtx_code); +enum rtx_code +reversed_comparison_code_parts (enum rtx_code code, rtx insn, rtx arg0, + rtx arg1) +{ + enum machine_mode mode; + mode = (enum machine_mode) (arg0)->mode; + if (mode == VOIDmode) + mode = (enum machine_mode) (arg1)->mode; + if ((mode_class[(int) (mode)]) == MODE_CC) + return (mode != CCFPmode && mode != CCFPUmode + ? reverse_condition (code) + : reverse_condition_maybe_unordered (code)); + switch (code) + { + case GEU: + return reverse_condition (code); + case ORDERED: + return UNKNOWN; + } + if (((enum rtx_code) (arg0)->code) == CONST_INT + || (((enum machine_mode) (arg0)->mode) != VOIDmode + && ! ((mode_class[(int) (mode)]) == MODE_FLOAT + || (mode_class[(int) (mode)]) == MODE_COMPLEX_FLOAT + || (mode_class[(int) (mode)]) == MODE_VECTOR_FLOAT))) + return reverse_condition (code); + return UNKNOWN; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45869.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45869.c new file mode 100644 index 000000000..e01977bf9 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45869.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +char * +foo (unsigned int count, void **list) +{ + char *minaddr = (char *) list[0]; + unsigned int i; /* NOTE: change of type to "int" eliminates the ICE */ + for (i = 1; i < count; i++) + { + char *addr = (char *) list[i]; + if (addr < minaddr) + minaddr = addr; + } + return minaddr; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45967-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45967-2.c new file mode 100644 index 000000000..6959fd5e1 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45967-2.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ + +extern void abort (void); +int b; +void +foo (void *p_, int *q) +{ + int *p; + int i; + for (i = 0; i < sizeof(int *); ++i) + ((char *)&p)[i] = ((char *)p_)[i]; + if (b) + p = q; + *p = 1; +} +int main() +{ + int i = 0, j; + int *p = &i; + foo (&p, &j); + if (i != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45967-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45967-3.c new file mode 100644 index 000000000..1a23a773b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45967-3.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ + +extern void abort (void); +void +foo (void *p_) +{ + int *p; + int i; + for (i = 0; i < sizeof(int *); ++i) + ((char *)&p)[i] = ((char *)p_)[i]; + *p = 1; +} +int main() +{ + int i = 0; + int *p = &i; + foo (&p); + if (i != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45967.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45967.c new file mode 100644 index 000000000..0a5b206e5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45967.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ + +extern void abort (void); +void __attribute__((noinline,noclone)) +foo (void *p_) +{ + int *p; + int i; + for (i = 0; i < sizeof(int *); ++i) + ((char *)&p)[i] = ((char *)p_)[i]; + *p = 1; +} +int main() +{ + int i = 0; + int *p = &i; + foo (&p); + if (i != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45982.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45982.c new file mode 100644 index 000000000..4aea6a8d8 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr45982.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-options "-std=c99" } */ + +#include <stdint.h> + +extern void abort (void); + +uintptr_t __attribute__((pure,noinline,noclone)) +foo (int *a) +{ + return (uintptr_t) a; +} + +void __attribute__((noinline,noclone)) +bar (uintptr_t a) +{ + int *p = (int *)a; + *p = 1; +} + +int main() +{ + int t = 0; + bar (foo (&t)); + if (t != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr46068.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr46068.c new file mode 100644 index 000000000..120119ce8 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr46068.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ + +void +foo () +{ + asm goto (""::::l1); + __builtin_unreachable (); +l1:; +} + +void +bar () +{ + foo (); + foo (); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr46172.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr46172.c new file mode 100644 index 000000000..c8d1b4759 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr46172.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-tree-dce -ftree-vectorize" } */ + +extern short X[]; + +int foo (int len) +{ + int i; + int s = 0; + for (i = 0; i < len; i++) + s += X[i] * X[i]; + return s; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr46183.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr46183.c new file mode 100644 index 000000000..9582c34e0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr46183.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-dse" } */ + +void bar(void); + +void foo (int i, ...) +{ + __builtin_va_list ap; + __builtin_va_start (ap, i); + __builtin_va_arg (ap, int); + while (i) i++; + __builtin_va_arg (ap, int); + while (i) i++; + __builtin_va_arg (ap, int); + while (i) i++; + __builtin_va_arg (ap, int); + if (i) + bar (); +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr46216.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr46216.c new file mode 100644 index 000000000..b257dbf2c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr46216.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ + +typedef int Embryo_Cell; +int +embryo_program_run(Embryo_Cell *cip) +{ + unsigned char op; + Embryo_Cell offs; + static const void *switchtable[256] = { + &&SWITCHTABLE_EMBRYO_OP_NONE, &&SWITCHTABLE_EMBRYO_OP_LOAD_PRI + }; + for (;;) + { + op = *cip++; + while (1) { + goto *switchtable[op]; +SWITCHTABLE_EMBRYO_OP_LOAD_PRI: + offs = *(Embryo_Cell *)cip++; +SWITCHTABLE_EMBRYO_OP_NONE: + break; + }; + } + return offs; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr46398.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr46398.c new file mode 100644 index 000000000..9110bbbbe --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr46398.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ + +int __attribute__((noinline)) +test (int token) +{ + int done = 0; + int virtual_p = 0; + while (!done) + { + if (token == 42) + virtual_p = 1; + else + done = 1; + } + return virtual_p; +} +extern void abort (void); +int +main() +{ + if (test (0) != 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr46723.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr46723.c new file mode 100644 index 000000000..40c6e8cd6 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr46723.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ + +short *m; +void test() +{ + short x = 128; + unsigned int i; + for (i = 0; i < 128; ++i, x = (unsigned short)x + 1) + m[i] = x; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47228.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47228.c new file mode 100644 index 000000000..4ee7cab4d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47228.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ +/* { dg-require-effective-target int32plus } */ + +struct S4 +{ + unsigned f0:24; +} __attribute__((__packed__)); + +struct S4 g_10 = { + 6210831 +}; + +struct S4 func_2 (int x) +{ + struct S4 l_8[2] = { + {0}, {0} + }; + g_10 = l_8[1]; + for (; x<2; x++) { + struct S4 tmp = { + 11936567 + }; + l_8[x] = tmp; + } + return g_10; +} + +int main (void) +{ + func_2 (0); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47278-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47278-1.c new file mode 100644 index 000000000..f97906c61 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47278-1.c @@ -0,0 +1,5 @@ +/* { dg-do run } */ +/* { dg-require-visibility "" } */ +/* { dg-additional-sources "pr47278-2.c" } */ + +int foo (void) { return 1; } diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47278-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47278-2.c new file mode 100644 index 000000000..0c700d196 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47278-2.c @@ -0,0 +1,15 @@ +/* { dg-require-visibility "" } */ + +extern void abort (void); + +int __attribute__((weak,visibility("hidden"))) foo (void) +{ + return 0; +} + +int main() +{ + if (foo() != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47281.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47281.c new file mode 100644 index 000000000..517e8548e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47281.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ + +struct T; +typedef void F(void); + +F* aux(void (*x)()) +{ + return x; +} + +void make_mess (int); + +F* +get_funloc (void (*x)(int), F* (*y)()) +{ + return y(x); +} + +F* +foo () +{ + return get_funloc (make_mess, aux); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47364-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47364-1.c new file mode 100644 index 000000000..3ac699974 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47364-1.c @@ -0,0 +1,8 @@ +/* { dg-do run } */ + +char one[50] = "ijk"; +int +main (void) +{ + return __builtin_strlen (one) != 3; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47365.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47365.c new file mode 100644 index 000000000..e3bc55011 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47365.c @@ -0,0 +1,39 @@ +/* { dg-do run } */ + +struct A +{ + int i; +}; + +struct B +{ + struct A a[2]; +}; + +int i = 1; +struct B b = { 0, 3 }; + +static void +test () +{ + if (b.a[0].i != i) + { + int t = b.a[0].i; + b.a[0] = b.a[1]; + b.a[1].i = t; + } + + if (b.a[1].i == i) + __builtin_abort (); + + if (b.a[0].i == 0) + __builtin_abort (); +} + +int +main () +{ + test (); + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47370.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47370.c new file mode 100644 index 000000000..ff71f0964 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47370.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ + +struct S { int s; }; + +void +foo (void) +{ + for (;;) + ; +} + +struct S +bar (void) +{ + struct S s = { 99 }; + return s; +} + +void +baz (int i) +{ + struct S s[1]; + s[0] = bar (); + bar (); + foo (); +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47383.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47383.c new file mode 100644 index 000000000..ae8d67051 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47383.c @@ -0,0 +1,30 @@ +/* { dg-do run } */ + +static int heap[2*(256 +1+29)+1]; +static int heap_len; +static int heap_max; +void +__attribute__ ((noinline)) +foo (int elems) +{ + int n, m; + int max_code = -1; + int node = elems; + heap_len = 0, heap_max = (2*(256 +1+29)+1); + for (n = 0; n < elems; n++) + heap[++heap_len] = max_code = n; + do { + n = heap[1]; + heap[1] = heap[heap_len--]; + m = heap[1]; + heap[--heap_max] = n; + heap[--heap_max] = m; + } while (heap_len >= 2); +} + +int +main () +{ + foo (286); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47411.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47411.c new file mode 100644 index 000000000..d3c10d331 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47411.c @@ -0,0 +1,42 @@ +/* { dg-do compile } */ + +typedef long unsigned int size_t; + +static __inline void * +__inline_memcpy_chk (void *__dest, const void *__src, size_t __len) +{ + return __builtin___memcpy_chk (__dest, __src, __len, __builtin_object_size (__dest, 0)); +} + +extern void *xmalloc (size_t) __attribute__ ((__malloc__)); + +struct htab { void ** entries; }; + +typedef struct htab *htab_t; + +extern void ** htab_find_slot (htab_t, const void *); + +enum mode_class { MODE_RANDOM, MODE_CC, MODE_INT, MAX_MODE_CLASS }; + +struct mode_data +{ + struct mode_data *next; + enum mode_class cl; +}; + +static const struct mode_data blank_mode = { 0, MAX_MODE_CLASS }; + +static htab_t modes_by_name; + +struct mode_data * +new_mode (void) +{ + struct mode_data *m + = ((struct mode_data *) xmalloc (sizeof (struct mode_data))); + + ((__builtin_object_size (m, 0) != (size_t) -1) ? __builtin___memcpy_chk (m, &blank_mode, sizeof (struct mode_data), __builtin_object_size (m, 0)) : __inline_memcpy_chk (m, &blank_mode, sizeof (struct mode_data))); + + *htab_find_slot (modes_by_name, m) = m; + + return m; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47426-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47426-1.c new file mode 100644 index 000000000..47dcff913 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47426-1.c @@ -0,0 +1,23 @@ +/* { dg-do run } */ +/* { dg-options "-fipa-pta" } */ +/* { dg-additional-sources "pr47426-2.c" } */ + +void bar (int *i); + +static void +foo (int *i) +{ + if (*i) + bar (i); + if (*i) + __builtin_abort(); +} + +typedef void tfoo (int *); + +tfoo * +getfoo (void) +{ + return &foo; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47426-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47426-2.c new file mode 100644 index 000000000..a22e902bc --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47426-2.c @@ -0,0 +1,19 @@ +typedef void tfoo (int *); +tfoo *getfoo (void); + +void +bar (int *i) +{ + (*i)--; +} + +int +main () +{ + int i = 1; + getfoo ()(&i); + if (i) + __builtin_abort (); + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47473.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47473.c new file mode 100644 index 000000000..92f2b872e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47473.c @@ -0,0 +1,14 @@ +/* PR c/47473 */ +/* { dg-do run } */ +/* { dg-options "-std=c99" } */ + +int +main (void) +{ + long double _Complex w = 0.2L - 0.3iL; + w = w * (0.3L - (0.0F + 1.0iF) * 0.9L); + if (__builtin_fabsl (__real__ w + 0.21L) > 0.001L + || __builtin_fabsl (__imag__ w + 0.27L) > 0.001L) + __builtin_abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47621.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47621.c new file mode 100644 index 000000000..882e67f08 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47621.c @@ -0,0 +1,14 @@ +/* { dg-do run } */ + +extern void abort (void); + +int +main (void) +{ + int data = 1; + struct ptr { int val; } *ptr = (struct ptr *) &data; + ptr->val = 0; + if (data != 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47677.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47677.c new file mode 100644 index 000000000..bd9077863 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47677.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ + +struct S { int s; int u; }; +extern int bar (void); +extern struct S *baz (void); + +void +foo (int x, struct S *y, char z, int *v, struct S *s) +{ + int c, d; + if (x & 2) + d = 1; + else + { + d = (x & 1) ? 11 : 0; + while ((c = (s->s != (s->u & 1) ? s->s : bar ())) != '\0'); + c = (s->s != '\\' && (s->u & 4) ? s->s : bar ()); + if (c == '<') + goto lab; + } + while ((c = ((s->u & 1) ? s->s : bar ())) != 0 + && ((d != 11 && d != 17) || (v[c] & 1) == 0)) + { + lab:; + switch (d) + { + case 14: + if (c == '}') + y = baz (); + d = y->s = z == '<' ? 17 : 11; + } + } +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47725.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47725.c new file mode 100644 index 000000000..03d5d36c3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47725.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ + +struct _Unwind_Context +{ + void *reg[17]; + void *ra; +}; +extern void bar (struct _Unwind_Context *); +void +__frame_state_for (void *pc_target) +{ + struct _Unwind_Context context; + __builtin_memset (&context, 0, sizeof (struct _Unwind_Context)); + context.ra = pc_target; + bar (&context); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47743.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47743.c new file mode 100644 index 000000000..1930e94d2 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47743.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ + +int +foo (void *x, int y) +{ + long long a = 1, *b; + double *c; + if (y) + { + b = (long long *) x; + while (b) + a *= *b++; + } + else + { + c = (double *) x; + while (c) + a *= *c++; + } + return a; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47744-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47744-1.c new file mode 100644 index 000000000..0f7efa9f0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47744-1.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-fpic" { target fpic } } */ + +typedef int int32_t; +static const int init_jk[] = {2,3,4,6}; + int __kernel_rem_pio2(double *x, double *y, int e0, int nx, int prec, const int32_t *ipio2) +{ + int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih; + double z,fw,f[20],fq[20],q[20]; + jk = init_jk[prec]; + jp = jk; + jx = nx-1; + for (i=0;i<=jk;i++) { + for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw; + } + for(i=0,j=jz,z=q[jz];j>0;i++,j--) { + z = q[j-1]+fw; + } + n = (int32_t) z; + return n&7; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47744-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47744-2.c new file mode 100644 index 000000000..82f6151cb --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47744-2.c @@ -0,0 +1,40 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target int128 } */ +/* { dg-options "-std=gnu99" } */ + +typedef long unsigned int size_t; +typedef long int ssize_t; +typedef ssize_t index_type; +typedef __int128_t GFC_INTEGER_16; +typedef struct descriptor_dimension +{ + index_type _stride; + index_type _lbound; + index_type _ubound; +} +descriptor_dimension; +typedef struct { GFC_INTEGER_16 *data; size_t offset; index_type dtype; descriptor_dimension dim[7];} gfc_array_i16; +void +matmul_i16 (gfc_array_i16 * const restrict retarray, + gfc_array_i16 * const restrict a, + GFC_INTEGER_16 bbase_yn) +{ + GFC_INTEGER_16 * restrict dest; + index_type rxstride, rystride; + index_type x, y, n, count, xcount; + GFC_INTEGER_16 * restrict dest_y; + GFC_INTEGER_16 s; + const GFC_INTEGER_16 * restrict abase_n; + rxstride = ((retarray)->dim[0]._stride); + rystride = ((retarray)->dim[1]._stride); + xcount = ((a)->dim[0]._ubound + 1 - (a)->dim[0]._lbound); + dest = retarray->data; + dest_y = &dest[y*rystride]; + for (x = 0; x < xcount; x++) + dest_y[x] += abase_n[x] * bbase_yn; + for (x = 0; x < xcount; x++) + { + for (n = 0; n < count; n++) + dest_y[x*rxstride] = (GFC_INTEGER_16) 0; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47744-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47744-3.c new file mode 100644 index 000000000..5a5dd33e9 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47744-3.c @@ -0,0 +1,74 @@ +/* { dg-do compile } */ + +typedef union rtunion_def { + struct rtx_def *rtx; +} rtunion; +typedef struct rtx_def { + unsigned short code; + rtunion fld[1]; +} *rtx; +extern rtx recog_operand[]; +extern rtx *recog_operand_loc[]; +extern int reload_n_operands; +extern void find_dummy_reload (int, int); +extern int asm_noperands (rtx); +extern int n_occurrences (char **); +char operands_match[10][10]; +void find_reloads (rtx insn, int n_alternatives, int commutative) +{ + register int i, j; + int noperands; + char *constraints[10]; + int address_reloaded[10]; + int this_alternative[10]; + char this_alternative_win[10]; + int this_alternative_matches[10]; + int this_alternative_number; + rtx body = ((insn)->fld[3].rtx); + int operand_mode[10]; + if (body->code == 1) + { + reload_n_operands = noperands = asm_noperands (body); + n_alternatives = n_occurrences (constraints); + } + for (this_alternative_number = 0; + this_alternative_number < n_alternatives; + this_alternative_number++) + for (i = 0; + i < noperands; + i++) + { + register char *p = constraints[i]; + register int win = 0; + int badop = 1; + int c; + register rtx operand = recog_operand[i]; + int force_reload = 0; + this_alternative_win[i] = 0; + this_alternative[i] = 1; + while (*p && (c = *p++) != ',') + switch (c) + { + case '4': + c -= '0'; + this_alternative_matches[i] = c; + if ((c != commutative + || i != commutative + 1) + && operands_match[c][i]) + win = this_alternative_win[c]; + else + find_dummy_reload (operand_mode[i], this_alternative[c]); + if (! win || force_reload) + for (j = 0; j < i; j++) + if (this_alternative_matches[j] + == this_alternative_matches[i]) + badop = 1; + break; + case '<': + if (operand->code == 2 + && ! address_reloaded[i] + && operand->fld[0].rtx->code == 3) + win = 1; + } + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47890.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47890.c new file mode 100644 index 000000000..83cb5e6d9 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47890.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ + +void f(char *s) +{ + signed short i; + + for (i = 0; i < 19; i = i + 1) + s[i] = i; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47917.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47917.c new file mode 100644 index 000000000..f89d44987 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47917.c @@ -0,0 +1,40 @@ +/* { dg-do run } */ +/* { dg-options "-std=c99" } */ +/* { dg-options "-std=c99 -D_XOPEN_SOURCE=500" { target *-*-solaris2.9 } } */ +/* { dg-options "-std=gnu99" { target *-*-hpux* } } */ +/* { dg-additional-options "-D__USE_MINGW_ANSI_STDIO=1" { target *-*-mingw* } } */ +/* { dg-xfail-run-if "no C99 snprintf function" { *-*-hpux10* } } */ +/* { dg-xfail-run-if "non-conforming C99 snprintf" { *-*-hpux11.[012]* } } */ + +/* PR middle-end/47917 */ + +#include <stdio.h> +extern int memcmp (const void *, const void *, __SIZE_TYPE__); +extern void abort (void); + +char buf1[6], buf2[6], buf3[4], buf4[4]; +int i; + +int +foo (void) +{ + int ret = snprintf (buf1, sizeof buf1, "abcde"); + ret += snprintf (buf2, sizeof buf2, "abcdef") * 16; + ret += snprintf (buf3, sizeof buf3, "%s", i++ < 6 ? "abc" : "def") * 256; + ret += snprintf (buf4, sizeof buf4, "%s", i++ > 10 ? "abcde" : "defgh") * 4096; + return ret; +} + +int +main (void) +{ + if (foo () != 5 + 6 * 16 + 3 * 256 + 5 * 4096) + abort (); + if (memcmp (buf1, "abcde", 6) != 0 + || memcmp (buf2, "abcde", 6) != 0 + || memcmp (buf3, "abc", 4) != 0 + || memcmp (buf4, "def", 4) != 0 + || i != 2) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47958-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47958-1.c new file mode 100644 index 000000000..9fdf142fc --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47958-1.c @@ -0,0 +1,13 @@ +/* { dg-do assemble } */ + +void (*foo[6][6]) (int); +void bar (hdR) + int hdR; +{ } +void xxx () +{ + unsigned int i, j; + for (i = 0; i < 6; ++i) + for (j = 0; j < 6; ++j) + foo [i][j] = bar; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47968.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47968.c new file mode 100644 index 000000000..4f33cf1f3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47968.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-w -Wno-psabi" } */ + +typedef __attribute__ ((vector_size (16))) float float4; +typedef __attribute__ ((vector_size (16))) double double2; + +float foo (double2 d2) +{ + float4 f4 = (float4) d2; + return *(float *) &f4; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47975.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47975.c new file mode 100644 index 000000000..e2a72af49 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr47975.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-common" { target { hppa*-*-hpux* } } } */ + +int __attribute__ ((vector_size (32))) x; + +void +foo (void) +{ + x <<= x; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48044.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48044.c new file mode 100644 index 000000000..d20a634a1 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48044.c @@ -0,0 +1,11 @@ +/* PR middle-end/48044 */ +/* { dg-do compile } */ +/* { dg-require-alias "" } */ + +#define ASMNAME(cname) ASMNAME2 (__USER_LABEL_PREFIX__, cname) +#define ASMNAME2(prefix, cname) STRING (prefix) cname +#define STRING(x) #x + +int a __asm__ (ASMNAME ("b")) = 0; +extern int c __asm__ (ASMNAME ("a")) __attribute__ ((alias ("b"))); +extern int d __attribute__ ((weak, alias ("a"))); diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48063.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48063.c new file mode 100644 index 000000000..d861bf04c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48063.c @@ -0,0 +1,19 @@ +/* PR tree-optimization/48063 */ +/* { dg-do compile } */ +/* { dg-options "-fno-early-inlining" } */ + +extern void abort (void); +static void bar (); + +void +foo () +{ + bar (1); +} + +static void +bar (double i) +{ + if (i) + abort (); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48098.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48098.c new file mode 100644 index 000000000..cd7293937 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48098.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ + +void +foo (int n) +{ + static char *__restrict *p; + int i; + p = __builtin_malloc (n); + for (i = 0; i < n; i++) + p[i] = 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48124-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48124-1.c new file mode 100644 index 000000000..a0c73bf59 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48124-1.c @@ -0,0 +1,34 @@ +/* { dg-do run } */ +/* { dg-options "-fno-toplevel-reorder" } */ +/* { dg-require-effective-target int32plus } */ + +extern void abort (void); + +struct S +{ + signed a : 26; + signed b : 16; + signed c : 10; + volatile signed d : 14; +}; + +static struct S e = { 0, 0, 0, 1 }; +static int f = 1; + +void __attribute__((noinline)) +foo (void) +{ + e.d = 0; + f = 2; +} + +int +main () +{ + if (e.a || e.b || e.c || e.d != 1 || f != 1) + abort (); + foo (); + if (e.a || e.b || e.c || e.d || f != 2) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48124-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48124-2.c new file mode 100644 index 000000000..485d8d4b5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48124-2.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ + +extern void abort (void); + +static volatile struct S0 { + short f3[9]; + unsigned f8 : 15; +} s = {1}; +static unsigned short sh = 0x1234; + +struct S0 a, b; +int vi = 0; + +void func_4() +{ + s.f8 |= 1; + sh = 15; + if (vi) a = b; +} + +int main() +{ + func_4(); + if (sh != 15) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48124-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48124-3.c new file mode 100644 index 000000000..386d88bd9 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48124-3.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ + +extern void abort (void); +struct S1 +{ + int f0; + int:1; + int f3; + int:1; + int:0; + int f6:1; +}; +int g_13 = 1; +volatile struct S1 g_118 = { + 1 +}; + +void __attribute__((noinline)) +func_46 () +{ + for (g_13 = 0; g_13 >= 0; g_13 -= 1) + g_118.f6 = 0; +} + +int +main () +{ + func_46 (); + if (g_13 != -1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48124-4.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48124-4.c new file mode 100644 index 000000000..fe9f97efc --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48124-4.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ +/* { dg-require-effective-target int32plus } */ + +extern void abort (void); +struct S1 { + unsigned f0, f1; + unsigned short f2, f3; + unsigned f4 : 16; + unsigned f5, f6; + volatile unsigned f7 : 28; +}; +static struct S1 g_76; +static struct S1 g_245 = {0,0,0,0,0,0,0,1}; +static signed char g_323 = 0x80; +static void func_1(void) +{ + g_245.f7 &= 1; + for (g_323 = 0; g_323 <= -1; g_323 -= 2) { + g_76 = g_76; + g_76.f4 ^= 11; + } +} +int main() +{ + func_1(); + if (g_323 != 0 || g_245.f7 != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48146.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48146.c new file mode 100644 index 000000000..c04903528 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48146.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target int32plus } */ + +static unsigned char +safe_sub_func_int_s_s (int si1, unsigned char si2) +{ + return si1 ^ si2 & -si2 ^ si2 ? : si1 - si2; +} + +int g_2[10] = { + 0x90AC204EL +}; + +volatile unsigned char g_39; + +unsigned char +func_67 (unsigned short p_68) +{ + unsigned char l_92; + unsigned char l_74; + int *l = &g_2[6]; +lbl_90:*l ^= 1; + if (p_68) + goto lbl_93; + for (l_74 = 0;; l_74 = safe_sub_func_int_s_s (l_74, 1)) + { + if (l_74) + goto lbl_90; +lbl_93:l_92 ^= 0 != &g_39; + if (0) + { + } + else + *l = 1; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48343.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48343.c new file mode 100644 index 000000000..e56b3a3da --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48343.c @@ -0,0 +1,19 @@ +/* PR debug/48343 */ +/* { dg-do compile } */ +/* { dg-options "-fcompare-debug" } */ + +void foo (unsigned char *, unsigned char *); + +void +test (unsigned int x, int y) +{ + unsigned int i, j = 0, k; + unsigned char s[256], t[64]; + foo (s, t); + t[0] = y; + for (i = 0; i < 256; i++) + { + j = (j + s[i] + t[i % x]) & 0xff; + k = i; i = j; j = k; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48493.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48493.c new file mode 100644 index 000000000..ddb61f2e0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48493.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ + +typedef long long T __attribute__((may_alias, aligned (1))); + +struct S +{ + _Complex float d __attribute__((aligned (8))); +}; + +void bar (struct S); + +void +f1 (T x) +{ + struct S s; + *(T *) ((char *) &s.d + 1) = x; + bar (s); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48542.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48542.c new file mode 100644 index 000000000..e3e49489f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48542.c @@ -0,0 +1,57 @@ +/* { dg-do run } */ +/* The return-address was clobbered. */ +#include <stdlib.h> +#include <setjmp.h> + +jmp_buf env; +extern void sub(void); +extern void sub3(void); +int called; +__attribute__ ((__noinline__)) +int sjtest() +{ + int i; + if (setjmp(env)) + return 99; + + for (i = 0; i < 10; i++) + sub(); + + longjmp(env, 1); +} + +__attribute__ ((__noinline__)) +void sub(void) +{ + called++; +} + +int called3; +__attribute__ ((__noinline__)) +int sjtest3() +{ + int i; + if (setjmp(env)) + return 42; + + for (i = 0; i < 10; i++) + sub3(); + return 0; +} + +__attribute__ ((__noinline__)) +void sub3(void) +{ + called3++; + if (called3 == 10) + longjmp (env, 1); +} + +int main(void) +{ + if (sjtest() != 99 || called != 10) + abort(); + if (sjtest3() != 42 || called3 != 10) + abort(); + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48694-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48694-1.c new file mode 100644 index 000000000..810366bc8 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48694-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ + +extern volatile int g_89[5][9]; +extern int g, *gp; +void func_64() +{ + int i; + for (i = 0; i < 1; ) + { + for (g = 0; g < 1; ) + return; + gp = (int *)&g_89[g][0]; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48694-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48694-2.c new file mode 100644 index 000000000..4791ac3f7 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48694-2.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +extern volatile int g_4[1][4]; +extern int g_7; +void modify(int *); +void func_2() +{ + int l_46 = 4; + if (g_7) + modify(&l_46); + else + { + int i; + for (i = 0; i != 5; i += 1) + { + volatile int *vp = &g_4[0][l_46]; + *vp = 0; + } + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48702.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48702.c new file mode 100644 index 000000000..1ec371da8 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48702.c @@ -0,0 +1,47 @@ +/* { dg-do run } */ + +extern void abort (void); + +#define LEN 4 + +static inline void unpack(int array[LEN]) +{ + int ii, val; + val = 1; + for (ii = 0; ii < LEN; ii++) { + array[ii] = val % 2; + val = val / 2; + } +} + +static inline int pack(int array[LEN]) +{ + int ans, ii; + ans = 0; + for (ii = LEN-1; ii >= 0; ii--) { + ans = 2 * ans + array[ii]; + } + return ans; +} + +int __attribute__((noinline)) +foo() +{ + int temp, ans; + int array[LEN]; + unpack(array); + temp = array[0]; + array[0] = array[2]; + array[2] = temp; + ans = pack(array); + return ans; +} + +int main(void) +{ + int val; + val = foo(); + if (val != 4) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48731.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48731.c new file mode 100644 index 000000000..74b77f67c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48731.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ + +#include <stdarg.h> + +int blah(int a, ...) +{ + va_list va; + va_start(va,a); + if (a == 0) + return -1; + else + { + int i; + for (i = 0; i < a; i++) + va_arg(va,int); + return va_arg(va,int); + } +} + +__attribute((flatten)) +int blah2(int b, int c) +{ + return blah(2, b, c); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48822.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48822.c new file mode 100644 index 000000000..b619f369b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48822.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +void foo (int *, int *); +int bar () +{ + int a = 0; + int b = 0; + if (b != 0) + { + int ax = a; + int bx = b; + while (bx != 0) + { + int tem = ax % bx; + ax = bx; + bx = tem; + } + } + foo (&a, &b); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48953.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48953.c new file mode 100644 index 000000000..41a3d7b80 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr48953.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ +/* { dg-options "-fno-tree-dce" } */ + +static inline int foo (int n, int k) +{ + struct S + { + int i[n]; + int value; + } s[2]; + return s[k].value = 0; +} + +int main () +{ + return foo (2, 0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49030.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49030.c new file mode 100644 index 000000000..edd0c3629 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49030.c @@ -0,0 +1,21 @@ +/* { dg-require-effective-target int32plus } */ + +void +sample_move_d32u24_sS (char *dst, float *src, unsigned long nsamples, + unsigned long dst_skip) +{ + long long y; + while (nsamples--) + { + y = (long long) (*src * 8388608.0f) << 8; + if (y > 2147483647) { + *(int *) dst = 2147483647; + } else if (y < -2147483647 - 1) { + *(int *) dst = -2147483647 - 1; + } else { + *(int *) dst = (int) y; + } + dst += dst_skip; + src++; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49079.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49079.c new file mode 100644 index 000000000..1b53d3c31 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49079.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +extern void abort (void); + +struct Ustr +{ + unsigned char data[1]; +}; + +static unsigned int +ustr_xi__embed_val_get(const unsigned char *data) +{ + return (unsigned int)data[0]; +} + +int __attribute__((noinline)) zero(void) { return 0; } + +static unsigned int +ustr_len(const struct Ustr *s1) +{ + return ustr_xi__embed_val_get(s1->data + 1 + zero()); +} + +int +main() +{ + if (ustr_len (((struct Ustr *) "\x01" "\x0002" "s2")) != 2) + abort (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49169.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49169.c new file mode 100644 index 000000000..c7800bb75 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49169.c @@ -0,0 +1,15 @@ +/* { dg-do compile { target { arm*-*-* || mips*-*-* } } } */ + +#include <stdlib.h> +#include <stdint.h> + +int +main (void) +{ + void *p = main; + if ((intptr_t) p & 1) + abort (); + return 0; +} + +/* { dg-final { scan-assembler "abort" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49217.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49217.c new file mode 100644 index 000000000..e8a89de8f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49217.c @@ -0,0 +1,26 @@ +/* { dg-do run } */ +/* { dg-options "-fno-early-inlining" } */ + +extern void abort (void); +int i; +static void foo(void); +void __attribute__((noinline)) +bar (void) +{ + if (!i) + foo (); +} +static void +foo(void) +{ + i = 1; + bar (); +} +int main() +{ + i = 0; + bar(); + if (i != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49518.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49518.c new file mode 100644 index 000000000..55761fd61 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49518.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-Wno-aggressive-loop-optimizations" } */ + +int a, b; +struct S { unsigned int s, t, u; } c, d = { 0, 1, 0 }; + +void +test (unsigned char z) +{ + char e[] = {0, 0, 0, 0, 1}; + for (c.s = 1; c.s; c.s++) + { + b = e[c.s]; + if (a) + break; + b = z >= c.u; + if (d.t) + break; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49603.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49603.c new file mode 100644 index 000000000..90f51e505 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49603.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ + +struct gl_visual { + float AlphaScale; +}; +struct gl_context { + struct gl_visual *Visual; +}; +void quickdraw_rgb( struct gl_context * ctx, + int width, int height) +{ + int i, j; + unsigned char alpha[1600]; + for (j=0; j<width; j++) + alpha[j] = (int) ctx->Visual->AlphaScale; + for (i=0; i<height; i++) + foo( alpha); +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49651.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49651.c new file mode 100644 index 000000000..c58fe943c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49651.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +extern void abort (void); + +struct X { + int *p; + int *q; +}; + +void __attribute__((noinline, noclone)) +foo (struct X x) { *x.q = 0; } + +volatile int what; +struct X y; + +int main() +{ + int i, j; + struct X x, *p; + x.p = &i; + x.q = &j; + if (what) + p = &y; + else + p = &x; + j = 1; + foo (*p); + if (j != 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49958.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49958.c new file mode 100644 index 000000000..de689bcde --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49958.c @@ -0,0 +1,11 @@ +/* { dg-do run } */ +/* { dg-options "-fstrict-overflow" } */ + +extern void abort (void); +int foo (int i, int j, int o, int m) { return i*o + 1 + j*m > 1; } +int main() +{ + if (foo (- __INT_MAX__ - 1, -1, 1, 1)) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49997.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49997.c new file mode 100644 index 000000000..4ccc60473 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr49997.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-finline-functions -fnon-call-exceptions" } */ + +extern int g_78, g_223; +static int MOD(int si1, int si2) { + return (!si2 || (!si1 && si2)) ? si1 : (si1 % 3); +} +void func_65(int p_66) { + g_78 = MOD(p_66, 3); +} +void func_54(int si1) { + func_65(0); + func_65(1); + func_65(2); + while (g_223) { + MOD(si1, 3); + func_65(3); + func_65(4); + func_65(5); + func_65(6); + func_65(7); + func_65(8); + } +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50067-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50067-1.c new file mode 100644 index 000000000..8201ebfdc --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50067-1.c @@ -0,0 +1,23 @@ +/* { dg-do run } */ + +/* Make sure data-dependence analysis does not compute a bogus + distance vector for the different sized accesses. */ + +extern int memcmp(const void *, const void *, __SIZE_TYPE__); +extern void abort (void); +short a[32] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 }; +short b[32] = { 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, }; +int main() +{ +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + int i; + if (sizeof (short) == 2) + { + for (i = 0; i < 32; ++i) + (*((unsigned short(*)[32])&a[0]))[i] = (*((char(*)[32])&a[0]))[i+8]; + if (memcmp (&a, &b, sizeof (a)) != 0) + abort (); + } +#endif + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50067-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50067-2.c new file mode 100644 index 000000000..f9728a766 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50067-2.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ + +/* Make sure data-dependence analysis does not compute a bogus + distance vector for the different sized accesses. */ + +extern int memcmp(const void *, const void *, __SIZE_TYPE__); +extern void abort (void); +short a[32] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 }; +short b[32] = { 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, }; +int main() +{ +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + int i; + if (sizeof (short) == 2) + { + for (i = 0; i < 32; ++i) + { + a[i] = (*((char(*)[32])&a[0]))[i+8]; + } + if (memcmp (&a, &b, sizeof (a)) != 0) + abort (); + } +#endif + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50067-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50067-3.c new file mode 100644 index 000000000..b774ea3f8 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50067-3.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-fpredictive-commoning" } */ + +extern void abort (void); +int a[6] = { 0, 0, 0, 0, 7, 0 }; +static int *p = &a[4]; + +int +main () +{ + int i; + for (i = 0; i < 4; ++i) + { + a[i + 1] = a[i + 2] > i; + *p &= ~1; + } + if (a[4] != 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50067-4.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50067-4.c new file mode 100644 index 000000000..1571d72f1 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50067-4.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ + +/* Verify we do not get a bogus access function with 0B vs. 1B which + disambiguates both accesses and leads to vectorization. */ + +extern int memcmp(const void *, const void *, __SIZE_TYPE__); +extern void abort (void); +short a[33] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 }; +short b[33] = { 0, }; +int main() +{ +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + int i; + if (sizeof (short) == 2) + { + for (i = 0; i < 64; ++i) + { + (*((char(*)[])&a[1]))[i] = (*((char(*)[])&a[0]))[i+1]; + } + if (memcmp (&a, &b, sizeof (a)) != 0) + abort (); + } +#endif + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50067-5.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50067-5.c new file mode 100644 index 000000000..13ed73fe4 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50067-5.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ + +/* Verify we do not get a bogus access function pairs with + exchanged dimensions, 0, {1, +, 1}_1 vs. {2B, +, 1}_1, 0 which + disambiguates both accesses and leads to vectorization. */ + +extern int memcmp(const void *, const void *, __SIZE_TYPE__); +extern void abort (void); +short a[33] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 }; +short b[33] = { 0, }; +char * volatile ap_ = (char *)&a[0]; +int main() +{ +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + int i; + char *ap = ap_; + if (sizeof (short) == 2) + { + for (i = 0; i < 64; ++i) + { + (*((char(*)[])&ap[i+2]))[0] = (*((char(*)[])&ap[0]))[i+1]; + } + if (memcmp (&a, &b, sizeof (a)) != 0) + abort (); + } +#endif + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50092.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50092.c new file mode 100644 index 000000000..c8a929b2c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50092.c @@ -0,0 +1,15 @@ +/* PR target/50092 */ +/* { dg-do compile { target lp64 } } */ + +volatile int v; + +void bar (long double); +void baz (_Complex long double *); + +void +foo (void) +{ + _Complex long double w[100000000]; + bar ((long double) v / 2147483648.0); + baz (w); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50222.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50222.c new file mode 100644 index 000000000..f534d8960 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50222.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-funswitch-loops -ftree-loop-distribution" } */ + +typedef struct AVProgram { + void *priv_data; + unsigned int nb_streams; +} AVFormatContext; +typedef struct { + unsigned short flags; + unsigned char stream_id; +} FrameCode; +typedef struct { + FrameCode frame_code[256]; +} NUTContext; +void build_frame_code(AVFormatContext *s, int stream_id, + int is_audio, int pred_count) +{ + NUTContext *nut = s->priv_data; + int keyframe_0_esc = s->nb_streams > 2; + int start2 = 1 + 253*stream_id / s->nb_streams; + int key_frame; + for(key_frame=0; key_frame<2; key_frame++) + { + FrameCode *ft; + if (is_audio && keyframe_0_esc && key_frame==0) + continue; + ft= &nut->frame_code[start2]; + ft->flags|= 3; + ft->stream_id= stream_id; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50287.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50287.c new file mode 100644 index 000000000..1f61293a5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50287.c @@ -0,0 +1,109 @@ +/* { dg-do compile } */ + +struct PMC { + unsigned flags; +}; + +struct PVC { + unsigned flags, other_stuff; +}; + + +typedef struct Pcc_cell +{ + struct PMC *p; + long bla; + long type; +} Pcc_cell; + +int gi; +int cond; + +struct PVC g_pvc; + +extern void abort (); +extern void never_ever(int interp, struct PMC *pmc) + __attribute__((noinline,noclone)); + +void never_ever (int interp, struct PMC *pmc) +{ + abort (); +} + +static void mark_cell(int * interp, Pcc_cell *c, struct PVC pvc) + __attribute__((__nonnull__(1))); + +static void +mark_cell(int * interp, Pcc_cell *c, struct PVC pvc) +{ + if (!cond) + return; + + if (c && c->type == 4 && c->p + && !(c->p->flags & (1<<8))) + never_ever(gi + 1, c->p); + if (c && c->type == 4 && c->p + && !(c->p->flags & (1<<7))) + never_ever(gi + 2, c->p); + if (c && c->type == 4 && c->p + && !(c->p->flags & (1<<6))) + never_ever(gi + 3, c->p); + if (c && c->type == 4 && c->p + && !(c->p->flags & (1<<5))) + never_ever(gi + 4, c->p); + if (c && c->type == 4 && c->p + && !(c->p->flags & (1<<4))) + never_ever(gi + 5, c->p); + if (c && c->type == 4 && c->p + && !(c->p->flags & (1<<3))) + never_ever(gi + 6, c->p); + if (c && c->type == 4 && c->p + && !(c->p->flags & (1<<2))) + never_ever(gi + 7, c->p); + if (c && c->type == 4 && c->p + && !(c->p->flags & (1<<1))) + never_ever(gi + 8, c->p); + if (c && c->type == 4 && c->p + && !(c->p->flags & (1<<9))) + never_ever(gi + 9, c->p); +} + +static void +foo(int * interp, Pcc_cell *c) +{ + mark_cell(interp, c, g_pvc); +} + +static struct Pcc_cell * +__attribute__((noinline,noclone)) +getnull(void) +{ + return (struct Pcc_cell *) 0; +} + + +int main() +{ + int i; + + cond = 1; + for (i = 0; i < 100; i++) + foo (&gi, getnull ()); + return 0; +} + + +void +bar_1 (int * interp, Pcc_cell *c) +{ + c->bla += 1; + mark_cell(interp, c, g_pvc); +} + +void +bar_2 (int * interp, Pcc_cell *c, struct PVC pvc) +{ + c->bla += 2; + mark_cell(interp, c, pvc); +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50333.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50333.c new file mode 100644 index 000000000..47577dccc --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50333.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ + +static inline void +unext(unsigned int *_ui, unsigned _len, unsigned int _ui0) +{ + unsigned j = 1; + while (++j<_len) + ; + _ui[j-1]=_ui0; +} +unsigned int +ncwrs_urow(unsigned _n, unsigned _k, unsigned int *_u) +{ + unsigned k; + for(k=2; k<_n; k++) + unext(_u+1,_k+1,1); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50363.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50363.c new file mode 100644 index 000000000..eb350198a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50363.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-tree-ch -fno-tree-fre" } */ + +void +foo (int *__restrict__ * r, int n) +{ + int *p; + for (p = *r; p < *r + n; p++) + ; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50389.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50389.c new file mode 100644 index 000000000..6d8b095b8 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50389.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-freorder-blocks -ftracer" } */ + +extern int data[]; +extern int i; + +void +foo (void) +{ + char buf[8]; + __builtin___memcpy_chk (buf, data, i ? 8 : 4, + __builtin_object_size (buf, 0)); + __builtin___memcpy_chk (buf, data, i ? 8 : 4, + __builtin_object_size (buf, 0)); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50396.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50396.c new file mode 100644 index 000000000..aa17ebdaa --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50396.c @@ -0,0 +1,22 @@ +/* { dg-do run } */ +/* { dg-add-options ieee } */ + +extern void abort (void); +typedef float vf128 __attribute__((vector_size(16))); +typedef float vf64 __attribute__((vector_size(8))); +int main() +{ +#if !__FINITE_MATH_ONLY__ +#if __FLT_HAS_QUIET_NAN__ + vf128 v = (vf128){ 0.f, 0.f, 0.f, 0.f }; + vf64 u = (vf64){ 0.f, 0.f }; + v = v / (vf128){ 0.f, 0.f, 0.f, 0.f }; + if (v[0] == v[0]) + abort (); + u = u / (vf64){ 0.f, 0.f }; + if (u[0] == u[0]) + abort (); +#endif +#endif + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50444.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50444.c new file mode 100644 index 000000000..35a614163 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50444.c @@ -0,0 +1,76 @@ +/* { dg-do run { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-msse2" } */ +/* { dg-require-effective-target sse2_runtime } */ + +typedef long long __m128i __attribute__ ((__vector_size__ (16), +__may_alias__)); +typedef int __v4si __attribute__ ((__vector_size__ (16))); +typedef long long __v2di __attribute__ ((__vector_size__ (16))); +typedef unsigned int uint32_t; + +typedef struct { + uint32_t v[4]; +} a4x32; + +a4x32* incr(a4x32* x) +{ + x->v[0] += 1; + return x; +} + +typedef struct { + __m128i m; +} a1xm128i; + +static inline a1xm128i ssefunc( a1xm128i in, a1xm128i k) +{ + a1xm128i ret; + ret.m = (__m128i)__builtin_ia32_pxor128 ((__v2di)in.m, (__v2di)k.m); + return ret; +} + +static a4x32 caster( a4x32 c4x32, a1xm128i k) +{ + a1xm128i c1x128; + if( sizeof(c4x32) != sizeof(c1x128) ) __builtin_abort(); + __builtin_memcpy(&c1x128, &c4x32, sizeof(c1x128)); + c1x128 = ssefunc(c1x128, k); + __builtin_memcpy(&c4x32, &c1x128, sizeof(c4x32)); + return c4x32; +} + +typedef struct { + a1xm128i key; + a4x32 c; + __SIZE_TYPE__ elem; + a4x32 v; +} Engine; + +void ctor(Engine *e) +{ + e->elem = 0; + e->key.m = (__m128i)(__v4si){ 0, 0, 0, 0 }; + e->c.v[0] = 0; + e->c.v[1] = 0; + e->c.v[2] = 0; + e->c.v[3] = 0; +} + +uint32_t method( Engine *e) +{ + if( e->elem == 0 ) + { + e->v = caster(*incr(&e->c), e->key); + e->elem = 4; + } + return e->v.v[--e->elem]; +} + +int main() +{ + Engine e4; ctor(&e4); + Engine e5; ctor(&e5); + if(method(&e4)!=method(&e5)) + __builtin_abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50472.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50472.c new file mode 100644 index 000000000..3b432eae3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50472.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-optimized" } */ +/* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } } */ + +static const unsigned int foo = 1; +unsigned int test( void ) +{ + const volatile unsigned int *bar = &foo; + return ( *bar ); +} + +/* { dg-final { scan-tree-dump-not "return 1" "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50723.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50723.c new file mode 100644 index 000000000..24e490fc6 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50723.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ + +typedef short unsigned int wchar_t; +typedef unsigned int size_t; +int* _errno(void); +int WideCharToMultiByte (wchar_t *); +int __attribute__ ((__nonnull__ (1))) +__wcrtomb_cp (char *dst, wchar_t wc, const unsigned int cp, + const unsigned int mb_max) +{ + if (cp == 0) { + if (wc > 255) + (*_errno()) = 42; + return 1; + } + else + return WideCharToMultiByte (&wc); +} +void wcsrtombs (char *dst, const wchar_t *pwc, unsigned int cp, + unsigned int mb_max) +{ + if ((__wcrtomb_cp (dst, *pwc, cp, mb_max)) <= 0) + return; + if ((__wcrtomb_cp (dst, *pwc, cp, mb_max)) <= 0) + return; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50729.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50729.c new file mode 100644 index 000000000..a1daa7b85 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50729.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-require-effective-target int32plus } */ + +extern void abort (void); +unsigned short __attribute__((noinline)) +foo (int i) +{ + if (i >= 0 + && i <= 0x400000) + return (unsigned short)(signed char)i; + return i; +} +int main() +{ + int i; + for (i = 0; i < 0xffff; ++i) + if (foo(i) != (unsigned short)(signed char) i) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50767.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50767.c new file mode 100644 index 000000000..96ab72ebd --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50767.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-tree-copy-prop -fno-tree-dominator-opts" } */ + +struct S +{ + struct S *s; +}; + +static struct S *ss; +struct S *s; + +void bar(void); + +void foo(void) +{ + for (;;) + { + s->s = ss; + bar (); + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50768.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50768.c new file mode 100644 index 000000000..351b2f966 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50768.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-ftracer" } */ + +char data[8]; +int l1; + +void +test1 (void) +{ + char buf[8]; + __builtin___mempcpy_chk (buf, data, l1 ? sizeof (buf) : 4, + __builtin_object_size (buf, 0)); + if (__builtin___memmove_chk + (buf, data, l1 ? sizeof (buf) : 4, + __builtin_object_size (buf, 0)) != buf) + __builtin_abort (); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50823.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50823.c new file mode 100644 index 000000000..9ac691172 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50823.c @@ -0,0 +1,43 @@ +/* { dg-do compile } */ +/* { dg-options "-finline-functions" } */ + +int k1, k2, k3, k4, k5, k6, k7, k8; + +void set_first_insn (int); +void set_last_insn (void); + +static int make_insn_raw (void) +{ + set_first_insn (0); + set_last_insn (); + return k1; +} + +static void add_insn_after (void) +{ + if (k2) + k3 = k4; + + if (k5) + k6 = k7; +} + +void emit_pattern_after_noloc (int (make_raw) (void)) +{ + if (k8) + { + make_raw (); + add_insn_after (); + } +} + +void emit_insn_after_noloc (void) +{ + emit_pattern_after_noloc (make_insn_raw); +} + +void emit_debug_insn_before_setloc (int k9) +{ + if (k9) + make_insn_raw (); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50838.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50838.c new file mode 100644 index 000000000..a3911c975 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50838.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ + +typedef void * gcv_object_t; +typedef gcv_object_t object; +typedef const void * Pseudofun; +extern struct pseudocode_tab_ { + Pseudofun pseudo_eql; + Pseudofun pseudo_iconv_wcslen; + Pseudofun pseudo_iconv_wcstombs; + Pseudofun pseudo_iconv_range; +} +pseudocode_tab; +extern struct symbol_tab_ { + object pointer[1024]; +} pseudofun_tab; +int +init_memory (void) +{ + object* ptr2 = &pseudofun_tab.pointer[0]; + const Pseudofun* ptr1 = (const Pseudofun*)&pseudocode_tab; + unsigned int count = (sizeof(pseudocode_tab)/sizeof(Pseudofun)); + while (count--) + { + *ptr2++ = (gcv_object_t)(((unsigned char *)((*ptr1)))); + ptr1++; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50890.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50890.c new file mode 100644 index 000000000..17240d4fb --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50890.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ + +static float make_insn_raw (void) +{ + return 0; +} + +static int emit_pattern_after_noloc (int (make_raw) ()) +{ + return make_raw (); +} + +void emit_insn_after_noloc (void) +{ + emit_pattern_after_noloc ((void *) make_insn_raw); +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50902.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50902.c new file mode 100644 index 000000000..5b7275b83 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr50902.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ + +_Bool data[128]; +void foo (_Bool *init) +{ + int i; + for (i = 0; i < 128; i++) + data[i] = *init; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51042.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51042.c new file mode 100644 index 000000000..05961c4ac --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51042.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ + +int a, b; + +void +foo (int x) +{ + int e[2]; + int d; + while (x) + { + for (d = 0; d <= 1; d = 1) + if (e[a]) + break; + for (b = 0; b <= 0; b = 1) + { + e[a] = a; + if (a) + break; + } + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51070-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51070-2.c new file mode 100644 index 000000000..f21eb3acb --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51070-2.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-inline" } */ + +int +func_4 (int si1, int si2) +{ + return si1; +} + +int +func_14 (int left, int right) +{ + return 1; +} + +int +func_37 (int left, int right) +{ + return left; +} + +int g_92[1024]; +int g_95[1024]; +int g_224; +int g_352[1024]; +int +func_9 () +{ + for (; g_224; g_224 += 1) + { + g_95[0] = func_4 (func_37 (g_92[g_224], 0), 0); + g_92[g_224] = 0, g_352[g_224] = func_14 (0, 0); + } + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51070.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51070.c new file mode 100644 index 000000000..cc06a90c8 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51070.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ + +int +func_4 (int si1, int si2) +{ + return si1; +} + +int +func_14 (int left, int right) +{ + return 1; +} + +int +func_37 (int left, int right) +{ + return left; +} + +int g_92[1024]; +int g_95[1024]; +int g_224; +int g_352[1024]; +int +func_9 () +{ + for (; g_224; g_224 += 1) + { + g_95[0] = func_4 (func_37 (g_92[g_224], 0), 0); + g_92[g_224] = 0, g_352[g_224] = func_14 (0, 0); + } + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51071-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51071-2.c new file mode 100644 index 000000000..b67879c44 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51071-2.c @@ -0,0 +1,40 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-delete-null-pointer-checks" } */ + +__extension__ typedef __UINTPTR_TYPE__ uintptr_t; + +extern struct module __this_module; +static inline void +trace_module_get (struct module *mod, uintptr_t ip) { } +struct module; +static inline __attribute__((no_instrument_function)) +int try_module_get(struct module *module) +{ + int ret = 1; + if (module) + { + if (module_is_live(module)) + { + __label__ __here; + asm(""); + __here: + trace_module_get(module, (uintptr_t)&&__here); + } + else + ret = 0; + } + return ret; +} +struct net_device; +struct net_device_ops { + int (*ndo_open)(struct net_device *dev); +}; +int t3e3_open(struct net_device *dev) +{ + int ret = hdlc_open(dev); + if (ret) + return ret; + try_module_get((&__this_module)); + return 0; +} +const struct net_device_ops t3e3_ops = { .ndo_open = t3e3_open }; diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51071.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51071.c new file mode 100644 index 000000000..99af9587d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51071.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ + +void foo (void); +void bar (void *); +extern int t; + +static void kmalloc_large (int size, int flags) +{ + (void) size; + (void) flags; + foo (); + bar (({__here:&&__here;})); +} + +static void kmalloc (int size, int flags) +{ + if (size) + { + if ((unsigned long) size > 0x1000) + kmalloc_large (size, flags); + + if (flags) + bar (({__here:&&__here;})); + } +} + +void compress_file_range (int i, int j, int k) +{ + int nr_pages = ({j < k;}); + + if (i || t) + kmalloc (0x1000UL * nr_pages, 0x40UL); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51106-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51106-1.c new file mode 100644 index 000000000..10b3b682b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51106-1.c @@ -0,0 +1,14 @@ +/* PR target/51106 */ +/* { dg-do "compile" } */ +/* { dg-skip-if "RTL error" { "*-*-*" } { "-fno-fat-lto-objects" } { "" } } */ + +int +foo (int x) +{ + asm goto ("" : : "i" (x) : : lab); /* { dg-error "impossible constraint" } */ + return 1; +lab: + return 0; +} + +/* { dg-warning "probably doesn.t match constraints" "" { target *-*-* } 8 } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51106-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51106-2.c new file mode 100644 index 000000000..bab0987ff --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51106-2.c @@ -0,0 +1,15 @@ +/* PR target/51106 */ +/* { dg-do "compile" } */ +/* { dg-skip-if "RTL error" { "*-*-*" } { "-fno-fat-lto-objects" } { "" } } */ +/* { dg-skip-if "" { powerpc-ibm-aix* } { "*" } { "" } } */ + +int +bar (int x) +{ + asm goto ("" : : "i" (x) : : lab); /* { dg-error "impossible constraint" } */ + __builtin_unreachable (); +lab: + return 0; +} + +/* { dg-warning "probably doesn.t match constraints" "" { target *-*-* } 9 } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51238.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51238.c new file mode 100644 index 000000000..4d5da5d18 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51238.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-ftree-loop-distribution" } */ + +extern int ia[]; +extern int ib[]; +int i; + +void +foo (int l) +{ + while (l--) + { + i = ia[l]; + ia[l] = ib[l] = 0; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51244-21.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51244-21.c new file mode 100644 index 000000000..fbb02db28 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51244-21.c @@ -0,0 +1,75 @@ +/* { dg-do run } */ +#include <assert.h> + +static inline int +blk_oversized_queue (int* q) +{ + if (q[2]) + return q[1] != 0; + return q[0] == 0; +} + +int __attribute__ ((noinline)) +get_request (int* q, int rw) +{ + if (blk_oversized_queue (q)) + { + if ((rw == 1) || (rw == 0)) + return -33; + + return 0; + } + + return -100; +} + +int main (void) +{ + int x[3]; + int r; + + x[0] = 0; x[1] = 1; x[2] = 1; + r = get_request (x, 0); + assert (r == -33); + + r = get_request (x, 1); + assert (r == -33); + + r = get_request (x, 2); + assert (r == 0); + + + x[0] = 0; x[1] = 0; x[2] = 1; + r = get_request (x, 0); + assert (r == -100); + + r = get_request (x, 1); + assert (r == -100); + + r = get_request (x, 2); + assert (r == -100); + + + x[0] = 0; x[1] = 0; x[2] = 0; + r = get_request (x, 0); + assert (r == -33); + + r = get_request (x, 1); + assert (r == -33); + + r = get_request (x, 2); + assert (r == 0); + + + x[0] = 0; x[1] = 0; x[2] = 0; + r = get_request (x, 0); + assert (r == -33); + + r = get_request (x, 1); + assert (r == -33); + + r = get_request (x, 2); + assert (r == 0); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51245.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51245.c new file mode 100644 index 000000000..e5e2ded13 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51245.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +struct S { int s; } a, *b, **c; +int d; + +struct S +foo (void) +{ + struct S s = { 0 }, *e = &a; + if (d) + **c = *b; + while (1) + { + *b = s; + *e = *b; + if (a.s) + break; + } + return **c; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51528.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51528.c new file mode 100644 index 000000000..db5f3e0ca --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51528.c @@ -0,0 +1,46 @@ +/* { dg-do run } */ +/* { dg-options "-fno-early-inlining" } */ + +extern void abort (void); + +union U +{ + int i; + _Bool b; +}; + +_Bool gb; + +void __attribute__ ((noinline)) +use_bool (union U u) +{ + gb = u.b; +} + +union U +bar (void) +{ + union U u; + u.i = 0xFFFE; + return u; +} + +union U __attribute__ ((noinline)) +foo (void) +{ + union U u,v; + + u.b = 1; + use_bool (u); + u = bar (); + + return u; +} + +int main (int argc, char **argv) +{ + union U u = foo (); + if (u.i != 0xFFFE) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51692.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51692.c new file mode 100644 index 000000000..34a81c29d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51692.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +int +main () +{ + volatile double d = 0.0; + double *p = __builtin_calloc (1, sizeof (double)); + d += 1.0; + *p += 2.0; + __builtin_free (p); + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51760.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51760.c new file mode 100644 index 000000000..ebff2c930 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51760.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ + +extern inline __attribute__ ((always_inline)) void * +memmove (void *dest, const void *src, __SIZE_TYPE__ len) +{ + return __builtin___memmove_chk (dest, src, len, + __builtin_object_size (dest, 0)); +} + +void +foo (void) +{ + char a[64], *b; + for (;;) + { + memmove (a, b, 0); + b = a; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51801.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51801.c new file mode 100644 index 000000000..c36cee306 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51801.c @@ -0,0 +1,62 @@ +/* { dg-do compile } */ + +typedef struct { char Vshow; } TScreen; +typedef struct _Misc { char Tshow; } Misc; +typedef struct _XtermWidgetRec { TScreen screen; Misc misc; } XtermWidgetRec, *XtermWidget; +extern XtermWidget term; + +void +handle_tekshow (void *gw, int allowswitch) +{ + XtermWidget xw = term; + if (!((xw)->misc.Tshow)) + set_tek_visibility (1); +} + +void +do_tekonoff (void *gw, void *closure, void *data) +{ + handle_tekshow (gw, 0); +} + +void +do_vtonoff (void *gw, void *closure, void *data) +{ +} + +void +handle_toggle (void (*proc) (void *gw, void *closure, void *data), + int var, char **params, unsigned int nparams, void *w, + void *closure, void *data) +{ + XtermWidget xw = term; + int dir = -2; + switch (nparams) + { + case 0: + dir = -1; + } + switch (dir) + { + case 1: + (*proc) (w, closure, data); + Bell (xw, 2, 0); + } +} + +void +HandleVisibility (void *w, char **params, unsigned int *param_count) +{ + XtermWidget xw = term; + if (*param_count == 2) + switch (params[0][0]) + { + case 'v': + handle_toggle (do_vtonoff, (int) ((int) (&(xw)->screen)->Vshow), + params + 1, (*param_count) - 1, w, (void *) 0, + (void *) 0); + handle_toggle (do_tekonoff, (int) ((int) ((xw)->misc.Tshow)), + params + 1, (*param_count) - 1, w, (void *) 0, + (void *) 0); + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51949.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51949.c new file mode 100644 index 000000000..e23bd7b4c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr51949.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +typedef long unsigned int size_t; +extern __attribute__ ((malloc)) void *mem_alloc(size_t); +void *mem_alloc(size_t amount) +{ + void *q = __builtin_malloc (amount); + if (!q) { + __builtin_printf("malloc"); + __builtin_exit(255); + } +} +void mem_realloc() +{ + mem_alloc(1); +} +void put_env_var() +{ + mem_alloc(1); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52028.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52028.c new file mode 100644 index 000000000..764377c3c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52028.c @@ -0,0 +1,83 @@ +/* { dg-do run } */ +/* { dg-require-effective-target int32plus } */ +/* { dg-options "-ftree-loop-distribution" } */ + +#define CAST_LONG unsigned int +typedef struct cast_key_st +{ + CAST_LONG data[32]; +} CAST_KEY; +#define CAST_exp(l,A,a,n) \ + A[n/4]=l; \ + a[n+3]=(l )&0xff; \ + a[n+2]=(l>> 8)&0xff; \ + a[n+1]=(l>>16)&0xff; \ + a[n+0]=(l>>24)&0xff; + +CAST_LONG CAST_S_table[1024]; + +#define S4 (CAST_S_table + 000) +#define S5 (CAST_S_table + 256) +#define S6 (CAST_S_table + 512) +#define S7 (CAST_S_table + 768) + +void +CAST_set_key (CAST_KEY * key) +{ + CAST_LONG x[16]; + CAST_LONG z[16]; + CAST_LONG k[32]; + CAST_LONG X[4] = {0,0,0,0}, Z[4]; + CAST_LONG l, *K = k; + int i; + for (i = 0; i < 16; i++) + x[i] = 0; + for (;;) + { + l = X[0] ^ S4[x[13]] ^ S5[x[15]] ^ S6[x[12]] ^ S7[x[14]] ^ S6[x[8]]; + CAST_exp (l, Z, z, 0); + CAST_exp (l, Z, z, 4); + CAST_exp (l, Z, z, 8); + CAST_exp (l, Z, z, 12); + K[0] = S4[z[8]] ^ S5[z[9]] ^ S6[z[7]] ^ S7[z[6]] ^ S4[z[2]]; + K[1] = S4[z[10]] ^ S5[z[11]] ^ S6[z[5]] ^ S7[z[4]] ^ S5[z[6]]; + K[2] = S4[z[12]] ^ S5[z[13]] ^ S6[z[3]] ^ S7[z[2]] ^ S6[z[9]]; + K[3] = S4[z[14]] ^ S5[z[15]] ^ S6[z[1]] ^ S7[z[0]] ^ S7[z[12]]; + K[4] = S4[x[3]] ^ S5[x[2]] ^ S6[x[12]] ^ S7[x[13]] ^ S4[x[8]]; + K[5] = S4[x[1]] ^ S5[x[0]] ^ S6[x[14]] ^ S7[x[15]] ^ S5[x[13]]; + K[6] = S4[x[7]] ^ S5[x[6]] ^ S6[x[8]] ^ S7[x[9]] ^ S6[x[3]]; + K[7] = S4[x[5]] ^ S5[x[4]] ^ S6[x[10]] ^ S7[x[11]] ^ S7[x[7]]; + K[8] = S4[z[3]] ^ S5[z[2]] ^ S6[z[12]] ^ S7[z[13]] ^ S4[z[9]]; + K[9] = S4[z[1]] ^ S5[z[0]] ^ S6[z[14]] ^ S7[z[15]] ^ S5[z[12]]; + K[10] = S4[z[7]] ^ S5[z[6]] ^ S6[z[8]] ^ S7[z[9]] ^ S6[z[2]]; + K[11] = S4[z[5]] ^ S5[z[4]] ^ S6[z[10]] ^ S7[z[11]] ^ S7[z[6]]; + l = Z[2] ^ S4[z[5]] ^ S5[z[7]] ^ S6[z[4]] ^ S7[z[6]] ^ S6[z[0]]; + CAST_exp (l, X, x, 0); + K[12] = S4[x[8]] ^ S5[x[9]] ^ S6[x[7]] ^ S7[x[6]] ^ S4[x[3]]; + K[13] = S4[x[10]] ^ S5[x[11]] ^ S6[x[5]] ^ S7[x[4]] ^ S5[x[7]]; + K[14] = S4[x[12]] ^ S5[x[13]] ^ S6[x[3]] ^ S7[x[2]] ^ S6[x[8]]; + K[15] = S4[x[14]] ^ S5[x[15]] ^ S6[x[1]] ^ S7[x[0]] ^ S7[x[13]]; + if (K != k) + break; + K += 16; + } + for (i = 0; i < 16; i++) + { + key->data[i * 2] = k[i]; + key->data[i * 2 + 1] = ((k[i + 16]) + 16) & 0x1f; + } +} + +int +main () +{ + CAST_KEY ref = { {0x0069B3F8, 0x00000013, 0x000AEFF8, 0x00000013, 0x004AD0E0, 0x0000001B, 0x00818F18, 0x00000018, 0x008FF000, 0x0000001B, 0x002D1C00, 0x0000001B, 0x00EA2800, 0x00000010, 0x00C73400, 0x00000010, 0x004BF8E0, 0x0000001B, 0x00B3D718, 0x00000018, 0x00B0EBF8, 0x00000013, 0x003247F8, 0x00000013, 0x00C5BA20, 0x00000010, 0x002D1C00, 0x00000010, 0x0060822B, 0x00000008, 0x0096236B, 0x0000001B} }; + CAST_KEY key; + unsigned i; + for (i = 1; i < 1024; i++) + CAST_S_table[i] = (CAST_S_table[i-1] * 7 + 3) & 0xFFFFFF; + CAST_set_key (&key); + if (__builtin_memcmp(&ref, &key, sizeof(ref))) + __builtin_abort(); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52060.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52060.c new file mode 100644 index 000000000..44207a503 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52060.c @@ -0,0 +1,57 @@ +/* PR rtl-optimization/52060 */ +/* { dg-do run { target int32plus } } */ + +extern void abort (void); +union U { float f; unsigned int i; }; + +static inline __attribute__((always_inline)) unsigned int +foo (float x) +{ + union U u; + unsigned int a, b, c; + int d; + int e; + u.f = x; + d = ((unsigned) u.i >> 23) & 0xFF; + c = d < 126 ? 0 : ~0; + e = 127 + 30 - d; + a = (u.i << 8) | 0x80000000U; + b = a & ((1 << e) - 1); + a = a >> e; + c &= (b | (a & 2)) ? ~0 : ~1; + a = ((a + 1U) >> 1) & c; + return a; +} + +__attribute__((noinline)) unsigned int +bar (float x) +{ + unsigned int a, b, c; + static const unsigned int d[128] = + { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 7 + }; + a = foo (1048575.0f * x); + c = d[a >> 13]; + b = (c << 13) | ((a >> (7 - c)) & 0x1fff); + return b; +} + +int +main () +{ + union U u; + u.f = 1048575.0f; + if (sizeof (u.i) == sizeof (u.f) + && u.i == 0x497ffff0U + && bar (1.0f) != 65535) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52170.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52170.c new file mode 100644 index 000000000..3d0a03889 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52170.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ + +typedef unsigned char uint8_t ; +typedef unsigned long uint32_t; +void f0a(uint32_t * result, uint32_t * arg1) +{ + int idx; + for (idx=0;idx<96;idx += 1) + { + uint8_t temp_5; + uint8_t temp_6; + + temp_5 = ~(*arg1); + temp_6 = (*arg1) + 1 - temp_5; + result[idx] = temp_6; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52244.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52244.c new file mode 100644 index 000000000..2a29e3cf4 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52244.c @@ -0,0 +1,36 @@ +/* { dg-do run } */ + +extern void abort (void); + +typedef union u_r +{ + _Bool b; + unsigned char c; +} u_t; + +u_t +bar (void) +{ + u_t u; + u.c = 0x12; + return u; +} + +u_t __attribute__ ((noinline)) +foo (void) +{ + u_t u; + + u.b = 1; + u = bar (); + + return u; +} + +int main (int argc, char **argv) +{ + u_t u = foo (); + if (u.c != 0x12) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52298.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52298.c new file mode 100644 index 000000000..f0799c1a5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52298.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ + +int a, b, c, h; + +int i[5][5]; + +void +fn1 () +{ + int l = 0; + + for (a = 0; a <= 3; a++) + for (b = 1; b >= 0; b -= 1) + l |= i[0][b]; + c = l; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52402.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52402.c new file mode 100644 index 000000000..ba7c5ae24 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52402.c @@ -0,0 +1,30 @@ +/* { dg-do run } */ +/* { dg-options "-w -Wno-psabi" } */ +/* { dg-require-effective-target int32plus } */ + +typedef int v4si __attribute__((vector_size(16))); +struct T { v4si i[2]; int j; } __attribute__((packed)); + +static v4si __attribute__((noinline)) +foo (struct T t) +{ + return t.i[0]; +} + +static struct T *__attribute__((noinline)) +init () +{ + char *p = __builtin_malloc (sizeof (struct T) + 1); + p++; + __builtin_memset (p, 1, sizeof (struct T)); + return (struct T *)p; +} + +int main() +{ + struct T *p; + p = init (); + if (foo (*p)[0] != 0x01010101) + __builtin_abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52406.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52406.c new file mode 100644 index 000000000..5579d0943 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52406.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ + +extern void abort (void); +struct { int f1; } a[2]; + +int *b, *const k = &a[1].f1; +static int **c = &b; + +int e, f, d; + +int +main () +{ + int **l = &b; + *l = k; + for (; d <= 0; d++) + { + int *j = &e; + **c = 1; + *l = k; + *k ^= 0; + f = **l; + *j = f; + } + if (e != 1) + abort (); + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52407.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52407.c new file mode 100644 index 000000000..917e9db3f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52407.c @@ -0,0 +1,34 @@ +/* { dg-do run } */ +/* { dg-options "-fno-common" { target hppa*-*-hpux* } } */ + +extern void abort (void); + +typedef long long T; +typedef T vl_t __attribute__((vector_size(2 * sizeof (T)))); + +vl_t ul[4], vl[4] = { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } }; + +static void +mul_vl_l(vl_t *u, vl_t *v, T x, int m) +{ + vl_t w; + T *p = (T *)&w; + p[0] = p[1] = x; + while (m--) + *u++ = *v++ * w; +} + +int +main(int argc, char *argv[]) +{ + int i; + T *pl; + + pl = (T *) &ul; + mul_vl_l(ul, vl, 2, 4); + for (i = 0; i < 8; i++) + if (pl[i] != 2 * (i + 1)) + abort (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52419.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52419.c new file mode 100644 index 000000000..d24225a3e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52419.c @@ -0,0 +1,32 @@ +/* PR middle-end/52419 */ +/* { dg-do run } */ + +extern void abort (void); + +typedef long long V + __attribute__ ((vector_size (2 * sizeof (long long)), may_alias)); + +typedef struct S { V b; } P __attribute__((aligned (1))); + +struct __attribute__((packed)) T { char c; P s; }; + +__attribute__((noinline, noclone)) void +foo (P *p) +{ + p->b[1] = 5; +} + +int +main () +{ + V a = { 3, 4 }; + struct T t; + + t.s.b = a; + foo (&t.s); + + if (t.s.b[0] != 3 || t.s.b[1] != 5) + abort (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52429.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52429.c new file mode 100644 index 000000000..e2aeaa971 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52429.c @@ -0,0 +1,24 @@ +/* PR tree-optimization/52429 */ +/* { dg-do compile } */ +/* { dg-require-effective-target pthread } */ +/* { dg-options "-g -ftree-parallelize-loops=4" } */ + +double d[65536], e[65536]; + +void +foo (void) +{ + int i; + double f, g; + for (i = 0; i < 65536; i++) + { + f = e[i]; + goto lab1; + lab2: + d[i] = f * g; + continue; + lab1: + g = d[i]; + goto lab2; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52493.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52493.c new file mode 100644 index 000000000..b04ac5c17 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52493.c @@ -0,0 +1,38 @@ +/* { dg-do compile } */ + +struct Time { + long int sec; + long usec; +}; +struct Flow { + unsigned short iif; + struct Time mtime; +}; +struct NetFlow { + unsigned MaxFlows; + unsigned HeaderFields; + unsigned short *HeaderFormat; +}; +static struct NetFlow *netflow; +static struct Time start_time; +static unsigned char emit_packet[1500]; +inline long int cmpmtime(struct Time *t1, struct Time *t2) +{ + return (t1->sec - t2->sec) * 1000 + (t1->usec - t2->usec) / 1000; +} +static void fill(int fields, unsigned short *format, + struct Flow *flow, void *p) +{ + int i; + for (i = 0; i < fields; i++) + if (format[i] == 21) + { + unsigned int __v; + __v = cmpmtime(&flow->mtime, &start_time); + *((unsigned int *) p) = __v; + } +} +void emit_thread() +{ + fill(netflow->HeaderFields, netflow->HeaderFormat, 0, &emit_packet); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52530.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52530.c new file mode 100644 index 000000000..f7cdf1a63 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52530.c @@ -0,0 +1,40 @@ +/* { dg-do run } */ + +extern void abort (void); + +#if __SIZEOF_INT__ > 2 +struct foo +{ + int *f; + int i; +}; + +int baz; +#else +struct foo +{ + long *f; + long i; +}; + +long baz; +#endif + +void __attribute__ ((noinline)) +bar (struct foo x) +{ + *(x.f) = x.i; +} + +int +main () +{ + struct foo x = { &baz, 0xdeadbeef }; + + bar (x); + + if (baz != 0xdeadbeef) + abort (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52693.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52693.c new file mode 100644 index 000000000..93e0680ac --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52693.c @@ -0,0 +1,33 @@ +/* { dg-do run } */ + +struct pair +{ + int x; + int y; +}; + +struct array +{ + struct pair elems[ 2 ]; + unsigned index; +}; + +extern void abort (); + +void __attribute__ ((noinline,noclone)) +test_results (int x1, int y1, int x2, int y2) +{ + if (x1 != x2 || y1 != y2) + abort (); +} + +int +main (void) +{ + struct array arr = {{{1,2}, {3,4}}, 1}; + struct pair last = arr.elems[arr.index]; + + test_results ( last.x, last.y, arr.elems[1].x, arr.elems[1].y); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52720.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52720.c new file mode 100644 index 000000000..528aa161b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52720.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-march=k8-sse3" { target x86_64-*-* } } */ + +struct alu_bank_swizzle { + int hw_gpr[3][4]; + int hw_cfile_addr[4]; +}; +static void init_bank_swizzle(struct alu_bank_swizzle *bs) +{ + int i, cycle, component; + for (cycle = 0; cycle < 3; cycle++) + for (component = 0; component < 4; component++) + bs->hw_gpr[cycle][component] = -1; + for (i = 0; i < 4; i++) + bs->hw_cfile_addr[i] = -1; +} +int check_and_set_bank_swizzle(int max_slots, int *slots) +{ + struct alu_bank_swizzle bs; + int i; + for (i = 0; i < max_slots; i++) + { + init_bank_swizzle(&bs); + if (slots[i]) + check_vector(&bs); + } +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52756.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52756.c new file mode 100644 index 000000000..175b414e1 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52756.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ + +void Env_FetchObj0AttrOffset (unsigned int NumFields, int *Status) +{ + int Found = 0; + if (NumFields) + while ((*Status == 0) && NumFields-- > 0 && Found == 0) + Found = 1; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52881.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52881.c new file mode 100644 index 000000000..c101c8033 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52881.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ + +int a, b, c, d, e, f, h, i, j, k, l, m, n, o; +static int g; +int +fn1 () { + for (;; ++f) + if (e) + break; + return 0; +} +unsigned char fn2 (); +void +fn3 () { +lbl_220: + if (j) { +lbl_221: + l = (g || b) <= fn1 (); + for (;;) { + g = 0; + fn2 (); + if (k) + goto lbl_220; + break; + } + if (l) + goto lbl_221; + } +} +unsigned char +fn2 () { + o = d ? 0 : c; + h = m | a % o != n; + return i; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52912.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52912.c new file mode 100644 index 000000000..3ae57588f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52912.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ + +int a, b, c; +static int +fn1 (p1) +{ +lbl_549: + if (p1) + goto lbl_549; + return 0; +} + +void +fn2 () +{ + b = (c && a) > fn1 (c) >= c; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52913.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52913.c new file mode 100644 index 000000000..ad99884bf --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52913.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ + +int a, b, c, d, e; +void +fn1 () +{ +lbl_101: + e = 0; +lbl_274: + for (c = 0; c < 1; c = a) + if (d) + if (b) + goto lbl_101; + else + break; + d = 1; + goto lbl_274; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52943.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52943.c new file mode 100644 index 000000000..da35c9d18 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52943.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ + +extern void abort (void); +int a[] = { 0, 0, 0, 6 }; + +int b; +int +main () +{ + for (;;) + { + b = 3; + for (; b; b -= 1) + a[b] = a[3] > 1; + break; + } + if (a[1] != 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52969.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52969.c new file mode 100644 index 000000000..05331d93f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52969.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-ftree-loop-if-convert-stores" } */ + +int a, b; +float xsum[100]; +void foo (float *cluster) +{ + int j; + for (; a ; ++j) { + xsum[j] = cluster[j]; + if (xsum[j] > 0) + xsum[j] = 0; + } + if (xsum[0]) + b = 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52996.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52996.c new file mode 100644 index 000000000..200bc36b2 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr52996.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */
+/* { dg-options "-funswitch-loops" } */
+
+int a, b, c, d, e, f;
+void
+fn1 ()
+{
+ int g, h;
+lbl_173:
+ if (a)
+ c++;
+lbl_158:
+ e = 0;
+ h = 0;
+ for (; h > -8; h--)
+ {
+ g = 0;
+ for (; g <= 0; g += 1)
+ {
+ d = 1;
+ for (; d >= 0; d -= 1)
+ a = 1;
+ if (b)
+ break;
+ if (f)
+ return;
+ if (h)
+ goto lbl_158;
+ }
+ }
+ goto lbl_173;
+}
+
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53070.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53070.c new file mode 100644 index 000000000..534ac3414 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53070.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-ffast-math -ftree-loop-if-convert -fno-tree-loop-im" } */ +int +foo (int c) +{ + int t = 0, i = 0; + for (; i < 100; i++) + t += c ? c : 1; + return t; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53120.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53120.c new file mode 100644 index 000000000..8a70290e0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53120.c @@ -0,0 +1,110 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-tree-sra" } */ +typedef struct { + unsigned int en : 1; + unsigned int bit_order : 1; + unsigned int scl_io : 1; + unsigned int scl_inv : 1; + unsigned int sda0_io : 1; + unsigned int sda0_idle : 1; + unsigned int sda1_io : 1; + unsigned int sda1_idle : 1; + unsigned int sda2_io : 1; + unsigned int sda2_idle : 1; + unsigned int sda3_io : 1; + unsigned int sda3_idle : 1; + unsigned int sda_sel : 2; + unsigned int sen_idle : 1; + unsigned int sen_inv : 1; + unsigned int sen_sel : 2; + unsigned int dummy1 : 14; +} reg_gio_rw_i2c1_cfg; + +typedef struct { + unsigned int data0 : 8; + unsigned int data1 : 8; + unsigned int data2 : 8; + unsigned int data3 : 8; +} reg_gio_rw_i2c1_data; + +typedef struct { + unsigned int trf_bits : 6; + unsigned int switch_dir : 6; + unsigned int extra_start : 3; + unsigned int early_end : 1; + unsigned int start_stop : 1; + unsigned int ack_dir0 : 1; + unsigned int ack_dir1 : 1; + unsigned int ack_dir2 : 1; + unsigned int ack_dir3 : 1; + unsigned int ack_dir4 : 1; + unsigned int ack_dir5 : 1; + unsigned int ack_bit : 1; + unsigned int start_bit : 1; + unsigned int freq : 2; + unsigned int dummy1 : 5; +} reg_gio_rw_i2c1_ctrl; + +extern reg_gio_rw_i2c1_cfg reg_gio; +extern reg_gio_rw_i2c1_data reg_data; +extern int reg_start; +extern reg_gio_rw_i2c1_ctrl reg_ctrl; + +extern void foobar(void); +extern void foo(int); +extern void frob(unsigned int); +extern void bar(int); +extern void baz(void); + +unsigned int f(int *devspec, unsigned int addr) +{ + reg_gio_rw_i2c1_ctrl ctrl = {0}; + reg_gio_rw_i2c1_data data = {0}; + + foobar(); + + static int first = 1; + + if (first) { + reg_gio_rw_i2c1_cfg cfg = {0}; + first = 0; + + foo(1); + cfg.sda0_idle = 1; + cfg.sda0_io = 0; + cfg.scl_inv = 0; + cfg.scl_io = 0; + cfg.bit_order = 1; + cfg.sda_sel = 0; + cfg.sen_sel = 0; + cfg.en = 1; + reg_gio = cfg; + } + + ctrl.freq = 1; + ctrl.start_bit = 0; + ctrl.ack_bit = 1; + ctrl.ack_dir0 = 0; + ctrl.ack_dir1 = 0; + ctrl.ack_dir2 = 0; + ctrl.ack_dir3 = 1; + ctrl.ack_dir4 = 0; + ctrl.ack_dir5 = 0; + ctrl.start_stop = 1; + ctrl.early_end = 0; + ctrl.extra_start = 2; + ctrl.switch_dir = 8*3; + ctrl.trf_bits = 8*4; + reg_ctrl = ctrl; + frob(0xac); + data.data0 = devspec[1] & 192; + data.data1 = addr; + data.data2 = devspec[1] | 0x01; + reg_data = data; + reg_start = 1; + bar(100); + data = reg_data; + baz(); + + return data.data3; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53144.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53144.c new file mode 100644 index 000000000..ad94812ad --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53144.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ + +typedef unsigned char __attribute__((vector_size(4))) uvec; + +int main (int argc, char *argv[]) { + int i; + int x = 0; + uvec uc0 = (uvec) {argc, 1, 2, 10}; + unsigned char uc1[4] = {0, 3, 2, 200}; + signed char ucg[4] = {1, 0, 0, 0 }; + signed char ucl[4] = {0, 1, 0, 1 }; + +#define uc0_ ((unsigned char *)&uc0) + + for (i = 0; i < 4; i ++) { + x |= ucg[i] != (uc0_[i] > uc1[i]); + x |= ucl[i] != (uc0_[i] < uc1[i]); + } + return x; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53168.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53168.c new file mode 100644 index 000000000..0b9a8dce6 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53168.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ + +int a, b, c; +unsigned *d; +int e[1]; +void fn1 (); +int fn2 (); +int +fn3 () +{ + int *f = &a; + if (fn2 ()) + { + for (; c; c++) + { + e[a] && (b = 0); + fn1 (); + if (e[a]) + return 0; + } + for (; c <= 0; c++) + for (;;) + ; + } + else + e[0] = 0 != (d = f); + return *d; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53272-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53272-1.c new file mode 100644 index 000000000..a8fc91cb5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53272-1.c @@ -0,0 +1,39 @@ +/* { dg-do run } */ +/* { dg-additional-sources "pr53272-2.c" } */ +struct rtc_class_ops { + int (*f)(void *, unsigned int enabled); +}; + +struct rtc_device +{ + void *owner; + const struct rtc_class_ops *ops; + int ops_lock; +}; + +__attribute__ ((__noinline__, __noclone__)) +extern int foo(void *); +__attribute__ ((__noinline__, __noclone__)) +extern void foobar(void *); + +__attribute__ ((__noinline__, __noclone__)) +int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled) +{ + int err; + asm volatile (""); + + err = foo(&rtc->ops_lock); + + if (err) + return err; + + if (!rtc->ops) + err = -19; + else if (!rtc->ops->f) + err = -22; + else + err = rtc->ops->f(rtc->owner, enabled); + + foobar(&rtc->ops_lock); + return err; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53272-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53272-2.c new file mode 100644 index 000000000..f5065a785 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53272-2.c @@ -0,0 +1,39 @@ +__attribute__ ((__noinline__, __noclone__)) +int foo(void *x) +{ + asm (""); + return *(int *) x != 42; +} + +__attribute__ ((__noinline__, __noclone__)) +void foobar(void *x) +{ + asm (""); + if (foo(x)) + __builtin_abort(); +} + +struct rtc_class_ops { + int (*f)(void *, unsigned int enabled); +}; + +struct rtc_device +{ + void *owner; + struct rtc_class_ops *ops; + int ops_lock; +}; + +extern __attribute__ ((__noinline__, __noclone__)) +int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int); + +int main(void) +{ + struct rtc_class_ops ops = {(void *) 0}; + struct rtc_device dev1 = {0, &ops, 42}; + + if (rtc_update_irq_enable (&dev1, 1) != -22) + __builtin_abort (); + + __builtin_exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53366-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53366-1.c new file mode 100644 index 000000000..d70eae821 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53366-1.c @@ -0,0 +1,71 @@ +/* PR tree-optimization/53366 */ +/* { dg-do run { target { size32plus } } } */ +/* { dg-require-effective-target size32plus } */ + +extern void abort (void); + +struct S { double v[3]; }; +struct T { struct S r, i; }; +struct U { struct T j[5]; }; + +void +foo (struct U *__restrict p1, struct U *__restrict p2, + struct S l1, struct S l2, struct S l3, struct S l4, + const double _Complex * __restrict x, int y, int z) +{ + int i, j; + while (y < z - 2) + { + for (j = 0; j < 5; ++j) + { + double a = __real__ x[5 * y + j]; + double b = __imag__ x[5 * y + j]; + double c = __real__ x[5 * (y + 2) + j]; + double d = __imag__ x[5 * (y + 2) + j]; + double e = __real__ x[5 * (y + 1) + j]; + double f = __imag__ x[5 * (y + 1) + j]; + double g = __real__ x[5 * (y + 3) + j]; + double h = __imag__ x[5 * (y + 3) + j]; + for (i = 0; i < 3; ++i) + { + p1->j[j].r.v[i] += l2.v[i] * a; + p1->j[j].r.v[i] += l4.v[i] * c; + p1->j[j].i.v[i] += l2.v[i] * b; + p1->j[j].i.v[i] += l4.v[i] * d; + p2->j[j].r.v[i] += l3.v[i] * e; + p2->j[j].r.v[i] += l1.v[i] * g; + p2->j[j].i.v[i] += l3.v[i] * f; + p2->j[j].i.v[i] += l1.v[i] * h; + } + } + y += 4; + } +} + +_Complex double x[5005]; +struct U p1, p2; + +int +main () +{ + int i, j; + struct S l1, l2, l3, l4; + for (i = 0; i < 5005; ++i) + x[i] = i + 1.0iF * (2 * i); + for (i = 0; i < 3; ++i) + { + l1.v[i] = 1; + l2.v[i] = 2; + l3.v[i] = 3; + l4.v[i] = 4; + } + foo (&p1, &p2, l1, l2, l3, l4, x, 5, 1000); + for (j = 0; j < 5; ++j) + for (i = 0; i < 3; ++i) + if (p1.j[j].r.v[i] != 3752430 + j * 1494.0 + || p1.j[j].i.v[i] != p1.j[j].r.v[i] * 2 + || p2.j[j].r.v[i] != 2502450 + j * 996.0 + || p2.j[j].i.v[i] != p2.j[j].r.v[i] * 2) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53366-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53366-2.c new file mode 100644 index 000000000..6be6a5610 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53366-2.c @@ -0,0 +1,43 @@ +/* PR tree-optimization/53366 */ +/* { dg-do run } */ + +extern void abort (void); + +struct T { float r[3], i[3]; }; +struct U { struct T j[2]; }; + +void __attribute__ ((noinline)) +foo (struct U *__restrict y, const float _Complex *__restrict x) +{ + int i, j; + for (j = 0; j < 2; ++j) + { + float a = __real__ x[j]; + float b = __imag__ x[j]; + float c = __real__ x[j + 2]; + float d = __imag__ x[j + 2]; + for (i = 0; i < 3; ++i) + { + y->j[j].r[i] = y->j[j].r[i] + a + c; + y->j[j].i[i] = y->j[j].i[i] + b + d; + } + } +} + +_Complex float x[4]; +struct U y; + +int +main () +{ + int i, j; + for (i = 0; i < 4; ++i) + x[i] = i + 1.0iF * (2 * i); + foo (&y, x); + for (j = 0; j < 2; ++j) + for (i = 0; i < 3; ++i) + if (y.j[j].r[i] != __real__ (x[j] + x[j + 2]) + || y.j[j].i[i] != __imag__ (x[j] + x[j + 2])) + __builtin_abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53390.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53390.c new file mode 100644 index 000000000..72a25c52e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53390.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ + +extern unsigned short var1; +extern int var2; + +extern struct { + int f1; + unsigned short *f2; +} *my_table; + +void foo(void) +{ + unsigned short *local_vec + = __builtin_malloc(var1 * var2 * sizeof(unsigned short)); + unsigned short i; + + my_table[0].f2 = __builtin_malloc(var1 * sizeof(unsigned short)); + + for (i = 0; i < var1; ++i) + my_table[0].f2[i] = local_vec[i * var2]; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53408.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53408.c new file mode 100644 index 000000000..25c6dc7f5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53408.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +int a, b, c, d, e; +void +fn1 () +{ + int f, g; + char h = 0; + b = 0; + for (; b < 32; b++) + { + g = h > e ? h : h << 1; + f = g && a ? 0 : 1; + h = 1; + for (; h > 0; h = h + 1) + c = 0 < h | f; + } + if (h) + d = 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53501.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53501.c new file mode 100644 index 000000000..36e3ae61e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53501.c @@ -0,0 +1,22 @@ +/* { dg-do run } */ + +extern void abort (void); + +int e[100], n, here; + +void __attribute__((noinline)) +foo(void) +{ + int i, k = 0; + for (i = 0; i < n; ++i) { e[k] = 10; ++k; e[k] = 10; ++k; } + for (i = 0; i < k; ++i) here = 1; + if (here != 1) + abort (); +} + +int main(void) +{ + n = 10; + foo(); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53516.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53516.c new file mode 100644 index 000000000..7f8094d19 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53516.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ +/* { dg-options "-ftree-vectorize -ftree-loop-distribute-patterns" } */ + +extern void abort (void); + +struct Foo +{ + char a : 1; + char b : 7; +}; + +struct Foo x[256]; +int y[256]; + +void __attribute__((noinline,noclone)) bar (int n) +{ + int i; + for (i = 0; i < n; ++i) + { + x[i].a = 0; + y[i] = 3; + } +} + +int main() +{ + x[5].b = 7; + bar (256); + if (x[5].b != 7) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53589.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53589.c new file mode 100644 index 000000000..5ab78907f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53589.c @@ -0,0 +1,15 @@ +/* PR rtl-optimization/53589 */ +/* { dg-do compile } */ + +extern void foo (void) __attribute__ ((__noreturn__)); + +void +bar (int x) +{ + if (x < 0) + foo (); + if (x == 0) + return; + __asm goto ("# %l[lab]" : : : : lab); +lab:; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53663-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53663-1.c new file mode 100644 index 000000000..3392ddecb --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53663-1.c @@ -0,0 +1,30 @@ +/* { dg-do run } */ + +extern void abort (void); + +union u +{ + int i; + _Bool b; +}; + +void f(union u * vp, union u v) +{ + *vp = v; +} + +int main() +{ + union u v; + union u v1; + union u v2; + + v.i = 10; + f(&v1, v); + + v.b = 0; + f(&v2, v); + if (v2.b != 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53663-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53663-2.c new file mode 100644 index 000000000..9589a9e20 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53663-2.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ + +extern void abort (void); + +union u +{ + int i; + short f; +} v; + +short foo (short *f) +{ + *f = 1; + v.i = 0; + v.f = 0; + return *f; +} + +int main() +{ + if (foo (&v.f) != 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53663-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53663-3.c new file mode 100644 index 000000000..96af5db10 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53663-3.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ + +extern void abort (void); + +union u +{ + int i; + float f; +} v; + +float foo (float *f) +{ + *f = 1; + v.i = 0; + v.f = 0.; + return *f; +} + +int main() +{ + if (foo (&v.f) != 0.) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53695.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53695.c new file mode 100644 index 000000000..eba0843c4 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53695.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-ftracer" } */ + +void +foo (const void **p) +{ + void *labs[] = { &&l1, &&l2, &&l3 }; +l1: + goto *p++; +l2: + goto *p; +l3: + ; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53703.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53703.c new file mode 100644 index 000000000..c9e10abf5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53703.c @@ -0,0 +1,149 @@ +/* Reduced test case from PR53703. Used to ICE. */ + +/* { dg-do compile } */ +/* { dg-options "-w" } */ + +typedef long unsigned int size_t; +typedef unsigned short int sa_family_t; +struct sockaddr {}; +typedef unsigned char __u8; +typedef unsigned short __u16; +typedef unsigned int __u32; +struct nlmsghdr { + __u32 nlmsg_len; + __u16 nlmsg_type; +}; +struct ifaddrmsg { + __u8 ifa_family; +}; +enum { + IFA_ADDRESS, + IFA_LOCAL, +}; +enum { + RTM_NEWLINK = 16, + RTM_NEWADDR = 20, +}; +struct rtattr { + unsigned short rta_len; + unsigned short rta_type; +}; +struct ifaddrs { + struct ifaddrs *ifa_next; + unsigned short ifa_flags; +}; +typedef unsigned short int uint16_t; +typedef unsigned int uint32_t; +struct nlmsg_list { + struct nlmsg_list *nlm_next; + int size; +}; +struct rtmaddr_ifamap { + void *address; + void *local; + int address_len; + int local_len; +}; +int usagi_getifaddrs (struct ifaddrs **ifap) +{ + struct nlmsg_list *nlmsg_list, *nlmsg_end, *nlm; + size_t dlen, xlen, nlen; + int build; + for (build = 0; build <= 1; build++) + { + struct ifaddrs *ifl = ((void *)0), *ifa = ((void *)0); + struct nlmsghdr *nlh, *nlh0; + uint16_t *ifflist = ((void *)0); + struct rtmaddr_ifamap ifamap; + for (nlm = nlmsg_list; nlm; nlm = nlm->nlm_next) + { + int nlmlen = nlm->size; + for (nlh = nlh0; + ((nlmlen) >= (int)sizeof(struct nlmsghdr) + && (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) + && (nlh)->nlmsg_len <= (nlmlen)); + nlh = ((nlmlen) -= ( (((nlh)->nlmsg_len)+4U -1) & ~(4U -1) ), + (struct nlmsghdr*)(((char*)(nlh)) + + ( (((nlh)->nlmsg_len)+4U -1) + & ~(4U -1) )))) + { + struct ifinfomsg *ifim = ((void *)0); + struct ifaddrmsg *ifam = ((void *)0); + struct rtattr *rta; + sa_family_t nlm_family = 0; + uint32_t nlm_scope = 0, nlm_index = 0; + memset (&ifamap, 0, sizeof (ifamap)); + switch (nlh->nlmsg_type) + { + case RTM_NEWLINK: + ifim = (struct ifinfomsg *) + ((void*)(((char*)nlh) + + ((0)+( ((((int) + ( ((sizeof(struct nlmsghdr))+4U -1) + & ~(4U -1) )))+4U -1) + & ~(4U -1) )))); + case RTM_NEWADDR: + ifam = (struct ifaddrmsg *) + ((void*)(((char*)nlh) + + ((0)+( ((((int) + ( ((sizeof(struct nlmsghdr))+4U -1) + & ~(4U -1) )))+4U -1) + & ~(4U -1) )))); + nlm_family = ifam->ifa_family; + if (build) + ifa->ifa_flags = ifflist[nlm_index]; + break; + default: + continue; + } + if (!build) + { + void *rtadata = ((void*)(((char*)(rta)) + + (( ((sizeof(struct rtattr))+4 -1) + & ~(4 -1) ) + (0)))); + size_t rtapayload = ((int)((rta)->rta_len) + - (( ((sizeof(struct rtattr))+4 -1) + & ~(4 -1) ) + (0))); + switch (nlh->nlmsg_type) + { + case RTM_NEWLINK: + break; + case RTM_NEWADDR: + if (nlm_family == 17) + break; + switch (rta->rta_type) + { + case IFA_ADDRESS: + ifamap.address = rtadata; + ifamap.address_len = rtapayload; + case IFA_LOCAL: + ifamap.local = rtadata; + } + } + } + if (nlh->nlmsg_type == RTM_NEWADDR && nlm_family != 17) + { + if (!ifamap.local) + { + ifamap.local = ifamap.address; + ifamap.local_len = ifamap.address_len; + } + if (!ifamap.address) + { + ifamap.address = ifamap.local; + } + if (ifamap.address_len != ifamap.local_len + || (ifamap.address != ((void *)0) + && memcmp (ifamap.address, ifamap.local, + ifamap.address_len))) + { + if (!build) + dlen += (((ifa_sa_len (nlm_family, + ifamap.address_len))+4U -1) + & ~(4U -1) ); + } + } + } + } + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53790.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53790.c new file mode 100644 index 000000000..0abd3dd83 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53790.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ + +typedef struct s { + int value; +} s_t; + +static inline int +read(s_t const *var) +{ + return var->value; +} + +int main() +{ + extern union u extern_var; + return read((s_t *)&extern_var); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53908.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53908.c new file mode 100644 index 000000000..e96b63522 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53908.c @@ -0,0 +1,288 @@ +/* { dg-do run } */ +/* SEGV at comment below. */ +typedef unsigned int size_t; +typedef enum har { + he_fatal = (-199), + he_not_initialized, + he_bad_input, + he_memory_too_small, + he_bad_action, + he_duplicate, + he_bad_nonce, + he_stale_nonce, + he_bad_credentials, + he_bad_user, + he_no_such_user, + he_bad_passwd, + he_unknown_auth_scheme, + he_not_found, + he_failed_digest_file_check, + he_failed_digest_file_save, + he_process_not_privileged, + he_other, + he_end_of_range, + ha_no_error = 0, + ha_no_value = 1 +} har; +typedef enum realm_type +{ + axis_realm = 0, + ws_realm +} realm_type; + +__attribute__((__noclone__, __noinline__)) +har has_www_auth(char *, size_t, realm_type, har); + +__attribute__((__noclone__, __noinline__)) +har has_auth_user(const char *, const char *, realm_type, char *, size_t); + +__attribute__((__noclone__, __noinline__)) +char *ha_get_string_value(void); + +typedef struct +{ + unsigned int track_id; + char* user; + char* realm; + char* authent; + int internal_realm; +} request; +enum user_response { + file_not_found_user_response = -3, + access_denied_user_response = -2, + no_user_response = -1, + ok_user_response = 0 +}; +struct realm_group { + char *name; + int id; + struct realm_group *next; +}; +struct realm { + char *name; + char *space; + struct realm_group *groups; + struct realm *next; +}; +struct user_info { + char *name; + int no_groups; + int groups[128]; + struct user_info *next; +}; +static struct user_info *find_user(const char *user_name); +static int is_member_of_groups(const struct user_info *user_item, + const struct realm_group *groups); +int authent_author(request *req); +struct realm *realms = ((void *)0); +struct user_info *users = ((void *)0); +static struct user_info* +find_user(const char *user_name) +{ + struct user_info *user_item; + user_item = users; + while (user_item != ((void *)0)) { + /* SEGV due to NULL access here on user_name. See also comment below. */ + if ((__builtin_strcmp(user_item->name, user_name) == 0)) + break; + user_item = user_item->next; + } + return user_item; +} +static int +is_member_of_groups(const struct user_info *user_item, + const struct realm_group *groups) +{ + const struct realm_group *group_item; + int i; + group_item = groups; + while (group_item != ((void *)0)) { + for (i = 0; i < user_item->no_groups; i++) + if (user_item->groups[i] == group_item->id) + return 0; + group_item = group_item->next; + } + return -1; +} +char *foo (void) __attribute__((__noclone__, __noinline__)); +char* g_strdup (const char *str) __attribute__((__malloc__, __noclone__, __noinline__)); +int g_strcmp0 (const char *str1, const char *str2); +static int +is_basic(char **user) +{ + char *passwd_ptr; + char *authent = foo(); + passwd_ptr = __builtin_strchr(authent, ':'); + if (passwd_ptr != ((void *)0)) { + *user = g_strdup(authent); + return 0; + } + return -1; +} +static int +is_digest(char **user) +{ + int ret_val = -1; + char *authent; + authent = ha_get_string_value(); + if (authent) { + *user = g_strdup(authent); + ret_val = 0; + } + return ret_val; +} +__attribute__((__noclone__, __noinline__)) +void g_free (void * mem); +static enum user_response +get_user_info_from_header(const realm_type type, + char **user_name, + struct user_info **user_item) +{ + int ret_val = no_user_response; + if ((type == ws_realm)) { + if (is_basic(user_name) == 0) + ret_val = access_denied_user_response; + if (is_digest(user_name) == 0) + ret_val = ok_user_response; + } else { + if (is_basic(user_name) < 0 && + /* Load of *user_name here, but not after the is_digest call. */ + is_digest(user_name) < 0) + ; + else if ((*user_item = find_user(*user_name)) != ((void *)0)) + ret_val = ok_user_response; + else + ret_val = access_denied_user_response; + if (ret_val != ok_user_response) + g_free(*user_name); + } + return ret_val; +} +static enum user_response +authenticate_user(request *req, + char **user_name, + struct user_info **user_item) +{ + char *authent = ((void *)0); + har resp = ha_no_value; + enum user_response user_resp; + int ret_val = no_user_response; + if (req->authent && __builtin_strlen(req->authent)) { + authent = req->authent; + user_resp = get_user_info_from_header(req->internal_realm, + user_name, + user_item); + if (user_resp == ok_user_response) { + resp = has_auth_user(authent, 0, req->internal_realm, "", 1); + if (resp == ha_no_error) + ret_val = ok_user_response; + else if (resp != he_stale_nonce) + ret_val = access_denied_user_response; + } else if (user_resp == access_denied_user_response) + ret_val = access_denied_user_response; + } + if (resp != he_memory_too_small && resp != ha_no_error) + resp = has_www_auth("", 1, req->internal_realm, resp); + return ret_val; +} + +int __attribute__ ((__noinline__, __noclone__)) +authent_author(request *req) +{ + struct realm *realm; + char *user_name = ((void *)0); + struct user_info *user_item = ((void *)0); + int res = 0; + asm (""); + realm = realms; + if (__builtin_strcmp("Wsd", realm->name) == 0) { + req->internal_realm = ws_realm; + is_digest(&user_name); + } + if (authenticate_user(req, &user_name, &user_item) < 0) { + if (user_name != ((void *)0)) + req->user = user_name; + res = -2; + goto authent_author_return; + } + if (is_member_of_groups(user_item, realm->groups) < 0) + res = -1; +authent_author_return: + return res; +} + +int good0, good1, good2; + +__attribute__ ((__noinline__, __noclone__)) +char *foo(void) +{ + asm (""); + good0++; + return ""; +} + +__attribute__ ((__noinline__, __noclone__)) +char *ha_get_string_value(void) +{ + asm (""); + good1++; + return "f"; +} + +__attribute__ ((__noinline__, __noclone__)) +har has_auth_user(const char *a, const char *b, realm_type c, char *d, size_t e) +{ + asm (""); + if (*a != 'z' || a[1] != 0 || b != 0 || c != axis_realm || *d != 0 + || e != 1) + __builtin_abort (); + return ha_no_error; +} + +__attribute__ ((__noinline__, __noclone__)) +har has_www_auth(char *a, size_t b, realm_type c, har d) +{ + (void)(*a+b+c+d); + asm (""); + __builtin_abort (); +} + + +char *strdupped_user = "me"; +__attribute__((__malloc__, __noclone__, __noinline__)) +char* g_strdup (const char *str) +{ + asm (""); + if (*str != 'f') + __builtin_abort (); + good2++; + return strdupped_user; +} + +__attribute__((__noclone__, __noinline__)) +void g_free (void * mem) +{ + (void)mem; + asm (""); + __builtin_abort (); +} + +struct user_info me = { .name = "me", .no_groups = 1, .groups = {42}, .next = 0}; +struct user_info you = { .name = "you", .next = &me}; +struct realm_group xgroups = { .name = "*", .id = 42, .next = 0}; + +int main(void) +{ + char *orig_user = "?"; + struct realm r = { .name = "x", .space = "space?", .groups = &xgroups, .next = 0}; + request req = { .user = orig_user, .realm = "!", .authent = "z", + .internal_realm = axis_realm}; + realms = &r; + users = &you; + if (authent_author (&req) != 0 || good0 != 1 || good1 != 1 || good2 != 1 + || req.user != orig_user + || req.internal_realm != axis_realm) + __builtin_abort (); + __builtin_exit (0); +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53922.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53922.c new file mode 100644 index 000000000..d385587e3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr53922.c @@ -0,0 +1,26 @@ +/* { dg-do run } */ +/* { dg-require-weak "" } */ +/* { dg-skip-if "No undefined" { *-*-mingw* } { "*" } { "" } } */ +/* { dg-skip-if "No undefined weak" { *-*-aix* } { "*" } { "" } } */ +/* { dg-skip-if "No undefined weak" { hppa*-*-hpux* && { ! lp64 } } { "*" } { "" } } */ +/* { dg-options "-Wl,-undefined,dynamic_lookup" { target *-*-darwin* } } */ + +int x(int a) +{ + return a; +} +int y(int a) __attribute__ ((weak)); +int g = 0; +int main() +{ + int (*scan_func)(int); + if (g) + scan_func = x; + else + scan_func = y; + + if (scan_func) + g = scan_func(10); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54027.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54027.c new file mode 100644 index 000000000..b5568f437 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54027.c @@ -0,0 +1,9 @@ +/* { dg-do run } */ + +int main (void) +{ + int x = 1; + while (x) + x <<= 1; + return x; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54098.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54098.c new file mode 100644 index 000000000..74398b689 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54098.c @@ -0,0 +1,72 @@ +/* { dg-do compile } */ + +extern int printf(const char *, ...); +struct list_head { + struct list_head *next, *prev; +}; +struct resource { + unsigned long long start; + unsigned long long end; + unsigned long flags; + struct resource *parent, *sibling, *child; +}; +struct pci_dev { + struct list_head bus_list; + struct resource resource[12]; +}; +struct pci_bus { + struct list_head devices; + unsigned char secondary; + unsigned char subordinate; +}; +struct resource *pci_bus_resource_n(const struct pci_bus *bus, int n); +static struct resource *find_free_bus_resource(struct pci_bus *bus, unsigned long type) { + int i; + struct resource *r; + unsigned long type_mask = 0x00000100 | 0x00000200 | 0x00002000; + for (i = 0; (r = pci_bus_resource_n(bus, i)) || i < 4; i++) { + if (r && (r->flags & type_mask) == type && !r->parent) return r; + } + return ((void *)0); +} +static unsigned long long calculate_memsize(unsigned long long size, unsigned long long min_size, unsigned long long size1, unsigned long long old_size, unsigned long long align) { + if (old_size == 1 ) old_size = 0; + if (size < old_size) size = old_size; + return size; +} +void pbus_size_mem(struct pci_bus *bus, unsigned long mask, unsigned long type, unsigned long long min_size, unsigned long long add_size, void *realloc_head) { + struct pci_dev *dev; + unsigned long long min_align, align, size, size0, size1; + int order; + struct resource *b_res = find_free_bus_resource(bus, type); + unsigned long long children_add_size = 0; + if (!b_res) return; + for (dev = ({ + const typeof( ((typeof(*dev) *)0)->bus_list ) *__mptr = ((&bus->devices)->next); + (typeof(*dev) *)( (char *)__mptr - __builtin_offsetof(typeof(*dev),bus_list) ); + } + ); + &dev->bus_list != (&bus->devices); + dev = ({ + const typeof( ((typeof(*dev) *)0)->bus_list ) *__mptr = (dev->bus_list.next); + (typeof(*dev) *)( (char *)__mptr - __builtin_offsetof(typeof(*dev),bus_list) ); + } + )) { + int i; + for (i = 0; i < 12; i++) { + struct resource *r = &dev->resource[i]; + unsigned long long r_size; + if (r->parent || (r->flags & mask) != type) continue; + r_size = r->end - r->start + 1; + if (order > 11) { + printf("%d: %pR %#llx\n", i, r, (unsigned long long) align); + } + size += r_size; + } + } + if (children_add_size > add_size) add_size = children_add_size; + size1 = (!realloc_head || (realloc_head && !add_size)) ? size0 : calculate_memsize(size, min_size+add_size, 0, b_res->end - b_res->start + 1, min_align); + if (!size0 && !size1) { + printf("%pR %02x-%02x\n", b_res, bus->secondary, bus->subordinate); + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54109.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54109.c new file mode 100644 index 000000000..d4d05263d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54109.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ + +typedef struct +{ + unsigned long bits[4]; +} nodemask_t; + +struct cpuset +{ + long flags; + nodemask_t mems_allowed; + struct cpuset *parent; +} b; + +void func1(unsigned long *p1, int p2) +{ + p1[p2 - 1] = 0; +} + +void func2(nodemask_t *p1, int p2) +{ + func1(p1->bits, p2); +} + +void func3(void) +{ + /* This accesses b.flags. */ + func2(&b.mems_allowed, 0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54127.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54127.c new file mode 100644 index 000000000..4f64998af --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54127.c @@ -0,0 +1,16 @@ +/* PR rtl-optimization/54127 */ +/* { dg-do compile } */ + +extern void foo (void) __attribute__ ((__noreturn__)); + +void +bar (int x) +{ + if (x < 0) + foo (); + if (x == 0) + return; + __asm goto ("# %l[lab] %l[lab2]" : : : : lab, lab2); +lab:; +lab2:; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54132.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54132.c new file mode 100644 index 000000000..97bc01caf --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54132.c @@ -0,0 +1,18 @@ +/* { dg-do run } */ + +extern void abort (void); +void foo(char *p, int n) +{ + int i; + for (i = 1; i < n; i++) + p[i] = p[i - 1]; +} +int main() +{ + char a[1024]; + a[0] = 1; + foo (a, 1024); + if (a[1023] != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54261-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54261-1.c new file mode 100644 index 000000000..571727b0c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54261-1.c @@ -0,0 +1,42 @@ +/* { dg-do run } */ +/* { dg-additional-options "-DSYNC_FALLBACK" { target { ! cas_int } } } */ + +#ifdef SYNC_FALLBACK +/* The SYNC_FALLBACK code is just so we don't have to restrict this test + to any subset of targets. For targets with no atomics support at + all, the cas_int effective-target is false and the fallback provides + a PASS. Where the bug trigs (at the time this test-case was added), + cas_int is also false but the fallback isn't used. */ +__attribute__((__noinline__, __noclone__)) +int +# if __INT_MAX__ == 0x7fff + __sync_fetch_and_add_2 +# else + __sync_fetch_and_add_4 +# endif + (int *at, int val) +{ + int tmp = *at; + asm (""); + *at = tmp + val; + return tmp; +} +#endif + +__attribute__((__noinline__, __noclone__)) +void g (int *at, int val) +{ + asm (""); + __sync_fetch_and_add (at, val); +} + +int main(void) +{ + int x = 41; + int a = 1; + g (&x, a); + + if (x != 42) + __builtin_abort (); + __builtin_exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54327.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54327.c new file mode 100644 index 000000000..fe7499aab --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54327.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +#include <string.h> +#include <stdlib.h> +void treathead () +{ + char *a = ';' == '\0' ? : 0; + if (*a == '=') + { + while (*a == (*a == 0) || *a == '\'') + a++; + if (strlen (a) < 2) + abort (); + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54409.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54409.c new file mode 100644 index 000000000..c7595474f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54409.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ + +int b; + +struct S +{ + char *p; + struct { + } s; + int a; +}; + +static _Bool +fn2 (int *p1) +{ + if (b) + { + struct S *c = (struct S *) &p1; + return c->a; + } +} + +_Bool +fn3 (struct S *p1) +{ + if (fn2 ((int *) &p1->s)) + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54436.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54436.c new file mode 100644 index 000000000..4bce32409 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54436.c @@ -0,0 +1,38 @@ +/* PR target/54436 */ +/* { dg-do assemble } */ + +#if __SIZEOF_SHORT__ == 2 && __SIZEOF_LONG_LONG__ == 8 +static inline unsigned short +baz (unsigned short *x) +{ + union U { unsigned short a; unsigned char b[2]; } u = { *x }; + u.b[0] = ((u.b[0] * 0x0802ULL & 0x22110ULL) + | (u.b[0] * 0x8020ULL & 0x88440ULL)) * 0x10101ULL >> 16; + u.b[1] = ((u.b[1] * 0x0802ULL & 0x22110ULL) + | (u.b[1] * 0x8020ULL & 0x88440ULL)) * 0x10101ULL >> 16; + unsigned char t = u.b[0]; + u.b[0] = u.b[1]; + u.b[1] = t; + return u.a; +} + +static inline unsigned long long +bar (unsigned long long *x) +{ + union U { unsigned long long a; unsigned short b[4]; } u = { *x }; + u.b[0] = baz (&u.b[0]); + return u.a; +} + +void +foo (void) +{ + unsigned long long l = -1ULL; + __asm volatile ("" : : "r" (bar (&l))); +} +#else +void +foo (void) +{ +} +#endif diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54458.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54458.c new file mode 100644 index 000000000..3d2e12fc2 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54458.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +unsigned int a, b, c; + +void +foo (unsigned int x) +{ + do + { + if (a == 0 ? 1 : 1 % a) + for (; b; b--) + lab:; + else + while (x) + ; + if (c) + goto lab; + } + while (1); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54520.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54520.c new file mode 100644 index 000000000..5884b2f35 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54520.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +char *a; +void +fn1 () +{ + char *p = a; + while (p && *p != '\0') + { + while (*p == '\t') + *p++ = '\0'; + if (*p != '\0') + p = 0; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54824.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54824.c new file mode 100644 index 000000000..82b822b09 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54824.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-w" } */ + +void __attribute__((noreturn)) bar(void) +{ +} + +void foo(int i, char *p, char *q) +{ + while (*p++) { + if (i) + p++; + if (!*q++) + bar(); + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54877.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54877.c new file mode 100644 index 000000000..cee406e50 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54877.c @@ -0,0 +1,23 @@ +/* PR tree-optimization/54877 */ +/* { dg-do run } */ +/* { dg-options "-ffast-math" } */ + +extern void abort (void); + +int +foo (void) +{ + double d; + int i; + for (i = 0, d = 0; i < 64; i++) + d--; + return (int) d; +} + +int +main () +{ + if (foo () != -64) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54894.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54894.c new file mode 100644 index 000000000..f243ec788 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54894.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target size32plus } */ + +typedef unsigned long long uint64_t; + +#define n 4096 +double A[n][n] __attribute__((aligned(16))); +double B[n][n] __attribute__((aligned(16))); +double C[n][n] __attribute__((aligned(16))); + +#define tilesize 128 + +typedef double adouble __attribute__((__aligned__(16))); + +void foo () +{ + int ih, jh, kh, il, kl, jl; + for (ih = 0; ih < n; ih += tilesize) + for (jh = 0; jh < n; jh += tilesize) + for (kh = 0; kh < n; kh += tilesize) + for (il = 0; il < tilesize; ++il) + { + adouble *Ap = (adouble *)&A[ih+il][kh]; + for (kl = 0; kl < tilesize; ++kl) + for (jl = 0; jl < tilesize; ++jl) + C[ih+il][jh+jl] += Ap[kl] * B[kh+kl][jh+jl]; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54920.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54920.c new file mode 100644 index 000000000..6b99e9ed2 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr54920.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-common" { target { hppa*-*-hpux* } } } */ + +typedef short __v8hi __attribute__ ((__vector_size__ (16))); +typedef long long __m128i __attribute__ ((__vector_size__ (16))); +int a; +__m128i b; + +void +fn1 () +{ + while (1) + b = (__m128i) (__v8hi) { a, 0, 0, 0, 0, 0 }; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55011.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55011.c new file mode 100644 index 000000000..67b2613f6 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55011.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ + +char a; + +void f(void) +{ + char b = 2; + + for(;;) + { + unsigned short s = 1, *p = &s, *i; + + for(*i = 0; *i < 4; ++*i) + if(a | (*p /= (b += !!a)) <= 63739) + return; + + if(!s) + a = 0; + + for(;;); + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55018.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55018.c new file mode 100644 index 000000000..d459b1ba6 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55018.c @@ -0,0 +1,23 @@ +/* PR tree-optimization/55018 */ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-optimized" } */ +/* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } } */ + +void +foo (int x) +{ + unsigned int a = 0; + int b = 3; + if (x) + b = 0; +lab: + if (x) + goto lab; + a++; + if (b != 2) + __builtin_printf ("%u", a); + goto lab; +} + +/* { dg-final { scan-tree-dump "printf" "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55107.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55107.c new file mode 100644 index 000000000..2402716be --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55107.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ + +typedef unsigned short uint16_t; + +uint16_t a, b; + +uint16_t f(void) +{ + int c, **p; + short d = 2, e = 4; + + for (;; b++) + { + int *j, k = 0; + + for (; *j; j++) + { + for(; c; c++) + for(; k < 1; k++) + { + short *f = &d; + + if(b) + return *f; + } + } + + if(!c) + d *= e; + + ((a = d) ? b = 0 : (**p ? : 1) != (d != 1 ? : (a = 0))) != (k ? a : 0) + < (a *= c = k) && (**p = 0); + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55111.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55111.c new file mode 100644 index 000000000..f5b0692c8 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55111.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ + +int a, b, c; +long d; +unsigned long *e; + +int f(void) +{ + for(;; a++) + { + if(c) + { + for(b = d = 0; b < 1; b++) + e = &d; + + --*e; + + if(d > 0) + a = 0; + + return d; + } + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55124.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55124.c new file mode 100644 index 000000000..a8eec984b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55124.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +int a, b; +long c; + +void f2(void) +{ + unsigned long k = 1; + + foo(b ? k = 0 : 0); + + b = ((c = b) ? (k ? : (c = 0)) : a) * c; +} + +void f1(void) +{ + f2(); + + a = b | c; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55238.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55238.c new file mode 100644 index 000000000..0ace05809 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55238.c @@ -0,0 +1,44 @@ +/* { dg-do compile } */ + +typedef void * gzFile; +typedef struct +{ + int mode; + int direct; + int seek; + int err; + char *msg; +} +gz_state; + +void gz_error (gz_state *state, int err, char *msg); + +static void +gz_reset (gz_state *state) +{ + if (state->mode == 7247) + { + state->direct = 1; + } + state->seek = 0; + gz_error (state, 0, 0); +} + +int +gzbuffer (void *file, int size) +{ + gz_state *state; + gz_reset (state); +} + +void gz_error (gz_state *state, int err, char *msg) +{ + if (state->msg != 0) + { + if (state->err != -4) + foo (state->msg); + } + if (msg == 0) + return; + bar (state->msg, msg); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55253.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55253.c new file mode 100644 index 000000000..9f6491d4c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55253.c @@ -0,0 +1,48 @@ +/* { dg-do run } */ + +struct +{ + int mallocFailed; +} +*a; + +struct StrAccum +{ + int useMalloc; +} +b, c; + +static void +fn1 (struct StrAccum *p1, int p2) +{ + if (p2 == 0) + return; + if (p1->useMalloc) + a->mallocFailed = 0; +} + +void +fn2 (struct StrAccum *p1) +{ + fn1 (p1, 1); +} + +void +fn3 (struct StrAccum *p1) +{ + fn1 (p1, 1); +} + +void +fn4 () +{ + c.useMalloc = 1; + fn1 (&c, 0); +} + +int +main () +{ + fn3 (&b); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55270.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55270.c new file mode 100644 index 000000000..0b7f906d0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55270.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ + +unsigned a, b, c; + +void f(void) +{ + for(; a; a++) + { + long *p1 = (long *)&b; + + if(*p1) + return; + + if(b && (*p1 = b) || c && ++*p1) + { + unsigned *p2 = &b; + + for(*p2 = 0; *p2 < 1;) + for(; b; b++); + } + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55305.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55305.c new file mode 100644 index 000000000..fb6144715 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55305.c @@ -0,0 +1,151 @@ +/* { dg-do run } */ + +extern void exit (int) __attribute__ ((noreturn)); +extern void abort (void) __attribute__ ((noreturn)); + +struct t +{ + char dummy; +}; + +struct m +{ + const struct t *t; + void (*m)(void); +}; + +struct s +{ + const struct m *m; + void *o; +}; + +struct e +{ + const struct t *t; + void *o; +}; + +struct ret +{ + struct s s; + _Bool b; +}; + +const struct t t1 = { 1 }; +const struct t t2 = { 2 }; +const struct t t3 = { 3 }; +const struct t t4 = { 4 }; +const struct t t5 = { 5 }; + +void +pass (void) +{ + exit (0); +} + +void +fail (void) +{ + abort (); +} + +const struct m m1 = { &t4, fail }; +const struct m m2 = { &t5, pass }; + +static struct e f2 (struct s s2, void *p); +static struct e f3 (struct s, void *) __attribute__ ((noinline)); +static void f4 (struct s, void *) __attribute__ ((noinline)); + +struct ret c (struct s, const struct t *) __attribute__ ((noinline)); + +struct ret +c (struct s s1, const struct t *t) +{ + struct ret r; + + if (s1.m->t == t) + { + r.s.m = &m2; + r.s.o = s1.o; + r.b = 1; + } + else + { + r.s.m = 0; + r.s.o = 0; + r.b = 0; + } + return r; +} + +void *m (void) __attribute__ ((noinline)); + +void * +m (void) +{ + return 0; +} + +struct e +f1 (struct s s1, void *p) +{ + struct ret r; + void *a; + struct s a2; + + r = c (s1, &t5); + if (r.b) + return f2 (r.s, p); + a = m (); + a2.m = &m1; + a2.o = a; + return f2 (a2, p); +} + +static struct e +f2 (struct s s2, void *p) +{ + struct e e1; + + e1 = f3 (s2, p); + if (e1.t == &t2 && e1.o == 0) + { + e1.t = 0; + e1.o = 0; + } + return e1; +} + +static struct e +f3 (struct s s1, void *p) +{ + struct e r; + + f4 (s1, p); + r.t = &t3; + r.o = 0; + return r; +} + +struct s g1; +void *g2; + +static void +f4 (struct s s1, void *p) +{ + g1 = s1; + g2 = p; + s1.m->m (); +} + +int +main () +{ + struct s s1; + + s1.m = &m2; + s1.o = 0; + f1 (s1, 0); + abort (); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55481.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55481.c new file mode 100644 index 000000000..26ba9ff7d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55481.c @@ -0,0 +1,16 @@ +/* { dg-do run } */ + +int main() +{ + signed char result = 0; + int n; + for (n = 0; n < 13; ++n) + { + int tem = result; + tem = tem + 31; + result = tem; + } + if (result != -109) + __builtin_abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55555.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55555.c new file mode 100644 index 000000000..9e4226659 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55555.c @@ -0,0 +1,34 @@ +/* { dg-do run } */ + +double s[4] = { 1.0, 2.0, 3.0, 4.0 }, pol_x[2] = { 5.0, 6.0 }; + +__attribute__((noinline)) int +foo (void) +{ + double coef_x[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + int lxp = 0; + if (lxp <= 1) + do + { + double t = pol_x[lxp]; + long S; + long l = lxp * 4L - 1; + for (S = 1; S <= 4; S++) + coef_x[S + l] = coef_x[S + l] + s[S - 1] * t; + } + while (lxp++ != 1); + asm volatile ("" : : "r" (coef_x) : "memory"); + for (lxp = 0; lxp < 8; lxp++) + if (coef_x[lxp] != ((lxp & 3) + 1) * (5.0 + (lxp >= 4))) + __builtin_abort (); + return 1; +} + +int +main () +{ + asm volatile ("" : : : "memory"); + if (!foo ()) + __builtin_abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55633.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55633.c new file mode 100644 index 000000000..5d30d61a6 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55633.c @@ -0,0 +1,39 @@ +/* PR fortran/55633 */ +/* { dg-do run { target int128 } } */ + +extern void abort (void); + +__attribute__((noinline, noclone)) void +bar (__int128_t *x) +{ + int c = sizeof (__int128_t) * __CHAR_BIT__; + if (c > 127) + c = 127; + if (*x != c) + abort (); +} + +__attribute__((noinline)) void +foo (void) +{ + __int128_t m, ma; + ma = 0; + m = 0; + m = ~m; + do + { + if (m == 0 || ma > 126) + break; + ma = ma + 1; + m = ((__uint128_t) m) >> 1; + } + while (1); + bar (&ma); +} + +int +main () +{ + foo (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55684.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55684.c new file mode 100644 index 000000000..7002a3737 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55684.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ + +typedef struct _IO_FILE FILE; +unsigned long int strtoul(const char *, char **, int); +char *fgets(char *, int, FILE *); +struct ihexrec { + unsigned char reclen; + unsigned char data[256]; +}; +static void srec_readrec(struct ihexrec * srec, char * rec) +{ + int i, j; + char buf[8]; + int offset = 0, len; + char * e; + for (i=0; j<srec->reclen; j++) + { + if (offset+2 > len) + return; + for (i=0; i<2; i++) + buf[i] = rec[offset++]; + srec->data[j] = strtoul(buf, &e, 16); + } + for (i=0; i<2; i++) + buf[i] = rec[offset++]; +} +void srec2b(FILE *inf) +{ + char buffer[256]; + struct ihexrec srec; + while (fgets(buffer,256,inf)!=(void *)0) + srec_readrec(&srec, buffer); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55687.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55687.c new file mode 100644 index 000000000..1eab1a4f6 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55687.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ + +typedef struct _IO_FILE FILE; +typedef short gshort; +typedef struct _GString GString; + +extern char *fgets(char *, int, FILE *); + +void verbose_text_loop (void *data) +{ + FILE *dev_vcs; + char buf[81]; + GString *buf_str; + gshort i, j; + while (1) + { + for (i = 1; i <= 7; i++) + { + while (fgets (buf, 81, dev_vcs)) + { + for (j = 0; j < __builtin_strlen (buf); j++) + if (buf[j] != ' ') + break; + for (; j < __builtin_strlen (buf); j++) + g_string_append_c_inline (buf_str, buf[j]); + } + } + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55755.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55755.c new file mode 100644 index 000000000..3c8bb6ba4 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55755.c @@ -0,0 +1,43 @@ +/* { dg-do run } */ +/* { dg-require-effective-target int32plus } */ + +struct S4 +{ + unsigned f0:24; +} __attribute__((__packed__)); + +struct S4 g_10 = { + 6210831 +}; + +struct S5 +{ + int i; + struct S4 l_8[2]; +} __attribute__((__packed__)); + +int a, b; + +struct S4 func_2 (int x) +{ + struct S5 l = { + 0, + {{0}, {0}} + }; + l.i = a; + g_10 = l.l_8[1]; + for (; x<2; x++) { + struct S4 tmp = { + 11936567 + }; + l.l_8[x] = tmp; + } + b = l.i; + return g_10; +} + +int main (void) +{ + func_2 (0); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55862.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55862.c new file mode 100644 index 000000000..eb8dceb9b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55862.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */
+
+int g, a, *b;
+
+void f(void)
+{
+ int *p;
+
+ if(g)
+ {
+ int **k = &p;
+
+ for(; g; p++)
+ for(a = 0; a < 1; a++)
+ {
+ int *c = p;
+label2:
+ if(a < 1)
+ *c = 0;
+ }
+
+ goto label1;
+
+ while(g++)
+ for(*b = 0; *b; b++)
+ label1:
+ ;
+ }
+
+ goto label2;
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55882.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55882.c new file mode 100644 index 000000000..fd2276e7f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55882.c @@ -0,0 +1,94 @@ +/* { dg-do run } */ + +typedef enum +{ + PVT_A = 0, + PVT_B = 1, + PVT_CONFIG = 2, + PVT_RESERVED3 = 3, +} T_CR_SELECT; + +typedef enum +{ + STD_ULOGIC_0 = 0, + STD_ULOGIC_1 = 1, +} STD_ULOGIC; + +typedef struct +{ + unsigned char rtp : 3; + unsigned char rtn : 3; +} C; + +typedef struct +{ + unsigned char nd; + unsigned char pd; + unsigned char rtn; + unsigned char rtp; +} A; + +typedef struct +{ + unsigned short reserved : 14; + unsigned char Z_rx_enable : 2; + A pvt; +} B; + +typedef struct +{ + B cr_dsclk_q3; + B cr_data_q3; + B cr_addr_q3; + B cr_cmd_q3; + B cr_pres_q3; + C cr_vref_q3[6]; + unsigned char pres_disable; + unsigned char pres_drive_high; + unsigned char c_enab_120; + STD_ULOGIC clk_tximp; + STD_ULOGIC dqs_tximp; + STD_ULOGIC cmd_tximp; + STD_ULOGIC data_tximp; + STD_ULOGIC dqs_rxterm; + STD_ULOGIC data_rxterm; + T_CR_SELECT cr_clk_sel; + unsigned char cr_clk : 5; + T_CR_SELECT cr_dsclk_odd_sel; + unsigned char cr_dsclk_odd : 5; + T_CR_SELECT cr_dsclk_even_sel; + unsigned char cr_dsclk_even : 5; + T_CR_SELECT cr_data_sel; + unsigned char cr_data : 5; + T_CR_SELECT cr_vref_sel; + unsigned char cr_vref : 5; + T_CR_SELECT cr_others_sel; + unsigned char cr_others : 5; +} CONFIG; + +typedef struct +{ + unsigned char enable_monitor; + unsigned short step_out_pointer : 12; + unsigned short hold_out_pointer : 12; + unsigned short enable_wr_dqs : 12; + unsigned short use_alt_rd_dqs : 12; + CONFIG io_buf; +} mystruct; + +unsigned short __attribute__((noinline,noclone)) +testfunction(unsigned i) +{ + mystruct dmfe[8]; + dmfe[0].use_alt_rd_dqs = 1; + dmfe[i].use_alt_rd_dqs = 0; + return dmfe[0].use_alt_rd_dqs; +} + +extern void abort (void); +int main () +{ + if (testfunction(0) != 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55888.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55888.c new file mode 100644 index 000000000..e75adcd2c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55888.c @@ -0,0 +1,116 @@ +/* { dg-do compile } */ + +typedef unsigned _GCC_ATTR_ALIGN_u32t; +typedef _GCC_ATTR_ALIGN_u32t _Uint32t __attribute__ ((__aligned__ (4))); +typedef unsigned int _GCC_ATTR_ALIGN_u8t __attribute__ ((__mode__ (__QI__))); +typedef _GCC_ATTR_ALIGN_u8t _Uint8t __attribute__ ((__aligned__ (1))); +typedef unsigned _Sizet; +typedef _Sizet size_t; +typedef _Uint8t uint8_t; +typedef _Uint32t uint32_t; +typedef enum +{ + PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_LABEL_REPEATED +} +ProtobufCLabel; +typedef enum +{ + PROTOBUF_C_TYPE_INT32, PROTOBUF_C_TYPE_SINT32, PROTOBUF_C_TYPE_SFIXED32, + PROTOBUF_C_TYPE_INT64, PROTOBUF_C_TYPE_SINT64, PROTOBUF_C_TYPE_SFIXED64, + PROTOBUF_C_TYPE_UINT32, PROTOBUF_C_TYPE_FIXED32, PROTOBUF_C_TYPE_UINT64, + PROTOBUF_C_TYPE_FIXED64, PROTOBUF_C_TYPE_FLOAT, PROTOBUF_C_TYPE_DOUBLE, + PROTOBUF_C_TYPE_BOOL, PROTOBUF_C_TYPE_ENUM, PROTOBUF_C_TYPE_STRING, + PROTOBUF_C_TYPE_BYTES, PROTOBUF_C_TYPE_MESSAGE, +} +ProtobufCType; +typedef struct _ProtobufCBinaryData ProtobufCBinaryData; +struct _ProtobufCBinaryData +{ + size_t len; +}; +typedef struct _ProtobufCMessageDescriptor ProtobufCMessageDescriptor; +typedef struct _ProtobufCFieldDescriptor ProtobufCFieldDescriptor; +typedef struct _ProtobufCMessage ProtobufCMessage; +struct _ProtobufCFieldDescriptor +{ + uint32_t id; + ProtobufCLabel label; + ProtobufCType type; + unsigned offset; +}; +struct _ProtobufCMessageDescriptor +{ + unsigned n_fields; + const ProtobufCFieldDescriptor *fields; +}; +struct _ProtobufCMessage +{ + const ProtobufCMessageDescriptor *descriptor; +}; +typedef enum +{ + PROTOBUF_C_WIRE_TYPE_VARINT, PROTOBUF_C_WIRE_TYPE_64BIT, + PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED, PROTOBUF_C_WIRE_TYPE_START_GROUP, + PROTOBUF_C_WIRE_TYPE_END_GROUP, PROTOBUF_C_WIRE_TYPE_32BIT +} +ProtobufCWireType; +static inline size_t +uint32_pack (uint32_t value, uint8_t * out) +{ + unsigned rv = 0; + if (value >= 0x80) + { + if (value >= 0x80) + { + value >>= 7; + } + } + out[rv++] = value; +} + +static inline size_t +binary_data_pack (const ProtobufCBinaryData * bd, uint8_t * out) +{ + size_t len = bd->len; + size_t rv = uint32_pack (len, out); + return rv + len; +} + +static size_t +required_field_pack (const ProtobufCFieldDescriptor * field, + const void *member, uint8_t * out) +{ + size_t rv = tag_pack (field->id, out); + switch (field->type) + { + case PROTOBUF_C_TYPE_BYTES: + { + const ProtobufCBinaryData *bd = + ((const ProtobufCBinaryData *) member); + out[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED; + return rv + binary_data_pack (bd, out + rv); + } + case PROTOBUF_C_TYPE_MESSAGE: + { + out[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED; + return rv + + prefixed_message_pack (*(ProtobufCMessage * const *) member, + out + rv); + } + } +} + +size_t +protobuf_c_message_pack (const ProtobufCMessage * message, uint8_t * out) +{ + unsigned i; + size_t rv = 0; + for (i = 0; i < message->descriptor->n_fields; i++) + { + const ProtobufCFieldDescriptor *field = message->descriptor->fields + i; + const void *member = ((const char *) message) + field->offset; + if (field->label == PROTOBUF_C_LABEL_REQUIRED) + rv += required_field_pack (field, member, out + rv); + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55890-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55890-1.c new file mode 100644 index 000000000..9fd558ea0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55890-1.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ + +extern void *memmove(void *, void *, __SIZE_TYPE__); +typedef int (*_TEST_fun_) (); +static _TEST_fun_ i = (_TEST_fun_) memmove; +main() { i(); } diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55890-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55890-2.c new file mode 100644 index 000000000..a753e573d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55890-2.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */
+
+extern void *memcpy();
+main() { memcpy(); }
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55890-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55890-3.c new file mode 100644 index 000000000..c7f77be68 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55890-3.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ + +void *memmove (); + +void * +bar () +{ + return memmove (); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55964-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55964-2.c new file mode 100644 index 000000000..a3bd09d5b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55964-2.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-ftree-loop-distribution -funswitch-loops" } */ + +struct test_struct { + int a, b[10], c[10], d[10]; +}; + +extern struct test_struct* new_struct; + +void testfunc(struct test_struct* old_struct) +{ + int i; + for (i = 0; i < 10; ++i) + { + new_struct->b[i] = old_struct ? old_struct->b[i] : -1; + new_struct->c[i] = old_struct ? old_struct->c[i] : 0; + new_struct->d[i] = old_struct ? old_struct->d[i] : 0; + } + if (old_struct) + old_struct->a++; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55964.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55964.c new file mode 100644 index 000000000..361151ccf --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr55964.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-ftree-loop-distribution -funswitch-loops -w" } */ + +int a, b; + +void f(void) +{ +lbl1: + for(b = 0; b < 1; b++) + { + int u = 1; + + if((b %= 0) * (b ? 0 : a) - 1 && (u /= 0)) + { + int *q = &u, **k = q; + goto lbl1; +lbl2: +lbl3: + a = **k; + goto lbl2; + } + } + goto lbl3; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56034.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56034.c new file mode 100644 index 000000000..f2b5d3784 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56034.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-ftree-loop-distribution" } */ + +int a, b, *p; + +void f(void) +{ + int *q; + + while(b++) + { + int i; + p = &i; + a = *q; + } + + if(a) + for(;; b++); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56150.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56150.c new file mode 100644 index 000000000..6de1115a2 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56150.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ + +struct { + int f4; +} g1; + +long g2; + +volatile long g3; + +void func_1 () +{ + if (g2) + g1 = g1; + else + g3; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56157.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56157.c new file mode 100644 index 000000000..796e3235c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56157.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-ftree-vectorize" } */ + +struct Pixel { + unsigned short r; + unsigned short g; + unsigned short b; + unsigned short a; +}; + +void fn(unsigned char * __restrict dst, const unsigned char * __restrict src) +{ + unsigned x; + for(x = 0; x < 1024; x += 1) + { + struct Pixel pixel; + pixel.r = (unsigned short)(((unsigned)src[0]) * 0xffff / 0xff); + pixel.g = (unsigned short)(((unsigned)src[1]) * 0xffff / 0xff); + pixel.b = (unsigned short)(((unsigned)src[2]) * 0xffff / 0xff); + pixel.a = (unsigned short)(((unsigned)src[3]) * 0xffff / 0xff); + __builtin_memcpy(dst, &pixel, sizeof pixel); + src += 4; + dst += 8; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56181.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56181.c new file mode 100644 index 000000000..c382b29c4 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56181.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */
+/* { dg-options "-ftracer" } */
+
+int a, b;
+
+void f(void)
+{
+ if(a++)
+ {
+ for(a = 0; a < 1;)
+ {
+ for(b = 0; b < 1; b++)
+ {
+ while(a++ < 0);
+lbl:
+ ;
+ }
+
+ if(a)
+ goto lbl;
+ }
+
+ goto lbl;
+ }
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56195.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56195.c new file mode 100644 index 000000000..d1949fd0e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56195.c @@ -0,0 +1,31 @@ +/* PR rtl-optimization/56195 */ +/* { dg-do assemble } */ + +int i, a, t, b, c, d, e, f, j, *h; + +void +fn (void) +{ + if (b) + { + int *p, *q; + char g; + + if (f++) + for (;; e++); + lbl: + for (b = 0; b < 2; b++) + t /= d + 1 ? : i || a < c < (d = f) ? : 1 | (j = 2); + + *p = g >= *q ^ c != a ^ *p; + + if (!e) + { + q = p; + goto lbl; + } + } + + if (h++) + goto lbl; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56264.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56264.c new file mode 100644 index 000000000..ca5eb47ff --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56264.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */
+/* { dg-options "-funswitch-loops" } */
+
+int a, b, c;
+
+void f(void)
+{
+ if(b)
+ {
+ for(a = 0; a < 1; a++)
+ lbl:
+ c = c && b ? : 0;
+
+ c = 0;
+ goto lbl;
+ }
+
+ if(a)
+ goto lbl;
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56321.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56321.c new file mode 100644 index 000000000..a8c463465 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56321.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-ffast-math" } */ + +void foo(int n, int nreps, float tdgefa, float tdgesl) +{ + float kflops,ops; + ops=((2.0*n*n*n)/3.0+2.0*n*n); + kflops=2.*nreps*ops/(1000.*(tdgefa+tdgesl)); + + __builtin_printf ("%f\n", kflops); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56349.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56349.c new file mode 100644 index 000000000..dc9ed082b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56349.c @@ -0,0 +1,41 @@ +/* { dg-do compile } */ + +int a, b; +short c; + +void f(void) +{ + int a = 0; + int *k = 0; + + for(; a < 2; a++); + + if(!!(b |= a < 3) - 1) + { + if(0) + for (;; a++) + { + for (; c; *k = 0); +lbl1: + ; + } + + for(; *k; k++) + { + c = b ? : a; + + if (c) + lbl2: + b = 0; + } + goto lbl1; + } + + for(;; b++) + { + if(b) + goto lbl2; + + k = &b; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56366.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56366.c new file mode 100644 index 000000000..15a430048 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56366.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ + +int a, *c, d; +unsigned short b; +short e; + +void f(void) +{ + for(;; d++) + { + for(a = -9; a < 63; a++) + for(d = 0; d < 9; d++) + b -= --e; + + a = b & *c; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56384.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56384.c new file mode 100644 index 000000000..ef3cf0536 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56384.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ + +int a, c; + +void f(void) +{ + unsigned char b; + + if(a) + { + for(; b < 1; b++); +lbl1: + c = (b |= 0) ^ (b || a); + } + + if((a = b)) + { + b = c; + goto lbl1; + } + + b = 5; + goto lbl1; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56407.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56407.c new file mode 100644 index 000000000..f26fd23f7 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56407.c @@ -0,0 +1,48 @@ +/* { dg-do run } */ + +extern void abort(void); +extern int rand(void); + +static void copy(int *r,int *a,int na) +{ + int i; + for( i = 0 ; i < na ; i++ ) + r[i] = a[i]; +} + +static void foo(int *a,int na) +{ + int i; + for( i = 0 ; i < na ; i++ ) + a[i] = rand(); +} + +static int cmp(int *a,int *b,int n) +{ + int i; + for( i = 0 ; i < n ; i++ ) + if ( a[i] != b[i] ) + return -1; + return 0; +} + +void __attribute__((noinline,noclone)) +test(int sz,int comm) +{ + int j,n; + int v[64],w[64]; + for( j = 1 ; j <= sz ; j++ ) + { + n = (2 * j - 1) * (2 * j - 1); + foo(w,n); + copy(v,w,n); + if ( comm ) + if ( cmp(v,w,n) ) abort (); + } +} + +int main() +{ + test(2,1); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56420.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56420.c new file mode 100644 index 000000000..6fa1a803d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56420.c @@ -0,0 +1,37 @@ +/* PR middle-end/56420 */ +/* { dg-do run { target int128 } } */ + +extern void abort (void); + +__attribute__((noinline, noclone)) __uint128_t +foo (__uint128_t x) +{ + return x * (((__uint128_t) -1) << 63); +} + +__attribute__((noinline, noclone)) __uint128_t +bar (__uint128_t x) +{ + return x * (((__uint128_t) 1) << 63); +} + +__attribute__((noinline, noclone)) __uint128_t +baz (__uint128_t x) +{ + return x * -(((__uint128_t) 1) << 62); +} + +int +main () +{ + if (foo (1) != (((__uint128_t) -1) << 63) + || foo (8) != (((__uint128_t) -1) << 66)) + abort (); + if (bar (1) != (((__uint128_t) 1) << 63) + || bar (8) != (((__uint128_t) 1) << 66)) + abort (); + if (baz (1) != -(((__uint128_t) 1) << 62) + || baz (8) != ((-(((__uint128_t) 1) << 62)) << 3)) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56443.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56443.c new file mode 100644 index 000000000..ed60e05af --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56443.c @@ -0,0 +1,29 @@ +/* PR tree-optimization/56443 */ +/* { dg-do run } */ +/* { dg-options "-ftree-vectorize" } */ + +extern void abort (void); +typedef int myint __attribute__ ((__aligned__ (16))); + +int a1[1024] __attribute__ ((__aligned__ (16))); +int a2[1024] __attribute__ ((__aligned__ (16))); + +__attribute__((noinline, noclone)) void +test (int n, myint * __restrict__ p1, myint * __restrict__ p2) +{ + while (n--) + *p1++ = *p2++ + 1; +} + +int +main () +{ + int n; + for (n = 0; n < 1024; n++) + a2[n] = n; + test (1024, a1, a2); + for (n = 0; n < 1024; n++) + if (a1[n] != a2[n] + 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56478.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56478.c new file mode 100644 index 000000000..506204e8b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56478.c @@ -0,0 +1,12 @@ +/* PR tree-optimization/56478 */ +/* { dg-do compile } */ + +int a; + +void +foo () +{ + int b; + for (b = 0;; b++) + a = 0 < -__LONG_LONG_MAX__ - 1 - b ? : 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56488.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56488.c new file mode 100644 index 000000000..94add8d9d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56488.c @@ -0,0 +1,32 @@ +/* { dg-do run { target { size32plus } } } */ +/* { dg-require-effective-target int32plus } */ + +int a, c, d = 1; +struct S { int s; } b, f; +short e; + +static void +foo (int x) +{ + int g[] = { }; + for (e = 0; e != 1; e = e + 5) + { + int *h[1] = { &g[0] }; + if (!x) + return; + f = b; + } +} + +int +main () +{ + int i, j; + for (i = 0; i < 6; i++) + for (j = 8; j; j--) + a = 0; + foo (d); + while (c) + ; + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56501.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56501.c new file mode 100644 index 000000000..d6fc29d7b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56501.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-w" } */ + +int a; +void try_help () __attribute__ ((__noreturn__)); +void try_help () +{ +} + +int main () +{ + switch (a) + { + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + break; + default: + try_help (); + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56661.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56661.c new file mode 100644 index 000000000..6fdaedb31 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56661.c @@ -0,0 +1,46 @@ +/* { dg-do run } */ + +__attribute__((noinline, noclone)) void +bar (int *b) +{ + b[0] = b[1] = b[2] = 1; +} + +__attribute__((noinline, noclone)) int +baz (int x) +{ + if (x != 1) + __builtin_abort (); +} + +void +foo (int x) +{ + if (x == 0) + { + int *b = __builtin_malloc (3 * sizeof (int)); + while (b[0]) + ; + } + else if (x == 1) + { + int i, j; + int *b = __builtin_malloc (3 * sizeof (int)); + for (i = 0; i < 2; i++) + { + bar (b); + for (j = 0; j < 3; ++j) + baz (b[j]); + baz (b[0]); + } + } +} + +int +main () +{ + int x = 1; + asm volatile ("" : "+r" (x)); + foo (x); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56689.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56689.c new file mode 100644 index 000000000..719f528c2 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56689.c @@ -0,0 +1,46 @@ +/* { dg-do compile } */ + +extern int baz (); +extern void bar (void); +extern void noret (void) __attribute__ ((__noreturn__)); + +void +fix_register (const char *name, int fixed, int call_used, int nregs) +{ + int i; + int reg; + + if ((reg = baz ()) >= 0) + { + for (i = reg; i < nregs; i++) + { + if ((i == 15 || i == 11) && (fixed == 0 || call_used == 0)) + { + switch (fixed) + { + case 0: + switch (call_used) + { + case 1: + bar (); + break; + default: + (noret ()); + } + case 1: + switch (call_used) + { + case 1: + break; + case 0: + default: + (noret ()); + } + break; + default: + (noret ()); + } + } + } + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56756.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56756.c new file mode 100644 index 000000000..470014d26 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56756.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ + +int a, *b; + +void f(void) +{ + if(a) + { + int k; + + for(a = 0; a < 1; a++) + { + int **q; + f(); + + for(; **q; ++**q) + lbl: + if(a) + { + a = 0; + goto lbl; + } + + b = &k; + } + } + goto lbl; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56778.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56778.c new file mode 100644 index 000000000..48068774a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr56778.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-march=core-avx2" { target x86_64-*-* } } */ + +typedef struct { + float a,b,c; +} S; + +S * arr[100]; + +void bar (float *in[], int n) +{ + int i; + for (i=0; i<n; i++) + (*in)[i] = -arr[i]->b; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57026.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57026.c new file mode 100644 index 000000000..e37895486 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57026.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ + +typedef struct __jmp_buf_tag { char buf[1024]; } jmp_buf[1]; +extern int setjmp (jmp_buf); +extern int bar (unsigned int *); +extern jmp_buf *baz (void); +struct C { int c1; unsigned int c2, c3, c4; }; + +void +foo (struct C *x, const int *y, unsigned int *z, unsigned int e, unsigned int g) +{ + unsigned int d = 0; + unsigned long f; + setjmp (*baz ()); + f = d; + if ((x->c1 || x->c2) && g && (!e || d >= 8)) + d = 16; + else + d = 8; + if ((!x->c3 && !x->c4 || *y == 0) && !e && bar (z)) + *z = f; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57036-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57036-1.c new file mode 100644 index 000000000..5aa63bd75 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57036-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ + +extern void g (void); +extern __inline __attribute__ ((__always_inline__,__leaf__)) +f () +{ + g (); +} +struct __jmp_buf_tag *b; +int jpgDecode_convert (unsigned i) +{ + if (i != 0) + f (); + read_buf_open (); + return _setjmp (b); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57036-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57036-2.c new file mode 100644 index 000000000..25de5cd15 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57036-2.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ + +int j_; +int jpgDecode_convert (unsigned i) +{ + __label__ label; + int j; + + inline void __attribute__((always_inline,leaf)) f(void) + { + g(); + } + + void __attribute__((noinline)) read_buf_open (void) + { + goto label; + } + + if (i != 0) + f (); + j = j_; + read_buf_open (); +label: + return j; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57075.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57075.c new file mode 100644 index 000000000..dee74a844 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57075.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +extern int baz (void) __attribute__ ((returns_twice)); +int __attribute__ ((__leaf__)) +foo (void) +{ + return __builtin_printf ("$"); +} + +void +bar () +{ + foo (); + baz (); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57081.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57081.c new file mode 100644 index 000000000..0fcbaaa62 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57081.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ + +int a; + +void f(void) +{ + int b; + + if(0) + lbl: + goto lbl; + + if(b) + { + int p = 0; + goto lbl; + } + + a = 0; + while(b++); + goto lbl; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57083.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57083.c new file mode 100644 index 000000000..070a53d21 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57083.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/57083 */ +/* { dg-do run { target int32plus } } */ + +extern void abort (void); +short x = 1; +int y = 0; + +int +main () +{ + unsigned t = (0x7fff8001U - x) << (y == 0); + if (t != 0xffff0000U) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57122.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57122.c new file mode 100644 index 000000000..f1b99c862 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57122.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ + +unsigned a; +int b, c; + +void f(void) +{ + if(a) + { + for(a = 0; a < 2; a++) + a /= 7; + + for(;; a++) + { + if(a) + lbl1: + b++; + + if(c) + goto lbl1; +lbl2: + ; + } + } + + goto lbl2; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57147-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57147-1.c new file mode 100644 index 000000000..e5ad54499 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57147-1.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-optimized" } */ +/* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } } */ + +struct __jmp_buf_tag {}; +typedef struct __jmp_buf_tag jmp_buf[1]; +extern int _setjmp (struct __jmp_buf_tag __env[1]); + +jmp_buf g_return_jmp_buf; + +void SetNaClSwitchExpectations (void) +{ +} +void TestSyscall(void) +{ + SetNaClSwitchExpectations(); + _setjmp (g_return_jmp_buf); +} + +/* { dg-final { scan-tree-dump-not "builtin_unreachable" "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57147-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57147-2.c new file mode 100644 index 000000000..521d126e3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57147-2.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-optimized" } */ +/* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } } */ + +struct __jmp_buf_tag {}; +typedef struct __jmp_buf_tag jmp_buf[1]; +extern int _setjmp (struct __jmp_buf_tag __env[1]); + +jmp_buf g_return_jmp_buf; + +void SetNaClSwitchExpectations (void) +{ + __builtin_longjmp (g_return_jmp_buf, 1); +} +void TestSyscall(void) +{ + SetNaClSwitchExpectations(); + _setjmp (g_return_jmp_buf); +} + +/* { dg-final { scan-tree-dump "setjmp" "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57147-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57147-3.c new file mode 100644 index 000000000..c64e5adb0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57147-3.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +typedef char * ptr_t; +struct __jmp_buf_tag { +}; +typedef struct __jmp_buf_tag sigjmp_buf[1]; +sigjmp_buf GC_jmp_buf; +void GC_fault_handler(int sig) +{ +} +void GC_setup_temporary_fault_handler() { + GC_set_and_save_fault_handler(GC_fault_handler); +} +ptr_t GC_find_limit(ptr_t p) +{ + GC_setup_temporary_fault_handler(); + if (__sigsetjmp (GC_jmp_buf, 1) == 0) + for (;;) + ; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57214.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57214.c new file mode 100644 index 000000000..d51067d95 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57214.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ + +extern int baz (void); +extern int foo (void) __attribute__ ((returns_twice)); + +void +bar (_Bool b) +{ + int buf[1]; + while (1) + { + _Bool x = 1; + if (b) + baz (); + b = 1; + baz (); + x = 0; + int i; + while (buf[i] && i) + i++; + foo (); + if (!x) + b = 0; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57251.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57251.c new file mode 100644 index 000000000..2fe268c36 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57251.c @@ -0,0 +1,12 @@ +/* PR middle-end/57251 */ +/* { dg-do compile } */ +/* { dg-options "-ftracer" } */ + +short a, b; +int +f (void) +{ + long long i = 2; + a ? f () ? : 0 : b--; + b &= i *= a |= 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57303.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57303.c new file mode 100644 index 000000000..1ddb5a8aa --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57303.c @@ -0,0 +1,33 @@ +/* { dg-do run } */ + +void abort (void); + +struct S0 +{ + int f0; +}; +struct S1 +{ + struct S0 f0; +}; + +struct S1 x = { {0} }; +struct S1 y = { {1} }; + +static void +foo (struct S0 p) +{ + struct S0 *l = &y.f0; + *l = x.f0; + if (p.f0) + *l = *l; +} + +int +main () +{ + foo(y.f0); + if (y.f0.f0 != 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57330.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57330.c new file mode 100644 index 000000000..3e6cbcbd2 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57330.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ + +void foo (int a) +{} + +void *a; +void bar () +{ + void **( *b ) ( ) = (void**(*)()) foo; + a = b (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57341.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57341.c new file mode 100644 index 000000000..3f5cc8dd7 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57341.c @@ -0,0 +1,22 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse" { target sse2_runtime } } */ + +int a, d; +int *b = &a, **c; +int +main () +{ + int e; + { + int f[4]; + for (d = 0; d < 4; d++) + f[d] = 1; + e = f[1]; + } + int *g[28] = { }; + *b = e; + c = &g[0]; + if (a != 1) + __builtin_abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57343.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57343.c new file mode 100644 index 000000000..b05bad5cb --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57343.c @@ -0,0 +1,22 @@ +/* { dg-do run } */ + +int c = 0; + +int +main () +{ + int i, f = 1; + for (i = 0; i < 5; i++) + { + --c; + unsigned char h = c * 100; + if (h == 0) + { + f = 0; + break; + } + } + if (f != 1) + __builtin_abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57381.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57381.c new file mode 100644 index 000000000..ff6550a6d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57381.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target int32plus } */ + +struct S0 { int f0, f1, f2; }; + +struct S1 { + int f0; + volatile struct S0 f2; +}; + +static struct S1 s = {0x47BED265,{0x06D4EB3E,5,0U}}; + +int foo(struct S0 p) +{ + for (s.f2.f2 = 0; (s.f2.f2 <= 12); s.f2.f2++) + { + volatile int *l_61[5][2][2] = {{{&s.f2.f0,&s.f2.f0},{&s.f2.f0,&s.f2.f0}},{{&s.f2.f0,&s.f2.f0},{&s.f2.f0,&s.f2.f0}},{{&s.f2.f0,(void*)0},{&s.f2.f0,&s.f2.f0}},{{&s.f2.f0,&s.f2.f0},{&s.f2.f0,&s.f2.f0}},{{&s.f2.f0,&s.f2.f0},{(void*)0,&s.f2.f0}}}; + + volatile int **l_68 = &l_61[0][0][1]; + volatile int *l_76 = &s.f2.f0; + (*l_68) = l_61[0][0][0]; + if ((*l_76 = (p.f2 % 5))) ; + } + return p.f0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57393-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57393-1.c new file mode 100644 index 000000000..e62d44df4 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57393-1.c @@ -0,0 +1,15 @@ +/* PR middle-end/57393 */ +/* { dg-do compile } */ +/* { dg-additional-options "-g -ffast-math" } */ + +extern void bar (double); + +struct S { int n; }; + +void +foo (struct S s, double a, int i, int j, int k) +{ + struct S t; + bar (s.n * a * i * j); + t.n = s.n * a * i * k; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57393-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57393-2.c new file mode 100644 index 000000000..b9b12ffa5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57393-2.c @@ -0,0 +1,16 @@ +/* PR middle-end/57393 */ +/* { dg-do compile } */ + +char a; + +foo (int **p) +{ + int b; + for (;;) + { + int c[1] = { 0 }; + unsigned *d = &c[0]; + for (b = 7; b; b--) + **p &= --*d >= a; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57393-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57393-3.c new file mode 100644 index 000000000..34cece06c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57393-3.c @@ -0,0 +1,20 @@ +/* PR middle-end/57393 */ +/* { dg-do compile } */ + +int a, b, c; +void foo (void); + +int +bar (void) +{ + for (;;) + { + foo (); + int d = a = 0; + for (; a < 7; ++a) + { + d--; + b &= c <= d; + } + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57417.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57417.c new file mode 100644 index 000000000..6eac6f932 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57417.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ + +int a, b; +volatile int *c; + +void foo () +{ + volatile int d[1]; + b = 0; + for (;; a--) + c = &d[b]; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57425-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57425-1.c new file mode 100644 index 000000000..8ca85cafe --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57425-1.c @@ -0,0 +1,37 @@ +/* { dg-do run } */ + +extern void abort (void) __attribute__((noreturn)); + +union setconflict +{ + int a[20]; + long b[10]; +}; + +int +main () +{ + int sum = 0; + { + union setconflict a; + int *c; + c = a.a; + asm ("": "=r" (c):"0" (c)); + *c = 0; + asm ("": "=r" (c):"0" (c)); + sum += *c; + } + { + union setconflict a; + long *c; + c = a.b; + asm ("": "=r" (c):"0" (c)); + *c = 1; + asm ("": "=r" (c):"0" (c)); + sum += *c; + } + + if (sum != 1) + abort(); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57425-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57425-2.c new file mode 100644 index 000000000..ccb546e0e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57425-2.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +extern void abort (void) __attribute__((noreturn)); + +int +main () +{ + int sum = 0; + { + int a[20]; + int *c; + c = a; + asm ("": "=r" (c):"0" (c)); + *c = 0; + asm ("": "=r" (c):"0" (c)); + sum += *c; + } + { + long b[10]; + long *c; + c = b; + asm ("": "=r" (c):"0" (c)); + *c = 1; + asm ("": "=r" (c):"0" (c)); + sum += *c; + } + + if (sum != 1) + abort(); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57425-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57425-3.c new file mode 100644 index 000000000..8e0c7fe2d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57425-3.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +extern void abort (void) __attribute__((noreturn)); + +int +main () +{ + int sum = 0; + { + long a[20]; + long *c; + c = a; + asm ("": "=r" (c):"0" (c)); + *c = 0; + asm ("": "=r" (c):"0" (c)); + sum += *c; + } + { + long long b[10]; + long long *c; + c = b; + asm ("": "=r" (c):"0" (c)); + *c = 1; + asm ("": "=r" (c):"0" (c)); + sum += *c; + } + + if (sum != 1) + abort(); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57478.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57478.c new file mode 100644 index 000000000..e81348dfd --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57478.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ + +typedef struct Node Node; + +struct Node +{ + Node *Pred, *Suc; + Node *SubBestPred; + Node *SubBestSuc; +}; + +void +foo (Node *N) +{ + do + { + N->SubBestPred = N->Pred; + N->SubBestSuc = N->Suc; + } + while (N = N->Suc); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57488.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57488.c new file mode 100644 index 000000000..7eda36476 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57488.c @@ -0,0 +1,58 @@ +/* { dg-do run } */ + +extern void abort (void); + +int i, j, *pj = &j, **ppj = &pj; +int x, *px = &x; + +short s, *ps = &s, k; + +unsigned short u, *pu = &u, **ppu = &pu; + +char c, *pc = &c; + +unsigned char v = 48; + +static int +bar (int p) +{ + p = k; + *px = **ppu = i; + *ppj = &p; + if (**ppj) + *pj = p; + return p; +} + +void __attribute__((noinline)) +foo () +{ + for (; i <= 3; i++) + for (; j; j--); + + u ^= bar (*pj); + + for (k = 1; k >= 0; k--) + { + int l; + bar (0); + for (l = 1; l < 5; l++) + { + int m; + for (m = 6; m; m--) + { + v--; + *ps = *pc; + } + } + } +} + +int +main () +{ + foo (); + if (v != 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57517.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57517.c new file mode 100644 index 000000000..2422d8ee6 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57517.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ + +int x[1024], y[1024], z[1024], w[1024]; +void foo (void) +{ + int i; + for (i = 1; i < 1024; ++i) + { + int a = x[i]; + int b = y[i]; + int c = x[i-1]; + int d = y[i-1]; + if (w[i]) + z[i] = (a + b) + (c + d); + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57521.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57521.c new file mode 100644 index 000000000..e7832cb00 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57521.c @@ -0,0 +1,51 @@ +/* { dg-do run } */ +/* { dg-options "-ftree-loop-if-convert" } */ + +void abort (void); + +int a, b, c, d, o = 1, p; +short e; + +int +fn1 (int * p1) +{ + int f, g, h, j = 0, k = 0, l = 0; + unsigned int i; + int *m[1] = { &l }; + for (; b >= 0; b--) + { + if (*p1) + if (j >= 0) + { + int n = 1; + e = 1; + h = a ? a : 1 % n; + g = h > 0 ? 0 : h + 1; + k = c + g; + } + else + continue; + else + { + + f = d > 0 ? 0 : d + 1; + i = f; + j = 1 + i; + } + l++; + } + return k; +} + +int +main () +{ + for (;; p++) + { + fn1 (&o); + break; + } + if (e != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57569.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57569.c new file mode 100644 index 000000000..f036d559d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57569.c @@ -0,0 +1,37 @@ +/* { dg-do run } */ + +extern void abort (void) __attribute__((noreturn)); + +struct S { int f0; } a; + +int b, e, *d = &b, f; + +void +fn1 () +{ + int **g[9][6]; + int ***h = &g[6][3]; + for (; e < 9; e++) { + f = 0; + for (; f < 6; f++) + g[e][f] = &d; + } + ***h = 0; +} + +void +fn2 () +{ + fn1 (); + struct S c[4][10] = {}; + a = c[3][9]; +} + +int +main () +{ + fn2 (); + if (a.f0 != 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57584.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57584.c new file mode 100644 index 000000000..0e5a29492 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57584.c @@ -0,0 +1,74 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target int32plus } */ + +typedef int int32_t; +typedef unsigned char uint8_t; +typedef unsigned long int uintptr_t; +typedef uint8_t scm_t_uint8; +typedef int32_t scm_t_int32; +typedef uintptr_t scm_t_uintptr; +typedef scm_t_uintptr scm_t_bits; +typedef struct scm_unused_struct { +} *SCM; +enum scm_tc8_tags { + scm_tc8_flag = 4 + 0x00, scm_tc8_char = 4 + 0x08, scm_tc8_unused_0 = 4 + 0x10, scm_tc8_unused_1 = 4 + 0x18 }; +struct __jmp_buf_tag { +}; +typedef struct __jmp_buf_tag jmp_buf[1]; +typedef struct scm_t_cell { +} scm_t_cell; +struct scm_prompt_registers { + jmp_buf regs; +}; +enum { + SCM_VM_APPLY_HOOK, SCM_VM_PUSH_CONTINUATION_HOOK, SCM_VM_POP_CONTINUATION_HOOK, SCM_VM_NEXT_HOOK, SCM_VM_ABORT_CONTINUATION_HOOK, SCM_VM_RESTORE_CONTINUATION_HOOK, SCM_VM_NUM_HOOKS, }; +typedef SCM (*scm_t_vm_engine) (SCM vm, SCM program, SCM *argv, int nargs); +struct scm_vm { + scm_t_uint8 *ip; + SCM *sp; + SCM *fp; + int engine; + int trace_level; +}; +static SCM vm_regular_engine (SCM vm, SCM program, SCM *argv, int nargs) { +} +static SCM vm_debug_engine (SCM vm, SCM program, SCM *argv, int nargs) { + register scm_t_uint8 *ip ; + register SCM *sp ; + register SCM *fp ; + struct scm_vm *vp = ((struct scm_vm *) ((((scm_t_bits) (0? (*(SCM*)0=((((SCM *)((scm_t_cell *) (((scm_t_bits) (0? (*(SCM*)0=((((vm))))): (((vm)))))))) [((1))]))): (((SCM *)((scm_t_cell *) (((scm_t_bits) (0? (*(SCM*)0=((((vm))))): (((vm)))))))) [((1))])))))); + static const void **jump_table_pointer = ((void *)0); + const void **jump_table; + if (__builtin_expect ((!jump_table_pointer), 0)) { + jump_table_pointer[0] = &&l_nop; + } +l_nop: + { + SCM *old_sp; + scm_t_int32 n; + old_sp = sp; + sp = (fp - 1) + n; + if (old_sp < sp) { + while (old_sp < sp) *++old_sp = ((SCM) ((((((9)) << 8) + scm_tc8_flag)))); + } + { + { if (__builtin_expect ((vp->trace_level > 0), 0)) { { vp->ip = ip; vp->sp = sp; vp->fp = fp; }; vm_dispatch_hook (vm, SCM_VM_NEXT_HOOK); } }; + }; + } + { + SCM k, prompt; + if ((_setjmp (((struct scm_prompt_registers*)((((scm_t_bits) (0? (*(SCM*)0=((((SCM *)((scm_t_cell *) (((scm_t_bits) (0? (*(SCM*)0=((((prompt))))): (((prompt)))))))) [((2))]))): (((SCM *)((scm_t_cell *) (((scm_t_bits) (0? (*(SCM*)0=((((prompt))))): (((prompt)))))))) [((2))]))))))->regs))) { + { ip = vp->ip; sp = vp->sp; fp = vp->fp; }; + { { if (__builtin_expect ((vp->trace_level > 0), 0)) { { vp->ip = ip; vp->sp = sp; vp->fp = fp; }; vm_dispatch_hook (vm, SCM_VM_NEXT_HOOK); } }; ; goto *jump_table[(*ip++) & ((1<<8)-1)]; }; + } + + if (__builtin_expect ((vp->trace_level > 0), 0)) { { vp->ip = ip; vp->sp = sp; vp->fp = fp; }; vm_dispatch_hook (vm, SCM_VM_NEXT_HOOK); } ; + + } +} +static const scm_t_vm_engine vm_engines[] = { + vm_regular_engine, vm_debug_engine }; +SCM scm_c_vm_run (SCM vm, SCM program, SCM *argv, int nargs) { + struct scm_vm *vp = ((struct scm_vm *) ((((scm_t_bits) (0? (*(SCM*)0=((((SCM *)((scm_t_cell *) (((scm_t_bits) (0? (*(SCM*)0=((((vm))))): (((vm)))))))) [((1))]))): (((SCM *)((scm_t_cell *) (((scm_t_bits) (0? (*(SCM*)0=((((vm))))): (((vm)))))))) [((1))])))))); + return vm_engines[vp->engine](vm, program, argv, nargs); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57656.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57656.c new file mode 100644 index 000000000..4f3645e46 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57656.c @@ -0,0 +1,13 @@ +/* { dg-do run } */ +/* { dg-options "-fstrict-overflow" } */ + +int main (void) +{ + int a = -1; + int b = __INT_MAX__; + int c = 2; + int t = 1 - ((a - b) / c); // t = 1 - ( __INT_MIN__ / 2 ) + if (t != (1 - (-1 - __INT_MAX__) / 2)) + __builtin_abort(); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57685.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57685.c new file mode 100644 index 000000000..75973f2a4 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57685.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +unsigned f(void) +{ + unsigned a; + int b, c, d, e; + + for(c = 27; c < 40; c++) + b |= d |= b; + + if(b) + a = e; + + return a; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57748-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57748-1.c new file mode 100644 index 000000000..dc0fcdc3b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57748-1.c @@ -0,0 +1,49 @@ +/* PR middle-end/57748 */ +/* { dg-do run } */ +/* ICE in expand_assignment: + misalignp == true, !MEM_P (to_rtx), offset != 0, + => gcc_assert (TREE_CODE (offset) == INTEGER_CST) */ + +#include <stdlib.h> + +extern void abort (void); + +typedef long long V + __attribute__ ((vector_size (2 * sizeof (long long)), may_alias)); + +typedef struct S { V a; V b[0]; } P __attribute__((aligned (1))); + +struct __attribute__((packed)) T { char c; P s; }; + +void __attribute__((noinline, noclone)) +check (struct T *t) +{ + if (t->s.b[0][0] != 3 || t->s.b[0][1] != 4) + abort (); +} + +int __attribute__((noinline, noclone)) +get_i (void) +{ + return 0; +} + +void __attribute__((noinline, noclone)) +foo (P *p) +{ + V a = { 3, 4 }; + int i = get_i (); + p->b[i] = a; +} + +int +main () +{ + struct T *t = (struct T *) calloc (128, 1); + + foo (&t->s); + check (t); + + free (t); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57748-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57748-2.c new file mode 100644 index 000000000..4e3b4b884 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57748-2.c @@ -0,0 +1,43 @@ +/* PR middle-end/57748 */ +/* { dg-do run } */ +/* wrong code in expand_assignment: + misalignp == true, !MEM_P (to_rtx), + offset == 0, bitpos >= GET_MODE_PRECISION, + => result = NULL. */ + +#include <stdlib.h> + +extern void abort (void); + +typedef long long V + __attribute__ ((vector_size (2 * sizeof (long long)), may_alias)); + +typedef struct S { V a; V b[0]; } P __attribute__((aligned (1))); + +struct __attribute__((packed)) T { char c; P s; }; + +void __attribute__((noinline, noclone)) +check (struct T *t) +{ + if (t->s.b[0][0] != 3 || t->s.b[0][1] != 4) + abort (); +} + +void __attribute__((noinline, noclone)) +foo (P *p) +{ + V a = { 3, 4 }; + p->b[0] = a; +} + +int +main () +{ + struct T *t = (struct T *) calloc (128, 1); + + foo (&t->s); + check (t); + + free (t); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57748-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57748-3.c new file mode 100644 index 000000000..5ddb6099c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57748-3.c @@ -0,0 +1,40 @@ +/* PR middle-end/57748 */ +/* { dg-do run } */ +/* wrong code in expand_expr_real_1. */ + +#include <stdlib.h> + +extern void abort (void); + +typedef long long V + __attribute__ ((vector_size (2 * sizeof (long long)), may_alias)); + +typedef struct S { V a; V b[0]; } P __attribute__((aligned (1))); + +struct __attribute__((packed)) T { char c; P s; }; + +void __attribute__((noinline, noclone)) +check (P *p) +{ + if (p->b[0][0] != 3 || p->b[0][1] != 4) + abort (); +} + +void __attribute__((noinline, noclone)) +foo (struct T *t) +{ + V a = { 3, 4 }; + t->s.b[0] = a; +} + +int +main () +{ + struct T *t = (struct T *) calloc (128, 1); + + foo (t); + check (&t->s); + + free (t); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57748-4.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57748-4.c new file mode 100644 index 000000000..455cb3d32 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57748-4.c @@ -0,0 +1,40 @@ +/* PR middle-end/57748 */ +/* { dg-do run } */ +/* wrong code in expand_expr_real_1. */ + +#include <stdlib.h> + +extern void abort (void); + +typedef long long V + __attribute__ ((vector_size (2 * sizeof (long long)), may_alias)); + +typedef struct S { V b[1]; } P __attribute__((aligned (1))); + +struct __attribute__((packed)) T { char c; P s; }; + +void __attribute__((noinline, noclone)) +check (P *p) +{ + if (p->b[1][0] != 3 || p->b[1][1] != 4) + abort (); +} + +void __attribute__((noinline, noclone)) +foo (struct T *t) +{ + V a = { 3, 4 }; + t->s.b[1] = a; +} + +int +main () +{ + struct T *t = (struct T *) calloc (128, 1); + + foo (t); + check (&t->s); + + free (t); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57993-2.cpp b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57993-2.cpp new file mode 100644 index 000000000..d8fd371b0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57993-2.cpp @@ -0,0 +1,213 @@ +/* This ICEd due to an incomplete fix for PR57993. */ +/* { dg-compile } */ + +extern "C" +{ + extern double sqrt (double __x) throw (); + typedef long unsigned int size_t; + typedef struct + { + } + __mbstate_t; + void *pov_malloc (size_t size, const char *file, int line, const char *msg); + typedef struct Object_Struct OBJECT; + typedef struct Ray_Struct RAY; + typedef struct istack_struct ISTACK; + typedef struct istk_entry INTERSECTION; + typedef double UV_VECT[2]; + typedef double VECTOR[3]; + typedef struct Transform_Struct TRANSFORM; + typedef struct Method_Struct METHODS; + typedef int (*ALL_INTERSECTIONS_METHOD) (OBJECT *, RAY *, ISTACK *); + typedef int (*INSIDE_METHOD) (VECTOR, OBJECT *); + typedef void (*NORMAL_METHOD) (VECTOR, OBJECT *, INTERSECTION *); + typedef void (*UVCOORD_METHOD) (UV_VECT, OBJECT *, INTERSECTION *); + typedef void *(*COPY_METHOD) (OBJECT *); + typedef void (*TRANSLATE_METHOD) (OBJECT *, VECTOR, TRANSFORM *); + typedef void (*ROTATE_METHOD) (OBJECT *, VECTOR, TRANSFORM *); + typedef void (*SCALE_METHOD) (OBJECT *, VECTOR, TRANSFORM *); + typedef void (*TRANSFORM_METHOD) (OBJECT *, TRANSFORM *); + typedef void (*INVERT_METHOD) (OBJECT *); + typedef void (*DESTROY_METHOD) (OBJECT *); + struct Method_Struct + { + ALL_INTERSECTIONS_METHOD All_Intersections_Method; + INSIDE_METHOD Inside_Method; + NORMAL_METHOD Normal_Method; + UVCOORD_METHOD UVCoord_Method; + COPY_METHOD Copy_Method; + TRANSLATE_METHOD Translate_Method; + ROTATE_METHOD Rotate_Method; + SCALE_METHOD Scale_Method; + TRANSFORM_METHOD Transform_Method; + INVERT_METHOD Invert_Method; + DESTROY_METHOD Destroy_Method; + }; + typedef struct Bicubic_Patch_Struct BICUBIC_PATCH; + typedef struct Bezier_Node_Struct BEZIER_NODE; + struct Bezier_Node_Struct + { + int Node_Type; + int Count; + }; + struct Bicubic_Patch_Struct + { + METHODS *Methods; + int Patch_Type, U_Steps, V_Steps; + VECTOR Control_Points[4][4]; + BEZIER_NODE *Node_Tree; + }; + typedef enum + { + CSV, SYS, PPM, TARGA, PNG, NONE + } + SHELLDATA; + typedef enum STATS + { + Number_Of_Pixels = + 0, Number_Of_Pixels_Supersampled, Number_Of_Samples, Number_Of_Rays, + Calls_To_DNoise, Calls_To_Noise, ADC_Saves, Istack_overflows, + Ray_RBezier_Tests, Ray_RBezier_Tests_Succeeded, Ray_Bicubic_Tests, + Ray_Bicubic_Tests_Succeeded, Ray_Blob_Tests, Ray_Blob_Tests_Succeeded, + Blob_Element_Tests, Blob_Element_Tests_Succeeded, Blob_Bound_Tests, + Blob_Bound_Tests_Succeeded, Ray_Box_Tests, Ray_Box_Tests_Succeeded, + Ray_Cone_Tests, Ray_Cone_Tests_Succeeded, Ray_CSG_Intersection_Tests, + Ray_CSG_Intersection_Tests_Succeeded, Ray_CSG_Merge_Tests, + Ray_CSG_Merge_Tests_Succeeded, Ray_CSG_Union_Tests, + Ray_CSG_Union_Tests_Succeeded, Ray_Disc_Tests, Ray_Disc_Tests_Succeeded, + Ray_Fractal_Tests, Ray_Fractal_Tests_Succeeded, Ray_HField_Tests, + Ray_HField_Tests_Succeeded, Ray_HField_Box_Tests, + Ray_HField_Box_Tests_Succeeded, Ray_HField_Triangle_Tests, + Ray_HField_Triangle_Tests_Succeeded, Ray_HField_Block_Tests, + Ray_HField_Block_Tests_Succeeded, Ray_HField_Cell_Tests, + Ray_HField_Cell_Tests_Succeeded, Ray_IsoSurface_Tests, + Ray_IsoSurface_Tests_Succeeded, Ray_IsoSurface_Bound_Tests, + Ray_IsoSurface_Bound_Tests_Succeeded, Ray_IsoSurface_Cache, + Ray_IsoSurface_Cache_Succeeded, Ray_Lathe_Tests, + Ray_Lathe_Tests_Succeeded, Lathe_Bound_Tests, + Lathe_Bound_Tests_Succeeded, Ray_Mesh_Tests, Ray_Mesh_Tests_Succeeded, + Ray_Plane_Tests, Ray_Plane_Tests_Succeeded, Ray_Polygon_Tests, + Ray_Polygon_Tests_Succeeded, Ray_Prism_Tests, Ray_Prism_Tests_Succeeded, + Prism_Bound_Tests, Prism_Bound_Tests_Succeeded, Ray_Parametric_Tests, + Ray_Parametric_Tests_Succeeded, Ray_Par_Bound_Tests, + Ray_Par_Bound_Tests_Succeeded, Ray_Quadric_Tests, + Ray_Quadric_Tests_Succeeded, Ray_Poly_Tests, Ray_Poly_Tests_Succeeded, + Ray_Sphere_Tests, Ray_Sphere_Tests_Succeeded, Ray_Sphere_Sweep_Tests, + Ray_Sphere_Sweep_Tests_Succeeded, Ray_Superellipsoid_Tests, + Ray_Superellipsoid_Tests_Succeeded, Ray_Sor_Tests, + Ray_Sor_Tests_Succeeded, Sor_Bound_Tests, Sor_Bound_Tests_Succeeded, + Ray_Torus_Tests, Ray_Torus_Tests_Succeeded, Torus_Bound_Tests, + Torus_Bound_Tests_Succeeded, Ray_Triangle_Tests, + Ray_Triangle_Tests_Succeeded, Ray_TTF_Tests, Ray_TTF_Tests_Succeeded, + Bounding_Region_Tests, Bounding_Region_Tests_Succeeded, + Clipping_Region_Tests, Clipping_Region_Tests_Succeeded, + Ray_IsoSurface_Find_Root, Ray_Function_VM_Calls, + Ray_Function_VM_Instruction_Est, VBuffer_Tests, VBuffer_Tests_Succeeded, + LBuffer_Tests, LBuffer_Tests_Succeeded, Media_Samples, Media_Intervals, + Reflected_Rays_Traced, Refracted_Rays_Traced, Transmitted_Rays_Traced, + Internal_Reflected_Rays_Traced, Shadow_Cache_Hits, + Shadow_Rays_Succeeded, Shadow_Ray_Tests, nChecked, nEnqueued, + totalQueues, totalQueueResets, totalQueueResizes, Polynomials_Tested, + Roots_Eliminated, MemStat_Smallest_Alloc, MemStat_Largest_Alloc, + MemStat_Largest_Mem_Usage, Number_Of_Photons_Shot, + Number_Of_Photons_Stored, Number_Of_Global_Photons_Stored, + Number_Of_Media_Photons_Stored, Priority_Queue_Add, + Priority_Queue_Remove, Gather_Performed_Count, Gather_Expanded_Count, + MaxStat + } + Stats; + static int All_Bicubic_Patch_Intersections (OBJECT * Object, RAY * Ray, + ISTACK * Depth_Stack); + static int Inside_Bicubic_Patch (VECTOR IPoint, OBJECT * Object); + static void Bicubic_Patch_Normal (VECTOR Result, OBJECT * Object, + INTERSECTION * Inter); + static void Bicubic_Patch_UVCoord (UV_VECT Result, OBJECT * Object, + INTERSECTION * Inter); + static BICUBIC_PATCH *Copy_Bicubic_Patch (OBJECT * Object); + static void Translate_Bicubic_Patch (OBJECT * Object, VECTOR Vector, + TRANSFORM * Trans); + static void Rotate_Bicubic_Patch (OBJECT * Object, VECTOR Vector, + TRANSFORM * Trans); + static void Scale_Bicubic_Patch (OBJECT * Object, VECTOR Vector, + TRANSFORM * Trans); + static void Transform_Bicubic_Patch (OBJECT * Object, TRANSFORM * Trans); + static void Invert_Bicubic_Patch (OBJECT * Object); + static void Destroy_Bicubic_Patch (OBJECT * Object); + static METHODS Bicubic_Patch_Methods = { + All_Bicubic_Patch_Intersections, Inside_Bicubic_Patch, + Bicubic_Patch_Normal, Bicubic_Patch_UVCoord, + (COPY_METHOD) Copy_Bicubic_Patch, Translate_Bicubic_Patch, + Rotate_Bicubic_Patch, Scale_Bicubic_Patch, Transform_Bicubic_Patch, + Invert_Bicubic_Patch, Destroy_Bicubic_Patch + }; + static void bezier_value (VECTOR (*Control_Points)[4][4], double u0, + double v0, VECTOR P, VECTOR N) + { + int i, j; + double c, t, ut, vt; + double u[4], uu[4], v[4], vv[4]; + double du[4], duu[4], dv[4], dvv[4]; + for (i = 1; i < 4; i++) + { + vv[i] = vv[i - 1] * (1.0 - v0); + dvv[i] = -i * vv[i - 1]; + } + for (i = 0; i < 4; i++) + { + for (j = 0; j < 4; j++) + { + t = c * ut * (dv[j] * vv[3 - j] + v[j] * dvv[3 - j]); + } + t = 1.0 / sqrt (t); + } + } + static int intersect_subpatch (BICUBIC_PATCH * Shape, RAY * ray, + VECTOR V1[3], double uu[3], double vv[3], + double *Depth, VECTOR P, VECTOR N, double *u, + double *v) + { + VECTOR Q, T1; + VECTOR B[3], IB[3], NN[3]; + bezier_value ((VECTOR (*)[4][4]) & Shape->Control_Points, uu[1], vv[1], + T1, NN[1]); + } + static int bezier_tree_walker (RAY * Ray, BICUBIC_PATCH * Shape, + BEZIER_NODE * Node, ISTACK * Depth_Stack) + { + int i, cnt = 0; + double Depth, u, v; + double uu[3], vv[3]; + VECTOR N, P; + VECTOR V1[3]; + if (Node->Node_Type == 0) + { + for (i = 0; i < Node->Count; i++) + { + } + if (intersect_subpatch (Shape, Ray, V1, uu, vv, &Depth, P, N, &u, &v)) + { + } + } + } + static int All_Bicubic_Patch_Intersections (OBJECT * Object, RAY * Ray, + ISTACK * Depth_Stack) + { + int Found, cnt = 0; + switch (((BICUBIC_PATCH *) Object)->Patch_Type) + { + case 1: + cnt = + bezier_tree_walker (Ray, (BICUBIC_PATCH *) Object, + ((BICUBIC_PATCH *) Object)->Node_Tree, + Depth_Stack); + } + } + BICUBIC_PATCH *Create_Bicubic_Patch () + { + BICUBIC_PATCH *New; + New = + (BICUBIC_PATCH *) pov_malloc ((sizeof (BICUBIC_PATCH)), "bezier.cpp", + 2079, ("bicubic patch")); + New->Methods = &Bicubic_Patch_Methods; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57993.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57993.c new file mode 100644 index 000000000..e73b73f4f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr57993.c @@ -0,0 +1,30 @@ +/* This ICEd prior to fixing PR57993. */ +/* { dg-do compile } */ + +int a, b, c, d; +char e; +unsigned g; + +void f(void) +{ + int h; + + for(; d; d++) + if(d) +lbl: + g + a || (d = 0); + + b && (a = e); + + for(h = 0; h < 1; ++h) + { + h = c ? : (d = 0); + g = a = (e | 0); + } + + if(a) + goto lbl; + + a = e = 0; + goto lbl; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58018.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58018.c new file mode 100644 index 000000000..52c8e83fa --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58018.c @@ -0,0 +1,22 @@ +/* PR tree-optimization/58018 */ +/* { dg-do compile } */ + +int a, b, c, d, e; + +void +bar (int p) +{ + int f = b; + e &= p <= (f ^= 0); +} + +void +foo () +{ + for (; d; d++) + { + bar (a && c); + bar (0); + bar (1); + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58041.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58041.c new file mode 100644 index 000000000..169a71ae7 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58041.c @@ -0,0 +1,33 @@ +/* { dg-do run } */ + +typedef long long V + __attribute__ ((vector_size (2 * sizeof (long long)), may_alias)); + +struct s +{ + char u; + V v[2]; +} __attribute__((packed,aligned(1))); + +__attribute__((noinline, noclone)) +long long foo(struct s *x, int y, V *z) +{ + V a = x->v[y]; + x->v[y] = *z; + return a[1]; +} + +struct s a = {0,{{0,0},{0,0}}}; +int main() +{ + V v1 = {0,1}; + V v2 = {0,2}; + + if (foo(&a,0,&v1) != 0) + __builtin_abort(); + if (foo(&a,0,&v2) != 1) + __builtin_abort(); + if (foo(&a,1,&v1) != 0) + __builtin_abort(); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58079.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58079.c new file mode 100644 index 000000000..99a30181f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58079.c @@ -0,0 +1,107 @@ +/* { dg-options "-mlong-calls" { target mips*-*-* } } */ + +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int __kernel_size_t; +typedef __kernel_size_t size_t; +struct list_head { + struct list_head *next; +}; + +struct dmx_ts_feed { + int is_filtering; +}; +struct dmx_section_feed { + u16 secbufp; + u16 seclen; + u16 tsfeedp; +}; + +typedef int (*dmx_ts_cb) ( + const u8 * buffer1, + size_t buffer1_length, + const u8 * buffer2, + size_t buffer2_length +); + +struct dvb_demux_feed { + union { + struct dmx_ts_feed ts; + struct dmx_section_feed sec; + } feed; + union { + dmx_ts_cb ts; + } cb; + int type; + u16 pid; + int ts_type; + struct list_head list_head; +}; + +struct dvb_demux { + int (*stop_feed)(struct dvb_demux_feed *feed); + struct list_head feed_list; +}; + + +static +inline +__attribute__((always_inline)) +u8 +payload(const u8 *tsp) +{ + if (tsp[3] & 0x20) { + return 184 - 1 - tsp[4]; + } + return 184; +} + +static +inline +__attribute__((always_inline)) +int +dvb_dmx_swfilter_payload(struct dvb_demux_feed *feed, const u8 *buf) +{ + int count = payload(buf); + int p; + if (count == 0) + return -1; + return feed->cb.ts(&buf[p], count, ((void *)0), 0); +} + +static +inline +__attribute__((always_inline)) +void +dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, const u8 *buf) +{ + switch (feed->type) { + case 0: + if (feed->ts_type & 1) { + dvb_dmx_swfilter_payload(feed, buf); + } + if (dvb_dmx_swfilter_section_packet(feed, buf) < 0) + feed->feed.sec.seclen = feed->feed.sec.secbufp = 0; + } +} + +static +void +dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf) +{ + struct dvb_demux_feed *feed; + int dvr_done = 0; + + for (feed = ({ const typeof( ((typeof(*feed) *)0)->list_head ) *__mptr = ((&demux->feed_list)->next); (typeof(*feed) *)( (char *)__mptr - __builtin_offsetof(typeof(*feed),list_head) );}); __builtin_prefetch(feed->list_head.next), &feed->list_head != (&demux->feed_list); feed = ({ const typeof( ((typeof(*feed) *)0)->list_head ) *__mptr = (feed->list_head.next); (typeof(*feed) *)( (char *)__mptr - __builtin_offsetof(typeof(*feed),list_head) );})) { + if (((((feed)->type == 0) && ((feed)->feed.ts.is_filtering) && (((feed)->ts_type & (1 | 8)) == 1))) && (dvr_done++)) + dvb_dmx_swfilter_packet_type(feed, buf); + else if (feed->pid == 0x2000) + feed->cb.ts(buf, 188, ((void *)0), 0); + } +} +void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf, size_t count) +{ + while (count--) { + dvb_dmx_swfilter_packet(demux, buf); + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58131.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58131.c new file mode 100644 index 000000000..3f68d4c52 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58131.c @@ -0,0 +1,22 @@ +/* PR tree-optimization/58131 */ +/* { dg-do compile } */ + +short a; +int b, c, d[1][4][2]; + +void +foo (void) +{ + int *e; + for (b = 1; ; b--) + { + if (*e) + break; + for (c = 2; c >= 0; c--) + { + *e |= d[0][3][b] != a; + int *f = &d[0][3][b]; + *f = 0; + } + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58143-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58143-1.c new file mode 100644 index 000000000..855515edb --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58143-1.c @@ -0,0 +1,51 @@ +/* { dg-do run } */ +/* { dg-additional-options "-fstrict-overflow" } */ + +extern void abort (void); + +int a, b, c, d, e, f, g, h = 1, i; + +int foo (int p) +{ + return p < 0 && a < - __INT_MAX__ - 1 - p ? 0 : 1; +} + +int *bar () +{ + int j; + i = h ? 0 : 1 % h; + for (j = 0; j < 1; j++) + for (d = 0; d; d++) + for (e = 1; e;) + return 0; + return 0; +} + +int baz () +{ + for (; b >= 0; b--) + for (c = 1; c >= 0; c--) + { + int *k = &c; + for (;;) + { + for (f = 0; f < 1; f++) + { + g = foo (*k); + bar (); + } + if (*k) + break; + return 0; + } + } + return 0; +} + +int main () +{ + baz (); + if (b != 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58143-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58143-2.c new file mode 100644 index 000000000..dd0dae1ef --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58143-2.c @@ -0,0 +1,34 @@ +/* { dg-do run } */ +/* { dg-additional-options "-fstrict-overflow" } */ + +int a, b, d, e, f, *g, h, i; +volatile int c; + +char foo (unsigned char p) +{ + return p + 1; +} + +int bar () +{ + for (h = 0; h < 3; h = foo (h)) + { + c; + for (f = 0; f < 1; f++) + { + i = a && 0 < -__INT_MAX__ - h ? 0 : 1; + if (e) + for (; d;) + b = 0; + else + g = 0; + } + } + return 0; +} + +int main () +{ + bar (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58143-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58143-3.c new file mode 100644 index 000000000..23ae9cd39 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58143-3.c @@ -0,0 +1,18 @@ +/* { dg-do run } */ +/* { dg-additional-options "-fstrict-overflow" } */ + +int a, b, c, d, e; + +int +main () +{ + for (b = 4; b > -30; b--) + for (; c;) + for (;;) + { + e = a > __INT_MAX__ - b; + if (d) + break; + } + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58223.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58223.c new file mode 100644 index 000000000..978084ad0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58223.c @@ -0,0 +1,16 @@ +/* { dg-do run } */ + +extern void abort (void); +int a[2], b; + +int main () +{ + for (b = 0; b < 2; b++) + { + a[0] = 1; + a[b] = 0; + } + if (a[0] != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58228.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58228.c new file mode 100644 index 000000000..d12303a00 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58228.c @@ -0,0 +1,15 @@ +/* { dg-do run } */ + +extern void abort (void); +int a[8][8] = {{1}}; +int b, c, d, e; + +int main () +{ + for (c = 0; c < 8; c++) + for (b = 0; b < 2; b++) + a[b + 4][c] = a[c][0]; + if (a[4][4] != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58246.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58246.c new file mode 100644 index 000000000..5417abf91 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58246.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ + +extern void abort (void); + +int a, b; + +int main () +{ + int t[2] = {1,1}; + + for (a = 0; a < 2; a++) + { + b ^= t[a]; + t[a] = t[1] = 0; + } + + if (b != 1) + abort (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58326-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58326-1.c new file mode 100644 index 000000000..3b46eed9c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58326-1.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ + +int a, *d; +long b; +short c; + +void foo () +{ + int e; +lbl: + for (c = 0; c < 2; c++) + { + if (1 >> b) + break; + e = *d; + for (; a; a++) + { + *d = e; + if (b) + goto lbl; + } + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58326-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58326-2.c new file mode 100644 index 000000000..ddddbbe57 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58326-2.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +int a, b, c, d; + +void foo () +{ + int e; + +lbl: + for (c = 0; c < 2; c++) + { + e = d; + for (; a; a++) + { + d = e; + if (b) + goto lbl; + } + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58417.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58417.c new file mode 100644 index 000000000..5cb0ddb02 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58417.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ + +long long arr[6] = {0, 1, 2, 3, 4, 5}; +extern void abort (void); +void __attribute__((noinline,noclone)) +foo (long long sum) +{ + asm (""); +} +int main() +{ + int i, n = 5; + long long sum = 0, prevsum = 0; + + for(i = 1; i <= n; i++) + { + foo (sum); + sum = (i - 1) * arr[i] - prevsum; + prevsum += arr[i]; + } + + if (sum != 10) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58539.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58539.c new file mode 100644 index 000000000..a016150f1 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58539.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-g" } */ + +int a, b; + +extern void baz (int); + +int foo (int p) +{ + return p ? p : 1; +} + +void bar () +{ + int *c = &a, *d = &a; + for (b = 0; b < 12; b++) + *d |= 1; + foo (*c); + baz (*c && 1); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58553.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58553.c new file mode 100644 index 000000000..542bf3f10 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58553.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ + +#define MAX_LENGTH 96 +#define SEQUENCE_LENGTH 31 + +static struct { + char buf[MAX_LENGTH + 1]; +} u1, u2; + +extern void abort (void); + +int main () +{ + int i; + char c; + + for (i = 0, c = 'A'; i < MAX_LENGTH; i++, c++) + { + u1.buf[i] = 'a'; + if (c >= 'A' + SEQUENCE_LENGTH) + c = 'A'; + u2.buf[i] = c; + } + if (u1.buf[MAX_LENGTH] != '\0') + abort (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58554.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58554.c new file mode 100644 index 000000000..269171ae9 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58554.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ + +extern void abort (void); +void __attribute__((noinline,noclone)) +clear_board(unsigned char *board, int board_size) +{ + int k; + for (k = 0; k < 421; k++) + if (k < board_size ) + board[k] = 3; +} +int main() +{ + unsigned char board[421]; + board[420] = 1; + clear_board (board, 420); + if (board[420] != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58626.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58626.c new file mode 100644 index 000000000..1416384b7 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58626.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ + +extern void abort (void); + +int a[8][6] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; +int b; + +int main(void) +{ + for (b = 0; b <= 1; b++) { + a[1][3] = 0; + int c; + for (c = 0; c <= 1; c++) { + a[c + 1][b] = a[c + 2][b]; + } + } + if (a[1][1] != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58670.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58670.c new file mode 100644 index 000000000..ba9fce71f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58670.c @@ -0,0 +1,47 @@ +/* PR middle-end/58670 */ +/* { dg-do run { target i?86-*-* x86_64-*-* } } */ + +#if defined (__i386__) || defined (__x86_64__) +#define ASM_STR "btsl $1, %0; jc %l[lab]" +#endif + +__attribute__((noinline, noclone)) int +foo (int a, int b) +{ + if (a) + return -3; +#ifdef ASM_STR + asm volatile goto (ASM_STR : : "m" (b) : "memory" : lab); + return 0; +lab: +#endif + return 0; +} + +int +bar (int a, int b) +{ + if (a) + return -3; +#ifdef ASM_STR + asm volatile goto (ASM_STR : : "m" (b) : "memory" : lab); + return 0; +lab: +#endif + return 0; +} + +int +main () +{ + if (foo (1, 0) != -3 + || foo (0, 3) != 0 + || foo (1, 0) != -3 + || foo (0, 0) != 0 + || bar (1, 0) != -3 + || bar (0, 3) != 0 + || bar (1, 0) != -3 + || bar (0, 0) != 0) + __builtin_abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58779.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58779.c new file mode 100644 index 000000000..b0c0c8695 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58779.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ + +int a, c; + +int main () +{ + int e = -1; + short d = (c <= 0) ^ e; + if ((unsigned int) a - (a || d) <= (unsigned int) a) + __builtin_abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58830.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58830.c new file mode 100644 index 000000000..8081f8b2c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58830.c @@ -0,0 +1,42 @@ +/* { dg-do run } */ +/* { dg-additional-options "-ftree-pre -ftree-partial-pre" } */ + +extern void abort (void); + +int b, c, d, f, g, h, i, j[6], *l = &b, *m, n, *o, r; +char k; + +static int +foo () +{ + char *p = &k; + + for (; d; d++) + if (i) + h = 0; + else + h = c || (r = 0); + + for (f = 0; f < 2; f++) + { + unsigned int q; + *l = 0; + if (n) + *m = g; + if (g) + o = 0; + for (q = -8; q >= 5; q++) + (*p)--; + } + + return 0; +} + +int +main () +{ + foo (); + if (j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[0]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] ^ (k & 15)] != 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58921.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58921.c new file mode 100644 index 000000000..7d7c98514 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58921.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ + +int a[7]; +int b; + +void +fn1 () +{ + for (; b; b++) + a[b] = ((a[b] <= 0) == (a[0] != 0)); +} + +int +main () +{ + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58941.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58941.c new file mode 100644 index 000000000..c0eea0731 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58941.c @@ -0,0 +1,33 @@ +/* { dg-do run } */ + +extern void abort (void); + +typedef struct { + int msgLength; + unsigned char data[1000]; +} SMsg; + +typedef struct { + int dummy; + int d[0]; +} SData; + +int condition = 3; + +int main() +{ + SMsg msg; + SData *pData = (SData*)(msg.data); + unsigned int i = 0; + for (i = 0; i < 1; i++) + { + pData->d[i] = 0; + if(condition & 1) + pData->d[i] |= 0x55; + if(condition & 2) + pData->d[i] |= 0xaa; + } + if (pData->d[0] != 0xff) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58955-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58955-1.c new file mode 100644 index 000000000..a79f42f0b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58955-1.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ + +extern void abort (void); + +int a, b, c, d[4] = { 0, 0, 0, 1 }; + +int +main () +{ + for (; a < 4; a++) + { + int e = d[a]; + for (c = 1; c < 1; c++); + b = e; + d[a] = 0; + } + if (b != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58955-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58955-2.c new file mode 100644 index 000000000..a43860e9b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58955-2.c @@ -0,0 +1,18 @@ +/* { dg-do run } */ + +extern void abort (void); + +int a, b[10]; + +int +main () +{ + for (; a < 2; a++) + { + b[a] = 1; + b[a + 1] = 0; + } + if (b[1] != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58956.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58956.c new file mode 100644 index 000000000..7576ba7fb --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr58956.c @@ -0,0 +1,30 @@ +/* { dg-do run } */ + +extern void abort (void); + +struct S +{ + int f0; +} a = {1}, b, g, *c = &b, **f = &c; + +int *d, **e = &d, h; + +struct S +foo () +{ + *e = &h; + if (!d) + __builtin_unreachable (); + *f = &g; + return a; +} + +int +main () +{ + struct S *i = c; + *i = foo (); + if (b.f0 != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59006.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59006.c new file mode 100644 index 000000000..34de83dac --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59006.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +int a[8], b; +void fn1(void) +{ + int c; + for (; b; b++) + { + int d = a[b]; + c = a[0] ? d : 0; + a[b] = c; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59038.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59038.c new file mode 100644 index 000000000..1694eca43 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59038.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ + +extern void abort (void); + +unsigned char first_ones_8bit[256]; +unsigned char connected_passed[256]; + +int +main () +{ + int i, j; + for (i=0;i<256;i++){ + connected_passed[i]=0; + first_ones_8bit[i]=0; + for (j=7;j>0;j--){ + if ((i & (3<<(7-j))) == (3<<(7-j))){ + connected_passed[i]=j; + break; + } + } + } + if (connected_passed[3] != 7) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59047.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59047.c new file mode 100644 index 000000000..fcedfcba8 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59047.c @@ -0,0 +1,39 @@ +/* { dg-do run } */ + +extern void abort (void); + +struct +{ + int f0; + int f1:1; + int f2:2; +} a = {0, 0, 1}; + +int b, c, *d, e, f; + +int +fn1 () +{ + for (; b < 1; ++b) + { + for (e = 0; e < 1; e = 1) + { + int **g = &d; + *g = &c; + } + *d = 0; + f = a.f1; + if (f) + return 0; + } + return 0; +} + +int +main () +{ + fn1 (); + if (b != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59058.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59058.c new file mode 100644 index 000000000..b3a5a3960 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59058.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ + +extern void abort (void); + +short b = 0; + +int +main () +{ + int c = 0; +l1: + b++; + c |= b; + if (b) + goto l1; + if (c != -1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59139.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59139.c new file mode 100644 index 000000000..4ec9177ff --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59139.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +int a, b, c, d, e; +int fn1(p1, p2) { return p2 == 0 ? p1 : 1 % p2; } + +void fn2() +{ + c = 0; + for (;; c = (unsigned short)c) + { + b = 2; + for (; b; b = a) + { + e = fn1(2, c && 1); + d = c == 0 ? e : c; + if (d) + return; + } + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59164.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59164.c new file mode 100644 index 000000000..1ec69610c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59164.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ + +int a, d, e; +long b[10]; +int c[10][8]; + +int fn1(p1) +{ + return 1 >> p1; +} + +void fn2(void) +{ + int f; + for (a=1; a <= 4; a++) + { + f = fn1(0 < c[a][0]); + if (f || d) + e = b[a] = 1; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59166.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59166.c new file mode 100644 index 000000000..d29ec33e0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59166.c @@ -0,0 +1,37 @@ +/* PR rtl-optimization/59166 */ +/* { dg-additional-options "-fcompare-debug" } */ + +int a, b, c, f, g; + +void +foo () +{ + for (; b; b++) + for (; f; f = g) + for (; a;) + ; +} + +static int +bar (int p) +{ + short d; + if (c) + { + for (; f; f = g); + foo (); + d = p; + char e = d; + if (p) + return 1; + } + return p; +} + +int +main () +{ + bar (0); + bar (g); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59216.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59216.c new file mode 100644 index 000000000..0de51bac9 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59216.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ + +#include <limits.h> + +extern void abort (void); +extern void exit (int); + +long long __attribute__((noinline)) f(int a) +{ + return -(long long) a; +} + +int +main() +{ + if (f(0) != 0) + abort (); + + if (f(1) != -(long long)1) + abort (); + + if (f(-1) != -(long long)-1) + abort (); + + if (f(INT_MIN) != -(long long)INT_MIN) + abort (); + + if (f(INT_MAX) != -(long long)INT_MAX) + abort (); + + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59245.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59245.c new file mode 100644 index 000000000..e5b9a0fb4 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59245.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ + +int a, b, c, e, g; +char d[5], f; + +int +fn1 () +{ + if (b) + { + g = 0; + return 0; + } + for (f = 0; f != 1; f--) + ; + return 0; +} + +void +fn2 () +{ + d[4] = -1; + for (a = 4; a; a--) + { + fn1 (); + e = c < -2147483647 - 1 - d[a] ? c : 0; + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59288.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59288.c new file mode 100644 index 000000000..8331e7328 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59288.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ + +void +baz (int *d) +{ + long int i, j, k; + for (i = 0, j = 0, k = 0; i < 512; i = (int) i + 1, j = (int) j + 1, k = (int) k + 3) + d[i] = j ^ (i * 3) ^ (2 * k + 2); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59330.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59330.c new file mode 100644 index 000000000..74b832ea3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59330.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ + +void free(void *ptr) +{ +} + +void *foo(void) +{ + return 0; +} + +int main(void) +{ + void *p = foo(); + free(p); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59338.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59338.c new file mode 100644 index 000000000..481c84d4e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59338.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ + +typedef enum +{ + XYZZY, +} enumType; + +typedef struct +{ + unsigned char More : 1; +} tResp; + +typedef struct +{ + enumType QueryType; + union + { + tResp l[0]; + } u; +} tQResp; + +void test(void) +{ + tQResp *qResp = (0); + if (qResp->u.l[0].More == 0) + return; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59374-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59374-1.c new file mode 100644 index 000000000..6230ae9ca --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59374-1.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-additional-options "-ftree-slp-vectorize" } */ + +extern void abort (void); + +static struct X { void *a; void *b; } a, b; + +void __attribute__((noinline)) +foo (void) +{ + void *tem = a.b; + a.b = (void *)0; + b.b = tem; + b.a = a.a; +} + +int main() +{ + a.b = &a; + foo (); + if (b.b != &a) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59374-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59374-2.c new file mode 100644 index 000000000..d791b987e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59374-2.c @@ -0,0 +1,26 @@ +/* { dg-do run } */ +/* { dg-additional-options "-ftree-slp-vectorize" } */ + +extern void abort (void); + +static struct X { void *a; void *b; } a, b; +static struct X *p; + +void __attribute__((noinline)) +foo (void) +{ + void *tem = a.b; + p->b = (void *)0; + b.b = tem; + b.a = a.a; +} + +int main() +{ + p = &a; + a.b = &a; + foo (); + if (b.b != &a) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59374-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59374-3.c new file mode 100644 index 000000000..ab0014d8f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59374-3.c @@ -0,0 +1,21 @@ +extern void abort (void); + +static struct X { void *a; void *b; } a, b; + +void __attribute__((noinline)) foo (void) +{ + void *tem = a.b; + a.b = (void *)0; + b.b = tem; + b.a = a.a; + a.a = tem; +} + +int main() +{ + a.b = &a; + foo (); + if (b.b != &a) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59651.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59651.c new file mode 100644 index 000000000..7139ba9bf --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59651.c @@ -0,0 +1,20 @@ +/* PR tree-optimization/59561 */ +/* { dg-do run } */ + +extern void abort (void); +int a[] = { 0, 0, 0, 0, 0, 0, 0, 6 }; + +int b; +int +main () +{ + for (;;) + { + for (b = 7; b; --b) + a[b] = a[7] > 1; + break; + } + if (a[1] != 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59715.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59715.c new file mode 100644 index 000000000..19c09de55 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59715.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ + +extern void abort (void); + +int a = 2, b; + +int +main () +{ + int c; + if (!b) + { + b = a; + c = a == 0 ? 1 : 1 % a; + if (c) + b = 0; + } + if (b != 0) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59891.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59891.c new file mode 100644 index 000000000..1562acccf --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59891.c @@ -0,0 +1,9 @@ +/* PR c/59891 */ + +unsigned int a; + +int +main () +{ + return (0 ? a : 0) ? : 0 % 0; /* { dg-warning "division by zero" } */ +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59903.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59903.c new file mode 100644 index 000000000..01772df61 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59903.c @@ -0,0 +1,56 @@ +/* { dg-do compile } */ + +int a, b, c, d, e, f, g, h, i[3], l, m, n, o, p, q, r; + +struct S0 +{ + int f0; + int f1; + int f2; + int f3; +} j; + +static int +fn1 (int p1) +{ + return p1 || ((p1 > 0) > (e << 1)); +} + +static struct S0 +fn2 (struct S0 p1) +{ + char s; + struct S0 t = {0,0,0,0}; + int u = 2; + for (;;) + { + if (i[0]) + break; + for (m = 0; m < 4; m++) + for (p1.f0 = 0; p1.f0 < 3; p1.f0++) + { + j = t; + t.f3 = i[p1.f0]; + o = b || 1 >> b ? 0 : a < 0; + q = 1 % d; + if ((g < fn1 ((1 ^ (q & 1)) | n)) ^ u) + j.f3 |= p % 2; + s = j.f3 > 0 ? j.f3 : j.f3 << 1; + r = l = s && p1.f1 * c; + h = p1.f1; + } + } + return p1; +} + +int +main () +{ + for (;f;) + { + struct S0 v = {0,0,0,0}; + fn2 (v); + j.f3 = 0; + } + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59990.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59990.c new file mode 100644 index 000000000..e54f9b7ef --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59990.c @@ -0,0 +1,18 @@ +/* { dg-do run } */ + +extern void abort (void); + +unsigned char value[4] = { 66, 9, 160, 255 }; + +int main (void) +{ + volatile float f; + unsigned char a[4]; + + __builtin_memcpy ((void *)&f, value, 4); + __builtin_memcpy (a, (void *)&f, 4); + if (a[2] != 160) + abort (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59993.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59993.c new file mode 100644 index 000000000..be55a10b9 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr59993.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +#include <setjmp.h> + +extern int optind; +jmp_buf jump_buf; +int +main (int argc, char **argv) +{ + foo (jump_buf, setjmp(jump_buf)); + argv += optind; + bar(argv[1]); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr60092.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr60092.c new file mode 100644 index 000000000..a85720c60 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr60092.c @@ -0,0 +1,23 @@ +/* { dg-do run } */ +/* { dg-require-weak "" } */ +/* { dg-skip-if "No undefined weak" { hppa*-*-hpux* && { ! lp64 } } { "*" } { "" } } */ +/* { dg-xfail-run-if "posix_memalign modifies first arg on error" { *-*-solaris2.11* } { "-O0" } } */ + +typedef __SIZE_TYPE__ size_t; +extern int posix_memalign(void **memptr, size_t alignment, size_t size) __attribute__((weak)); +extern void abort(void); +int +main (void) +{ + void *p; + int ret; + + if (!posix_memalign) + return 0; + + p = (void *)&ret; + ret = posix_memalign (&p, sizeof (void *), -1); + if (p != (void *)&ret) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr60115.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr60115.c new file mode 100644 index 000000000..cf7f45dfb --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr60115.c @@ -0,0 +1,14 @@ +/* { dg-do run } */ + +int a, b[2]; + +int +main () +{ +lbl: + for (; a; a--) + if (b[10000]) + goto lbl; + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr60183.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr60183.c new file mode 100644 index 000000000..3f676637b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr60183.c @@ -0,0 +1,39 @@ +/* { dg-do run } */ +/* { dg-require-effective-target size32plus } */ + +/* Large so an out-of-bound read will crash. */ +unsigned char c[0x30001] = { 1 }; +int j = 2; + +static void +foo (unsigned long *x, unsigned char *y) +{ + int i; + unsigned long w = x[0]; + for (i = 0; i < j; i++) + { + w += *y; + y += 0x10000; + w += *y; + y += 0x10000; + } + x[1] = w; +} + +__attribute__ ((noinline, noclone)) void +bar (unsigned long *x) +{ + foo (x, c); +} + +int +main () +{ + unsigned long a[2] = { 0, -1UL }; + asm volatile (""::"r" (c):"memory"); + c[0] = 0; + bar (a); + if (a[1] != 0) + __builtin_abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr8081.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr8081.c new file mode 100644 index 000000000..008ec5a14 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pr8081.c @@ -0,0 +1,26 @@ +/* { dg-do run } */ + +extern void abort (void); +int +main (int argc, char **argv) +{ + int size = 10; + typedef struct + { + char val[size]; + } + block; + block a, b; + block __attribute__((noinline)) + retframe_block () + { + return *(block *) &b; + } + b.val[0] = 1; + b.val[9] = 2; + a=retframe_block (); + if (a.val[0] != 1 + || a.val[9] != 2) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pta-callused-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pta-callused-1.c new file mode 100644 index 000000000..5ca71c2a0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pta-callused-1.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-options "-fdump-tree-alias" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-fno-fat-lto-objects" } { "" } } */ + +volatile int i; +int ** __attribute__((noinline,pure)) foo(int **p) { i; return p; } +int bar(void) +{ + int i = 0, j = 1; + int *p, **q; + p = &i; + q = foo(&p); + *q = &j; + return *p; +} +extern void abort (void); +int main() +{ + if (bar() != 1) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "p.._. = { i j }" "alias" } } */ +/* { dg-final { cleanup-tree-dump "alias" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pta-escape-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pta-escape-1.c new file mode 100644 index 000000000..d3cb25437 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pta-escape-1.c @@ -0,0 +1,34 @@ +/* { dg-do run } */ +/* { dg-options "-fdump-tree-alias" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-fno-fat-lto-objects" } { "" } } */ + +int *p; +void __attribute__((noinline,noclone)) +bar (void) +{ + *p = 1; +} +int __attribute__((noinline,noclone)) +foo (__INTPTR_TYPE__ addr) +{ + int i; + /* q points to ANYTHING */ + int **q = (int **)addr; + /* this store needs to cause i to escape */ + *q = &i; + i = 0; + /* and thus be clobbered by this function call */ + bar (); + return i; +} +extern void abort (void); +int +main() +{ + if (foo ((__INTPTR_TYPE__)&p) != 1) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "ESCAPED = {\[^\n\}\]* i \[^\n\}\]*}" "alias" } } */ +/* { dg-final { cleanup-tree-dump "alias" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pta-ptrarith-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pta-ptrarith-1.c new file mode 100644 index 000000000..ab5634da9 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pta-ptrarith-1.c @@ -0,0 +1,33 @@ +/* { dg-do run } */ +/* { dg-options "-fdump-tree-alias" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-fno-fat-lto-objects" } { "" } } */ + +struct Foo { + int *p; +}; + +void __attribute__((noinline)) +foo (void *p) +{ + struct Foo *f = (struct Foo *)p - 1; + *f->p = 0; +} + +int bar (void) +{ + struct Foo f; + int i = 1; + f.p = &i; + foo (&f + 1); + return i; +} +extern void abort (void); +int main() +{ + if (bar () != 0) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "ESCAPED = {\[^\n\}\]* i f \[^\n\}\]*}" "alias" } } */ +/* { dg-final { cleanup-tree-dump "alias" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pta-ptrarith-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pta-ptrarith-2.c new file mode 100644 index 000000000..1158775ab --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pta-ptrarith-2.c @@ -0,0 +1,36 @@ +/* { dg-do run } */ +/* { dg-options "-fdump-tree-alias" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-fno-fat-lto-objects" } { "" } } */ + +struct Foo { + int **p; + int **q; +}; + +int __attribute__((noinline)) +bar (void) +{ + struct Foo f; + int j, i = 1; + char *p; + int *x = &i; + int *y = &j; + f.p = &y; + f.q = &x; + p = (char *)&f; + for (j = 0; j < sizeof (int *); ++j) + p++; + return ***(int ***)p; +} +extern void abort (void); +int main() +{ + if (bar () != 1) + abort (); + return 0; +} + +/* In theory = { i } is the correct solution. But it's not easy to scan + for that reliably, so just use what we create now. */ +/* { dg-final { scan-tree-dump "= { i j }" "alias" } } */ +/* { dg-final { cleanup-tree-dump "alias" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pta-ptrarith-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pta-ptrarith-3.c new file mode 100644 index 000000000..938fb296b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pta-ptrarith-3.c @@ -0,0 +1,37 @@ +/* { dg-do run } */ +/* { dg-options "-fdump-tree-alias" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-fno-fat-lto-objects" } { "" } } */ + +extern void abort (void); +struct X { + int *p; + int *q; + int *r; +}; +int __attribute__((noinline)) +foo(int i, int j, int k, int off) +{ + struct X x; + int **p, *q; + x.p = &i; + x.q = &j; + x.r = &k; + p = &x.q; + p += off; + /* *p points to { i, j, k } */ + q = *p; + return *q; +} +int main() +{ + if (foo(1, 2, 3, -1) != 1) + abort (); + if (foo(1, 2, 3, 0) != 2) + abort (); + if (foo(1, 2, 3, 1) != 3) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "q_. = { i j k }" "alias" } } */ +/* { dg-final { cleanup-tree-dump "alias" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pta-structcopy-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pta-structcopy-1.c new file mode 100644 index 000000000..4846dd698 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pta-structcopy-1.c @@ -0,0 +1,36 @@ +/* { dg-do run } */ +/* { dg-options "-fdump-tree-ealias -Wno-attributes" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */ + +struct X +{ + long l1; + struct Y + { + long l2; + int *p; + } y; +}; +int i; +static int __attribute__((always_inline)) +foo (struct X *x) +{ + struct Y y = x->y; + /* In the inlined instance the dereferenced pointer needs to point to i. */ + *y.p = 0; + i = 1; + return *y.p; +} +extern void abort (void); +int main() +{ + struct X x; + x.y.p = &i; + if (foo(&x) != 1) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "y.* = { i }" "ealias" } } */ +/* { dg-final { scan-tree-dump "y.*, points-to vars: { D..... }" "ealias" } } */ +/* { dg-final { cleanup-tree-dump "ealias" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/reassoc-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/reassoc-1.c new file mode 100644 index 000000000..f0c9014cc --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/reassoc-1.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ + +int x; + +int __attribute__((noinline)) +foo(int a, int b, int w) +{ + int tmp1 = a * w; + int tmp2 = b * w; + x = tmp1; + return tmp1 + tmp2; +} + +extern void abort (void); + +int main() +{ + if (foo(1, 2, 3) != 9) + abort (); + if (x != 3) + abort (); + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/restrict-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/restrict-1.c new file mode 100644 index 000000000..e7af4f538 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/restrict-1.c @@ -0,0 +1,16 @@ +/* { dg-do run } */ + +extern void abort (void); +void __attribute__((noinline,noclone)) +foo (int ** __restrict__ p, int ** __restrict__ q) +{ + **p = **q; +} +int main() +{ + int x = 0, y = 1, *i = &x, *j = &y; + foo (&i, &j); + if (x != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/restrict-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/restrict-2.c new file mode 100644 index 000000000..ec51ade61 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/restrict-2.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ + +extern void abort (void); + +static inline void +foo (int * p) +{ + int * __restrict pr = p; + *pr = 1; +} + +int __attribute__((noinline,noclone)) +bar (int *q) +{ + int * __restrict qr = q; + *qr = 0; + foo (qr); + return *qr; +} + +int main() +{ + int i; + if (bar (&i) != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/restrict-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/restrict-3.c new file mode 100644 index 000000000..d815b8076 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/restrict-3.c @@ -0,0 +1,26 @@ +/* { dg-do run } */ + +extern void abort (void); + +static inline void +foo (int * __restrict pr) +{ + *pr = 1; +} + +int __attribute__((noinline,noclone)) +bar (int *q) +{ + int * __restrict qr = q; + *qr = 0; + foo (qr); + return *qr; +} + +int main() +{ + int i; + if (bar (&i) != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/restrict-4.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/restrict-4.c new file mode 100644 index 000000000..52994d48b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/restrict-4.c @@ -0,0 +1,26 @@ +/* { dg-do run } */ + +extern void abort (void); + +static inline void +foo (int * p) +{ + int * __restrict pr = p; + *pr = 1; +} + +int __attribute__((noinline,noclone)) +bar (int * __restrict qr) +{ + *qr = 0; + foo (qr); + return *qr; +} + +int main() +{ + int i; + if (bar (&i) != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/restrict-5.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/restrict-5.c new file mode 100644 index 000000000..233a9075f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/restrict-5.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ + +extern void abort (void); + +static inline void +foo (int * __restrict pr) +{ + *pr = 1; +} + +int __attribute__((noinline,noclone)) +bar (int * __restrict qr) +{ + *qr = 0; + foo (qr); + return *qr; +} + +int main() +{ + int i; + if (bar (&i) != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/ssa-pta-fn-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/ssa-pta-fn-1.c new file mode 100644 index 000000000..a90b1c62d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/ssa-pta-fn-1.c @@ -0,0 +1,62 @@ +/* { dg-do run } */ +/* { dg-options "-fdump-tree-alias" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-fno-fat-lto-objects" } { "" } } */ + +extern void abort (void); +int *glob; +int dummy; + +int * __attribute__((noinline,const)) +foo_const(int *p) { return p; } + +int * __attribute__((noinline,pure)) +foo_pure(int *p) { return p + dummy; } + +int * __attribute__((noinline)) +foo_normal(int *p) { glob = p; return p; } + +void test_const(void) +{ + int i; + int *p = &i; + int *q_const = foo_const(p); + *p = 1; + *q_const = 2; + if (*p != 2) + abort (); +} + +void test(void) +{ + int i; + int *p = &i; + int *q_normal = foo_normal(p); + *p = 1; + *q_normal = 2; + if (*p != 2) + abort (); +} + +void test_pure(void) +{ + int i; + int *p = &i; + int *q_pure = foo_pure(p); + *p = 1; + *q_pure = 2; + if (*p != 2) + abort (); +} + +int main() +{ + test_const(); + test(); + test_pure(); + return 0; +} + +/* { dg-final { scan-tree-dump "q_const_. = { NONLOCAL i }" "alias" } } */ +/* { dg-final { scan-tree-dump "q_pure_. = { ESCAPED NONLOCAL i }" "alias" } } */ +/* { dg-final { scan-tree-dump "q_normal_. = { ESCAPED NONLOCAL }" "alias" } } */ +/* { dg-final { cleanup-tree-dump "alias" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/alloca-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/alloca-1.c new file mode 100644 index 000000000..e226e7f03 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/alloca-1.c @@ -0,0 +1,45 @@ +/* { dg-do run } */ +/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */ + +#include "check.h" + +#ifndef ALIGNMENT +#define ALIGNMENT 64 +#endif + +typedef int aligned __attribute__((aligned(ALIGNMENT))); + +int global; + +void +bar (char *p, int size) +{ + __builtin_strncpy (p, "good", size); +} + +void +foo (int size) +{ + char *p = __builtin_alloca (size + 1); + aligned i; + + bar (p, size); + if (__builtin_strncmp (p, "good", size) != 0) + { +#ifdef DEBUG + p[size] = '\0'; + printf ("Failed: %s != good\n", p); +#endif + abort (); + } + + if (check_int (&i, __alignof__(i)) != i) + abort (); +} + +int +main() +{ + foo (5); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/alloca-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/alloca-2.c new file mode 100644 index 000000000..2ef17629d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/alloca-2.c @@ -0,0 +1,49 @@ +/* PR middle-end/37009 */ +/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-additional-options "-mmmx -msse2" } */ +/* { dg-require-effective-target sse2_runtime } */ + +#include <emmintrin.h> +#include "check.h" + +#ifndef ALIGNMENT +#define ALIGNMENT 16 +#endif + +typedef int aligned __attribute__((aligned(ALIGNMENT))); + +void +bar (char *p, int size) +{ + __builtin_strncpy (p, "good", size); +} + +void +__attribute__ ((noinline)) +foo (__m128 x, __m128 y ,__m128 z , int size) +{ + char *p = __builtin_alloca (size + 1); + aligned i; + + bar (p, size); + if (__builtin_strncmp (p, "good", size) != 0) + { +#ifdef DEBUG + p[size] = '\0'; + printf ("Failed: %s != good\n", p); +#endif + abort (); + } + + if (check_int (&i, __alignof__(i)) != i) + abort (); +} + +int +main (void) +{ + __m128 x = { 1.0 }; + foo (x, x, x, 5); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/alloca-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/alloca-3.c new file mode 100644 index 000000000..c3dd12479 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/alloca-3.c @@ -0,0 +1,49 @@ +/* PR middle-end/37009 */ +/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ +/* { dg-additional-options "-mmmx -msse2" } */ +/* { dg-require-effective-target sse2_runtime } */ + +#include <emmintrin.h> +#include "check.h" + +#ifndef ALIGNMENT +#define ALIGNMENT 16 +#endif + +typedef int aligned __attribute__((aligned(ALIGNMENT))); + +void +bar (char *p, int size) +{ + __builtin_strncpy (p, "good", size); +} + +void +__attribute__ ((noinline)) +foo (__m128 x, __m128 y ,__m128 z ,__m128 a, int size) +{ + char *p = __builtin_alloca (size + 1); + aligned i; + + bar (p, size); + if (__builtin_strncmp (p, "good", size) != 0) + { +#ifdef DEBUG + p[size] = '\0'; + printf ("Failed: %s != good\n", p); +#endif + abort (); + } + + if (check_int (&i, __alignof__(i)) != i) + abort (); +} + +int +main (void) +{ + __m128 x = { 1.0 }; + foo (x, x, x, x, 5); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/alloca-4.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/alloca-4.c new file mode 100644 index 000000000..bc16f5789 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/alloca-4.c @@ -0,0 +1,41 @@ +/* PR middle-end/37009 */ +/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-additional-options "-mincoming-stack-boundary=2 -mpreferred-stack-boundary=2" } */ + +#include "check.h" + +void +bar (char *p, int size) +{ + __builtin_strncpy (p, "good", size); +} + +void +__attribute__ ((noinline)) +foo (double x, double y ,double z ,double a, int size) +{ + char *p = __builtin_alloca (size + 1); + double i; + + bar (p, size); + if (__builtin_strncmp (p, "good", size) != 0) + { +#ifdef DEBUG + p[size] = '\0'; + printf ("Failed: %s != good\n", p); +#endif + abort (); + } + + check (&i, __alignof__(i)); +} + +int +main (void) +{ + double x = 1.0 ; + + foo (x, x, x, x, 5); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/alloca-5.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/alloca-5.c new file mode 100644 index 000000000..4c6506d1a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/alloca-5.c @@ -0,0 +1,32 @@ +/* PR middle-end/45234 */ +/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-additional-options "-mincoming-stack-boundary=2 -mpreferred-stack-boundary=2" } */ + +#include "check.h" + +void +__attribute__ ((noinline)) +bar (__float128 f) +{ + check (&f, __alignof__(f)); +} + +int +main (void) +{ + char *p = __builtin_alloca (6); + + bar (0); + + __builtin_strncpy (p, "good", 5); + if (__builtin_strncmp (p, "good", 5) != 0) + { +#ifdef DEBUG + p[5] = '\0'; + printf ("Failed: %s != good\n", p); +#endif + abort (); + } + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/alloca-6.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/alloca-6.c new file mode 100644 index 000000000..301fff7a2 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/alloca-6.c @@ -0,0 +1,34 @@ +/* PR middle-end/45234 */ +/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-additional-options "-mincoming-stack-boundary=2 -mpreferred-stack-boundary=2" } */ + +#include "check.h" + +void +__attribute__ ((noinline)) +bar (__float128 f) +{ + check (&f, __alignof__(f)); +} + +volatile int z = 6; + +int +main (void) +{ + char *p = __builtin_alloca (z); + + bar (0); + + __builtin_strncpy (p, "good", 5); + if (__builtin_strncmp (p, "good", 5) != 0) + { +#ifdef DEBUG + p[z - 1] = '\0'; + printf ("Failed: %s != good\n", p); +#endif + abort (); + } + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-1.c new file mode 100644 index 000000000..38b384e7c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-1.c @@ -0,0 +1,9 @@ +/* PR 11184 */ +/* Origin: Dara Hazeghi <dhazeghi@yahoo.com> */ + +void * +objc_msg_sendv (char * arg_frame, void (*foo)()) +{ + return __builtin_apply ( foo, arg_frame, 4); +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c new file mode 100644 index 000000000..8eba13aed --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c @@ -0,0 +1,48 @@ +/* PR target/12503 */ +/* Origin: <pierre.nguyen-tuong@asim.lip6.fr> */ + +/* Verify that __builtin_apply behaves correctly on targets + with pre-pushed arguments (e.g. SPARC). */ + +/* { dg-do run } */ + +/* arm_hf_eabi: Variadic funcs use Base AAPCS. Normal funcs use VFP variant. + avr: Variadic funcs don't pass arguments in registers, while normal funcs + do. */ +/* { dg-skip-if "Variadic funcs use different argument passing from normal funcs" { arm_hf_eabi || { avr-*-* } } "*" "" } */ +/* { dg-skip-if "Variadic funcs have all args on stack. Normal funcs have args in registers." { nds32*-*-* } "*" "" } */ + + +#define INTEGER_ARG 5 + +#if defined(__ARM_PCS) || defined(__epiphany__) +/* For Base AAPCS, NAME is passed in r0. D is passed in r2 and r3. + E, F and G are passed on stack. So the size of the stack argument + data is 20. */ +#define STACK_ARGUMENTS_SIZE 20 +#elif defined __aarch64__ || defined __arc__ || defined __MMIX__ +/* No parameters on stack for bar. */ +#define STACK_ARGUMENTS_SIZE 0 +#else +#define STACK_ARGUMENTS_SIZE 64 +#endif + +extern void abort(void); + +void foo(char *name, double d, double e, double f, int g) +{ + if (g != INTEGER_ARG) + abort(); +} + +void bar(char *name, ...) +{ + __builtin_apply(foo, __builtin_apply_args(), STACK_ARGUMENTS_SIZE); +} + +int main(void) +{ + bar("eeee", 5.444567, 8.90765, 4.567789, INTEGER_ARG); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-3.c new file mode 100644 index 000000000..1335d0902 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-3.c @@ -0,0 +1,31 @@ +/* PR middle-end/12210 */ +/* Origin: Ossadchy Yury A. <waspcoder@mail.ru> */ + +/* This used to fail on i686 because the argument was not copied + to the right location by __builtin_apply after the direct call. */ + +/* { dg-do run } */ + + +#define INTEGER_ARG 5 + +extern void abort(void); + +void foo(int arg) +{ + if (arg != INTEGER_ARG) + abort(); +} + +void bar(int arg) +{ + foo(arg); + __builtin_apply(foo, __builtin_apply_args(), 16); +} + +int main(void) +{ + bar(INTEGER_ARG); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-4.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-4.c new file mode 100644 index 000000000..28dc6106d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-4.c @@ -0,0 +1,29 @@ +/* PR tree-optimization/20076 */ +/* { dg-do run } */ + +extern void abort (void); + +double +foo (int arg) +{ + if (arg != 116) + abort(); + return arg + 1; +} + +inline double +bar (int arg) +{ + foo (arg); + __builtin_return (__builtin_apply ((void (*) ()) foo, + __builtin_apply_args (), 16)); +} + +int +main (int argc, char **argv) +{ + if (bar (116) != 117.0) + abort (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/builtin-return-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/builtin-return-1.c new file mode 100644 index 000000000..75c9acdf7 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/builtin-return-1.c @@ -0,0 +1,34 @@ +/* PR middle-end/11151 */ +/* Originator: Andrew Church <gcczilla@achurch.org> */ +/* { dg-do run } */ + +/* This used to fail on SPARC because the (undefined) return + value of 'bar' was overwriting that of 'foo'. */ + +extern void abort(void); + +int foo(int n) +{ + return n+1; +} + +int bar(int n) +{ + __builtin_return(__builtin_apply((void (*)(void))foo, __builtin_apply_args(), 64)); +} + +char *g; + +int main(void) +{ + /* Allocate 64 bytes on the stack to make sure that __builtin_apply + can read at least 64 bytes above the return address. */ + char dummy[64]; + + g = dummy; + + if (bar(1) != 2) + abort(); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/check.h b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/check.h new file mode 100644 index 000000000..af1988512 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/check.h @@ -0,0 +1,36 @@ +#include <stddef.h> +#ifdef DEBUG +#include <stdio.h> +#endif + +#ifdef __cplusplus +extern "C" void abort (void); +#else +extern void abort (void); +#endif + +int +check_int (int *i, int align) +{ + *i = 20; + if ((((ptrdiff_t) i) & (align - 1)) != 0) + { +#ifdef DEBUG + printf ("\nUnalign address (%d): %p!\n", align, i); +#endif + abort (); + } + return *i; +} + +void +check (void *p, int align) +{ + if ((((ptrdiff_t) p) & (align - 1)) != 0) + { +#ifdef DEBUG + printf ("\nUnalign address (%d): %p!\n", align, p); +#endif + abort (); + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/comp-goto-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/comp-goto-1.c new file mode 100644 index 000000000..7558f01e2 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/comp-goto-1.c @@ -0,0 +1,41 @@ +/* { dg-do run } */ + +#ifdef STACK_SIZE +#define DEPTH ((STACK_SIZE) / 512 + 1) +#else +#define DEPTH 1000 +#endif + +extern void abort (void); +extern void exit (int); + +#if ! defined (NO_LABEL_VALUES) && !defined (NO_TRAMPOLINES) +int +x(a) +{ + __label__ xlab; + void y(a) + { + void *x = &&llab; + if (a==-1) + goto *x; + if (a==0) + goto xlab; + llab: + y (a-1); + } + y (a); + xlab:; + return a; +} +#endif + +int +main () +{ +#if ! defined (NO_LABEL_VALUES) && !defined (NO_TRAMPOLINES) + if (x (DEPTH) != DEPTH) + abort (); +#endif + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/fastcall-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/fastcall-1.c new file mode 100644 index 000000000..24dab4d13 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/fastcall-1.c @@ -0,0 +1,31 @@ +/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +#include "check.h" + +#ifndef ALIGNMENT +#define ALIGNMENT 64 +#endif + +typedef int aligned __attribute__((aligned(ALIGNMENT))); + +int global; + +__attribute__ ((fastcall)) +void +foo (int j, int k, int m, int n, int o) +{ + aligned i; + + if (check_int (&i, __alignof__(i)) != i) + abort (); + + if (i != 20 || j != 1 || k != 2 || m != 3 || n != 4 || o != 5) + abort (); +} + +int +main() +{ + foo (1, 2, 3, 4, 5); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/global-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/global-1.c new file mode 100644 index 000000000..332103a76 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/global-1.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */ + +#include "check.h" + +#ifndef ALIGNMENT +#define ALIGNMENT 64 +#endif + +typedef int aligned __attribute__((aligned(ALIGNMENT))); + +int global; + +void +foo (void) +{ + aligned i; + + if (check_int (&i, __alignof__(i)) != i) + abort (); +} + +int +main() +{ + foo (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/inline-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/inline-1.c new file mode 100644 index 000000000..38127fd50 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/inline-1.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ +/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */ + +#include "check.h" + +#ifndef ALIGNMENT +#define ALIGNMENT 64 +#endif + +typedef int aligned __attribute__((aligned(ALIGNMENT))); + +int global; + +static void +inline __attribute__((always_inline)) +foo (void) +{ + aligned i; + + if (check_int (&i, __alignof__(i)) != i) + abort (); +} + +int +main() +{ + foo (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/inline-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/inline-2.c new file mode 100644 index 000000000..85a2ee3f3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/inline-2.c @@ -0,0 +1,46 @@ +/* { dg-do run } */ +/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */ + +#include "check.h" + +#ifndef ALIGNMENT +#define ALIGNMENT 64 +#endif + +typedef int aligned __attribute__((aligned(ALIGNMENT))); + +int global; + +void +bar (char *p, int size) +{ + __builtin_strncpy (p, "good", size); +} + +static void +inline __attribute__((always_inline)) +foo (int size) +{ + char *p = __builtin_alloca (size + 1); + aligned i; + + bar (p, size); + if (__builtin_strncmp (p, "good", size) != 0) + { +#ifdef DEBUG + p[size] = '\0'; + printf ("Failed: %s != good\n", p); +#endif + abort (); + } + + if (check_int (&i, __alignof__(i)) != i) + abort (); +} + +int +main() +{ + foo (5); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/nested-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/nested-1.c new file mode 100644 index 000000000..8402f95f5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/nested-1.c @@ -0,0 +1,45 @@ +/* { dg-do run } */ +/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */ + +#include "check.h" + +#ifndef ALIGNMENT +#define ALIGNMENT 64 +#endif + +typedef int aligned __attribute__((aligned(ALIGNMENT))); + +int global; + +void +foo (void) +{ + aligned j; + + void bar () + { + aligned i; + + if (check_int (&i, __alignof__(i)) != i) + abort (); + + if (check_int (&j, __alignof__(j)) != j) + abort (); + + j = -20; + } + bar (); + + if (j != -20) + abort (); + + if (check_int (&j, __alignof__(j)) != j) + abort (); +} + +int +main() +{ + foo (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/nested-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/nested-2.c new file mode 100644 index 000000000..dabc310d7 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/nested-2.c @@ -0,0 +1,46 @@ +/* { dg-do run } */ +/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */ + +#include "check.h" + +#ifndef ALIGNMENT +#define ALIGNMENT 64 +#endif + +typedef int aligned __attribute__((aligned(ALIGNMENT))); + +int global; + +void +foo (void) +{ + aligned j; + + __attribute__ ((__noinline__)) + void bar () + { + aligned i; + + if (check_int (&i, __alignof__(i)) != i) + abort (); + + if (check_int (&j, __alignof__(j)) != j) + abort (); + + j = -20; + } + bar (); + + if (j != -20) + abort (); + + if (check_int (&j, __alignof__(j)) != j) + abort (); +} + +int +main() +{ + foo (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/nested-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/nested-3.c new file mode 100644 index 000000000..d35c9a7ce --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/nested-3.c @@ -0,0 +1,63 @@ +/* { dg-do run } */ +/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */ + +#include "check.h" + +#ifndef ALIGNMENT +#define ALIGNMENT 64 +#endif + +typedef int aligned __attribute__((aligned(ALIGNMENT))); + +int global; + +void +copy (char *p, int size) +{ + __builtin_strncpy (p, "good", size); +} + +void +foo (int size) +{ + aligned j; + + __attribute__ ((__noinline__)) + void bar (int size) + { + char *p = __builtin_alloca (size + 1); + aligned i; + + copy (p, size); + if (strncmp (p, "good", size) != 0) + { +#ifdef DEBUG + p[size] = '\0'; + printf ("Failed: %s != good\n", p); +#endif + abort (); + } + + if (check_int (&i, __alignof__(i)) != i) + abort (); + + if (check_int (&j, __alignof__(j)) != j) + abort (); + + j = -20; + } + bar (size); + + if (j != -20) + abort (); + + if (check_int (&j, __alignof__(j)) != j) + abort (); +} + +int +main() +{ + foo (5); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/nested-4.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/nested-4.c new file mode 100644 index 000000000..05cb83301 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/nested-4.c @@ -0,0 +1,34 @@ +/* { dg-do run } */ +/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */ + +#include "check.h" + +#ifndef ALIGNMENT +#define ALIGNMENT 64 +#endif + +typedef int aligned __attribute__((aligned(ALIGNMENT))); + +int n; + +void +g (void) +{ + __label__ lab; + void h (void) + { + aligned t; + if (check_int (&t, __alignof__(t)) != t) + abort (); + if (n+t == 0) goto lab; + } + h(); +lab: + return; +} + +int main() +{ + g(); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/nested-5.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/nested-5.c new file mode 100644 index 000000000..95eba0482 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/nested-5.c @@ -0,0 +1,38 @@ +/* { dg-do run } */ + +extern void abort (void); +extern void exit (int); + +#ifndef NO_TRAMPOLINES +static void recursive (int n, void (*proc) (void)) +{ + __label__ l1; + + void do_goto (void) + { + goto l1; + } + + if (n == 3) + recursive (n - 1, do_goto); + else if (n > 0) + recursive (n - 1, proc); + else + (*proc) (); + return; + +l1: + if (n == 3) + exit (0); + else + abort (); +} + +int main () +{ + recursive (10, abort); + abort (); +} +#else +int main () { return 0; } +#endif diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/nested-6.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/nested-6.c new file mode 100644 index 000000000..d853825fe --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/nested-6.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ + +#ifndef NO_TRAMPOLINES + +typedef __SIZE_TYPE__ size_t; +extern void abort (void); +extern void exit (int); +extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *)); + +int main () +{ + __label__ nonlocal; + int compare (const void *a, const void *b) + { + goto nonlocal; + } + + char array[3]; + qsort (array, 3, 1, compare); + abort (); + + nonlocal: + exit (0); +} + +#else +int main() { return 0; } +#endif diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-1.c new file mode 100644 index 000000000..263d4486c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-1.c @@ -0,0 +1,55 @@ +/* { dg-do run } */ + +extern void abort (void); + +int global; + +static void foo(void) __attribute__((noinline)); + +static void foo(void) +{ + global = 1; +} + +static void bar(void) +{ + foo (); +} + +int execute(int cmd) +{ + __label__ start; + + void raise(void) + { + goto start; + } + + int last = -1; + + bar (); + + last = 0; + +start: + + if (last == 0) + while (1) + { + last = 1; + raise (); + } + + if (last == 0) + return 0; + else + return cmd; +} + +int main(void) +{ + if (execute (1) == 0) + abort (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-2.c new file mode 100644 index 000000000..5a64d5419 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-2.c @@ -0,0 +1,56 @@ +/* { dg-do run } */ + +extern void abort (void); + +int global; + +static void foo(void) __attribute__((noinline)); + +static void foo(void) +{ + global = 1; +} + +static void bar(void) +{ + foo (); + global = 0; +} + +int execute(int cmd) +{ + __label__ start; + + void raise(void) + { + goto start; + } + + int last = -1; + + bar (); + + last = 0; + +start: + + if (last == 0) + while (1) + { + last = 1; + raise (); + } + + if (last == 0) + return 0; + else + return cmd; +} + +int main(void) +{ + if (execute (1) == 0) + abort (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-3.c new file mode 100644 index 000000000..3afc8cc6a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-3.c @@ -0,0 +1,42 @@ +/* { dg-do run } */ + +#ifndef NO_TRAMPOLINES +extern void abort (void); + +int x(int a, int b) +{ + __label__ xlab; + + void y(int b) + { + switch (b) + { + case 1: goto xlab; + case 2: goto xlab; + } + } + + a = a + 2; + y (b); + + xlab: + return a; +} + +int main () +{ + int i, j; + + for (j = 1; j <= 2; ++j) + for (i = 1; i <= 2; ++i) + { + int a = x (j, i); + if (a != 2 + j) + abort (); + } + + return 0; +} +#else +int main() { return 0; } +#endif diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-4.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-4.c new file mode 100644 index 000000000..3673f1ac3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-4.c @@ -0,0 +1,38 @@ +/* { dg-do run } */ + +extern void abort (void); +extern void exit (int); + +#ifdef STACK_SIZE +#define DEPTH ((STACK_SIZE) / 512 + 1) +#else +#define DEPTH 1000 +#endif + +#if ! defined (NO_LABEL_VALUES) && !defined (NO_TRAMPOLINES) +int + +x(a) +{ + __label__ xlab; + void y(a) + { + if (a==0) + goto xlab; + y (a-1); + } + y (a); + xlab:; + return a; +} +#endif + +int +main () +{ +#if ! defined (NO_LABEL_VALUES) && !defined (NO_TRAMPOLINES) + if (x (DEPTH) != DEPTH) + abort (); +#endif + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-5.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-5.c new file mode 100644 index 000000000..d198c9a97 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/non-local-goto-5.c @@ -0,0 +1,11 @@ +/* { dg-do run } */ + +extern void exit (int); +#if !defined (NO_LABEL_VALUES) && !defined (NO_TRAMPOLINES) +extern void abort (void); +int s(i){if(i>0){__label__ l1;int f(int i){if(i==2)goto l1;return 0;}return f(i);l1:;}return 1;} +int x(){return s(0)==1&&s(1)==0&&s(2)==1;} +int main(){if(x()!=1)abort();exit(0);} +#else +int main(){ exit (0); } +#endif diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/pr16660-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/pr16660-1.c new file mode 100644 index 000000000..b917e824b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/pr16660-1.c @@ -0,0 +1,18 @@ +/* { dg-do run } */ +/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */ + +#include "check.h" + +void +f () +{ + unsigned long tmp[4] __attribute__((aligned(64))); + check (&tmp, 64); +} + +int +main() +{ + f(); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/pr16660-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/pr16660-2.c new file mode 100644 index 000000000..9a039eb2b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/pr16660-2.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ + +#include "check.h" + +typedef __SIZE_TYPE__ size_t; +#define ALIGNMENT 256 +int main(void) +{ + int a[ALIGNMENT/sizeof(int)] __attribute__((aligned(ALIGNMENT))); + check (&a, ALIGNMENT); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/pr16660-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/pr16660-3.c new file mode 100644 index 000000000..1c1ddd1dd --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/pr16660-3.c @@ -0,0 +1,14 @@ +/* { dg-do run } */ + +#include "check.h" + +typedef __SIZE_TYPE__ size_t; +#define ALIGNMENT 256 +int main(void) +{ + int a[ALIGNMENT/sizeof(int)] __attribute__((aligned(ALIGNMENT))); + check (&a, ALIGNMENT); + int b[ALIGNMENT/sizeof(int)] __attribute__((aligned(ALIGNMENT))); + check (&b, ALIGNMENT); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/push-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/push-1.c new file mode 100644 index 000000000..c23faf411 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/push-1.c @@ -0,0 +1,51 @@ +/* PR middle-end/37010 */ +/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-additional-options "-mmmx -msse2 -mpreferred-stack-boundary=2" } */ +/* { dg-require-effective-target sse2_runtime } */ + +#include <emmintrin.h> + +typedef __PTRDIFF_TYPE__ ptrdiff_t; +typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__)); +typedef int aligned __attribute__((aligned(16))); + +extern void abort (void); + +__m128 r; + +int +__attribute__ ((noinline)) +check_int (int *i, int align) +{ + *i = 20; + if ((((ptrdiff_t) i) & (align - 1)) != 0) + { + abort (); + } + return *i; +} + +void +__attribute__ ((noinline)) +foo (__m128 x, __m128 y ,__m128 z ,__m128 a, int size) +{ + aligned i; + + if (size != 5 || check_int (&i, __alignof__(i)) != i) + abort (); + + r = a; +} + +int +main (void) +{ + __m128 x = { 1.0 }; + + foo (x, x, x, x, 5); + + if (__builtin_memcmp (&r, &x, sizeof (r))) + abort (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/regparm-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/regparm-1.c new file mode 100644 index 000000000..b9acacf9e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/regparm-1.c @@ -0,0 +1,60 @@ +/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +#include "check.h" + +#ifndef ALIGNMENT +#define ALIGNMENT 64 +#endif + +typedef int aligned __attribute__((aligned(ALIGNMENT))); + +int test_nested (int i) +{ + aligned y; + + int __attribute__ ((__noinline__, __regparm__(2))) foo (int j, int k, int l) + { + aligned x; + + if (check_int (&x, __alignof__(x)) != x) + abort (); + + if (x != 20) + abort (); + + return i + j + k + l; + } + + if (check_int (&y, __alignof__(y)) != y) + abort (); + + if (y != 20) + abort (); + + return foo(i, i+1, i+2) * i; +} + +int __attribute__ ((__noinline__, __regparm__(3), __force_align_arg_pointer__)) +test_realigned (int j, int k, int l) +{ + aligned y; + + if (check_int (&y, __alignof__(y)) != y) + abort (); + + if (y != 20) + abort (); + + return j + k + l; +} + +int main () +{ + if (test_nested(10) != 430) + abort (); + + if (test_realigned(10, 11, 12) != 33) + abort (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/ret-struct-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/ret-struct-1.c new file mode 100644 index 000000000..b218a14ed --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/ret-struct-1.c @@ -0,0 +1,36 @@ +/* { dg-do run } */ +/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */ + +#include "check.h" + +#ifndef ALIGNMENT +#define ALIGNMENT 64 +#endif + +extern void abort(); +typedef struct my_struct +{ + char str[31]; +} stype ; + +stype g_s; + +stype __attribute__((noinline)) +foo (char arg1, char arg2, char arg3) +{ + stype __attribute__((aligned(ALIGNMENT))) s; + s.str[0] = arg1; + s.str[1] = arg2; + s.str[30] = arg3; + check(&s, ALIGNMENT); + return s; +} + +int main() +{ + g_s = foo(1,2,3); + + if (g_s.str[0] != 1 || g_s.str[1] != 2 || g_s.str[30] !=3) + abort(); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/setjmp-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/setjmp-1.c new file mode 100644 index 000000000..6ab67e395 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/setjmp-1.c @@ -0,0 +1,43 @@ +/* { dg-do run } */ + +extern int strcmp(const char *, const char *); +extern char *strcpy(char *, const char *); +extern void abort(void); +extern void exit(int); + +void *buf[20]; + +void __attribute__((noinline)) +sub2 (void) +{ + __builtin_longjmp (buf, 1); +} + +int +main () +{ + char *p = 0; + + p = (char *) __builtin_alloca (20); + + strcpy (p, "test"); + + if (__builtin_setjmp (buf)) + { + if (strcmp (p, "test") != 0) + abort (); + + exit (0); + } + + { + int *q = (int *) __builtin_alloca (p[2] * sizeof (int)); + int i; + + for (i = 0; i < p[2]; i++) + q[i] = 0; + + while (1) + sub2 (); + } +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/setjmp-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/setjmp-2.c new file mode 100644 index 000000000..2fd3be8fd --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/setjmp-2.c @@ -0,0 +1,46 @@ +/* { dg-do run { target i?86-*-linux* i?86-*-gnu* x86_64-*-linux* } } */ + +#include <setjmp.h> +#include <signal.h> + +#ifndef NULL +#define NULL ((void *)0) +#endif +static jmp_buf segv_jmpbuf; + +static void segv_handler(int seg) +{ + __builtin_longjmp(segv_jmpbuf, 1); +} + +static int is_addressable(void *p, size_t size) +{ + volatile char * volatile cp = (volatile char *)p; + volatile int ret; + struct sigaction sa, origsa; + sigset_t mask; + + sa.sa_handler = segv_handler; + sa.sa_flags = 0; + sigfillset(&sa.sa_mask); + sigaction(SIGSEGV, &sa, &origsa); + sigprocmask(SIG_SETMASK, NULL, &mask); + + if (__builtin_setjmp(segv_jmpbuf) == 0) { + while(size--) + *cp++; + ret = 1; + } else + ret = 0; + + sigaction(SIGSEGV, &origsa, NULL); + sigprocmask(SIG_SETMASK, &mask, NULL); + + return ret; +} + +int main(int argc, char **argv) +{ + is_addressable(0x0, 1); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/setjmp-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/setjmp-3.c new file mode 100644 index 000000000..fee0d281f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/setjmp-3.c @@ -0,0 +1,37 @@ +/* { dg-do run } */ + +#include <setjmp.h> + +extern void abort (void); + +jmp_buf buf; + +void raise0(void) +{ + __builtin_longjmp (buf, 1); +} + +int execute(int cmd) +{ + int last = 0; + + if (__builtin_setjmp (buf) == 0) + while (1) + { + last = 1; + raise0 (); + } + + if (last == 0) + return 0; + else + return cmd; +} + +int main(void) +{ + if (execute (1) == 0) + abort (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/setjmp-4.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/setjmp-4.c new file mode 100644 index 000000000..d1671223a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/setjmp-4.c @@ -0,0 +1,39 @@ +/* { dg-do run } */ + +#include <setjmp.h> + +extern void abort (void); + +jmp_buf buf; + +void raise0(void) +{ + __builtin_longjmp (buf, 1); +} + +int execute(int cmd) +{ + int last = 0; + + __builtin_setjmp (buf); + + if (last == 0) + while (1) + { + last = 1; + raise0 (); + } + + if (last == 0) + return 0; + else + return cmd; +} + +int main(void) +{ + if (execute (1) == 0) + abort (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/sibcall-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/sibcall-1.c new file mode 100644 index 000000000..8c174758f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/sibcall-1.c @@ -0,0 +1,35 @@ +/* { dg-do run } */ + +extern int ok (int); +extern void exit (); +static int gen_x86_64_shrd (int); +static int +gen_x86_64_shrd(int a __attribute__ ((__unused__))) +{ + return 0; +} + +extern int gen_x86_shrd_1 (int); +extern void ix86_split_ashr (int); + +void +ix86_split_ashr (int mode) +{ + (mode != 0 + ? ok + : gen_x86_64_shrd) (0); +} + +volatile int one = 1; +int +main (void) +{ + ix86_split_ashr (one); + return 1; +} + +int +ok (int i) +{ + exit (i); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/stackalign.exp b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/stackalign.exp new file mode 100644 index 000000000..8ef84fe35 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/stackalign.exp @@ -0,0 +1,69 @@ +# 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/>. + +# This harness is for tests that should be run at all optimisation levels. + +load_lib gcc-dg.exp +load_lib torture-options.exp + +global DG_TORTURE_OPTIONS LTO_TORTURE_OPTIONS + +dg-init +torture-init + +# default_flags are replaced by a dg-options test directive, or appended +# to by using dg-additional-options. Use default_flags for options that +# are used in all of the torture sets to limit the amount of noise in +# test summaries. +set default_flags "" + +# torture_flags are combined with other torture options and do not +# affect options specified within a test. +set torture_flags "" + +set stackalign_options [list] +if { [check_effective_target_automatic_stack_alignment] } then { + append default_flags " -mstackrealign" + append default_flags " -mpreferred-stack-boundary=5" +} +if { [istarget i?86*-*-*] || [istarget x86_64-*-*] } then { + append default_flags " -mno-mmx" +} +lappend stackalign_options [join $torture_flags] + +if { [check_effective_target_fpic] } then { + set pic_torture_flags $torture_flags + append pic_torture_flags " -fpic" + lappend stackalign_options [join $pic_torture_flags] +} + +if { [check_effective_target_automatic_stack_alignment] } then { + append torture_flags " -mforce-drap" + lappend stackalign_options [join $torture_flags] + if { [check_effective_target_fpic] } then { + set pic_torture_flags $torture_flags + append pic_torture_flags " -fpic" + lappend stackalign_options [join $pic_torture_flags] + } +} + +# Combine stackalign options with the usual torture optimization flags. +set-torture-options [concat $DG_TORTURE_OPTIONS $LTO_TORTURE_OPTIONS] $stackalign_options + +gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.c]] "$default_flags" + +torture-finish +dg-finish diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/struct-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/struct-1.c new file mode 100644 index 000000000..860213298 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/struct-1.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ +/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */ + +#include "check.h" + +#ifndef ALIGNMENT +#define ALIGNMENT 64 +#endif + +typedef int aligned __attribute__((aligned(ALIGNMENT))); + +void +foo (void) +{ + struct i + { + aligned i; + } i; + + if (check_int (&i.i, __alignof__(i.i)) != i.i) + abort (); +} + +int +main() +{ + foo (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/thiscall-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/thiscall-1.c new file mode 100644 index 000000000..27b71b60c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/thiscall-1.c @@ -0,0 +1,31 @@ +/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +#include "check.h" + +#ifndef ALIGNMENT +#define ALIGNMENT 64 +#endif + +typedef int aligned __attribute__((aligned(ALIGNMENT))); + +int global; + +__attribute__ ((thiscall)) +void +foo (int j, int k, int m, int n, int o) +{ + aligned i; + + if (check_int (&i, __alignof__(i)) != i) + abort (); + + if (i != 20 || j != 1 || k != 2 || m != 3 || n != 4 || o != 5) + abort (); +} + +int +main() +{ + foo (1, 2, 3, 4, 5); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/vararg-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/vararg-1.c new file mode 100644 index 000000000..5b36f2cd4 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/vararg-1.c @@ -0,0 +1,60 @@ +/* { dg-do run } */ +/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */ + +#include <stdarg.h> +#include "check.h" + +#ifndef ALIGNMENT +#define ALIGNMENT 64 +#endif + +typedef int aligned __attribute__((aligned(ALIGNMENT))); + +int global; + +void +bar (char *p, int size) +{ + __builtin_strncpy (p, "good", size); +} + +void +foo (const char *fmt, ...) +{ + va_list arg; + char *p; + aligned i; + int size; + double x; + + va_start (arg, fmt); + size = va_arg (arg, int); + if (size != 5) + abort (); + p = __builtin_alloca (size + 1); + + x = va_arg (arg, double); + if (x != 5.0) + abort (); + + bar (p, size); + if (__builtin_strncmp (p, "good", size) != 0) + { +#ifdef DEBUG + p[size] = '\0'; + printf ("Failed: %s != good\n", p); +#endif + abort (); + } + + if (check_int (&i, __alignof__(i)) != i) + abort (); + va_end (arg); +} + +int +main() +{ + foo ("foo", 5, 5.0); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/vararg-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/vararg-2.c new file mode 100644 index 000000000..6740e994e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/vararg-2.c @@ -0,0 +1,66 @@ +/* { dg-do run } */ +/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */ + +#include <stdarg.h> +#include "check.h" + +#ifndef ALIGNMENT +#define ALIGNMENT 64 +#endif + +typedef int aligned __attribute__((aligned(ALIGNMENT))); + +int global; + +void +bar (char *p, int size) +{ + __builtin_strncpy (p, "good", size); +} + +void +test (va_list arg) +{ + char *p; + aligned i; + int size; + double x; + + size = va_arg (arg, int); + if (size != 5) + abort (); + + p = __builtin_alloca (size + 1); + + x = va_arg (arg, double); + if (x != 5.0) + abort (); + + bar (p, size); + if (__builtin_strncmp (p, "good", size) != 0) + { +#ifdef DEBUG + p[size] = '\0'; + printf ("Failed: %s != good\n", p); +#endif + abort (); + } + + if (check_int (&i, __alignof__(i)) != i) + abort (); +} + +void +foo (const char *fmt, ...) +{ + va_list arg; + va_start (arg, fmt); + test (arg); + va_end (arg); +} +int +main() +{ + foo ("foo", 5, 5.0); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/vararg-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/vararg-3.c new file mode 100644 index 000000000..baf398c12 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/stackalign/vararg-3.c @@ -0,0 +1,78 @@ +/* PR middle-end/37009 */ +/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ +/* { dg-additional-options "-mmmx -msse2" } */ +/* { dg-require-effective-target sse2_runtime } */ + +#include <stdarg.h> +#include <emmintrin.h> +#include "check.h" + +#ifndef ALIGNMENT +#define ALIGNMENT 16 +#endif + +typedef int aligned __attribute__((aligned(ALIGNMENT))); + +void +bar (char *p, int size) +{ + __builtin_strncpy (p, "good", size); +} + +__m128 a = { 1.0 }; + +void +test (va_list arg) +{ + char *p; + aligned i; + int size; + double x; + __m128 e; + + size = va_arg (arg, int); + if (size != 5) + abort (); + + p = __builtin_alloca (size + 1); + + x = va_arg (arg, double); + if (x != 5.0) + abort (); + + bar (p, size); + if (__builtin_strncmp (p, "good", size) != 0) + { +#ifdef DEBUG + p[size] = '\0'; + printf ("Failed: %s != good\n", p); +#endif + abort (); + } + + if (check_int (&i, __alignof__(i)) != i) + abort (); + + e = va_arg (arg, __m128); + if (__builtin_memcmp (&e, &a, sizeof (e))) + abort (); +} + +void +foo (const char *fmt, ...) +{ + va_list arg; + va_start (arg, fmt); + test (arg); + va_end (arg); +} + +int +main (void) +{ + __m128 x = { 1.0 }; + + foo ("foo", 5, 5.0, x); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/run-gd.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/run-gd.c new file mode 100644 index 000000000..6335e73c3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/run-gd.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ +/* { dg-require-effective-target tls_runtime } */ +/* { dg-add-options tls } */ + +extern void abort (void); + +__thread int tls_gd __attribute__((tls_model("global-dynamic"))) = 0; + +int get_gd (void) +{ + return tls_gd; +} + +int *get_gdp (void) +{ + return &tls_gd; +} + +int main (void) +{ + int val; + + val = get_gd (); + if (val != 0) + abort (); + + val = *get_gdp (); + if (val != 0) + abort (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/run-ie.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/run-ie.c new file mode 100644 index 000000000..ec07a4447 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/run-ie.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ +/* { dg-require-effective-target tls_runtime } */ +/* { dg-add-options tls } */ + +extern void abort (void); + +__thread int tls_ie __attribute__((tls_model("initial-exec"))) = 4; + +int get_ie (void) +{ + return tls_ie; +} + +int *get_iep (void) +{ + return &tls_ie; +} + +int main (void) +{ + int val; + + val = get_ie (); + if (val != 4) + abort (); + + val = *get_iep (); + if (val != 4) + abort (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/run-ld.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/run-ld.c new file mode 100644 index 000000000..cabfaf794 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/run-ld.c @@ -0,0 +1,33 @@ +/* { dg-do run } */ +/* { dg-require-effective-target tls_runtime } */ +/* { dg-add-options tls } */ + +extern void abort (void); + +__thread int tls_ld __attribute__((tls_model("local-dynamic"))) = 1; +__thread int tls_ld2 __attribute__((tls_model("local-dynamic"))) = 2; + +int get_ld (void) +{ + return tls_ld + tls_ld2; +} + +int *get_ldp (void) +{ + return &tls_ld; +} + +int main (void) +{ + int val; + + val = get_ld (); + if (val != 1 + 2) + abort (); + + val = *get_ldp (); + if (val != 1) + abort (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/run-le.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/run-le.c new file mode 100644 index 000000000..0c340f30e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/run-le.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ +/* { dg-require-effective-target tls_runtime } */ +/* { dg-add-options tls } */ + +extern void abort (void); + +__thread int tls_le __attribute__((tls_model("local-exec"))) = 3; + +int get_le (void) +{ + return tls_le; +} + +int *get_lep (void) +{ + return &tls_le; +} + +int main (void) +{ + int val; + + val = get_le (); + if (val != 3) + abort (); + + val = *get_lep (); + if (val != 3) + abort (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/thr-init-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/thr-init-1.c new file mode 100644 index 000000000..ff3338ffb --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/thr-init-1.c @@ -0,0 +1,26 @@ +/* { dg-do run } */ +/* { dg-require-effective-target tls_runtime } */ +/* { dg-add-options tls } */ + +extern int printf (char *,...); +extern void abort() ; + +int test_code(int b) +{ +static __thread int fstat = 1; + fstat += b ; + return fstat; +} + +int main (int ac, char *av[]) +{ + int a = test_code(1); + + if ( a != 2 ) + { + printf ("a=%d\n", a) ; + abort (); + } + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/thr-init-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/thr-init-2.c new file mode 100644 index 000000000..44156232c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/thr-init-2.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ +/* { dg-require-effective-target tls_runtime } */ +/* { dg-add-options tls } */ + +extern int printf (char *,...); +extern void abort() ; + +static __thread int fstat ; +static __thread int fstat = 1; +static __thread int fstat ; + +int test_code(int b) +{ + fstat += b ; + return fstat; +} + +int main (int ac, char *av[]) +{ + int a = test_code(1); + + if ( a != 2 || fstat != 2 ) + { + printf ("a=%d fstat=%d\n", a, fstat) ; + abort (); + } + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/tls-reload-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/tls-reload-1.c new file mode 100644 index 000000000..bd9a0b891 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/tls-reload-1.c @@ -0,0 +1,49 @@ +/* { dg-do run } */ +/* { dg-require-effective-target tls_runtime } */ +/* { dg-add-options tls } */ + +#define ARRAY(X) X##_array +#define DECLARE(X) \ + __thread int X; \ + __thread int ARRAY(X)[4]; \ + int *volatile *__attribute__((noinline)) \ + check##X (int *volatile *y) \ + { \ + if (!y || *y++ != &X || *y++ != &ARRAY(X)[3]) \ + return 0; \ + return y; \ + } +#define COPY(X) *y++ = &X; *y++ = &ARRAY(X)[3]; +#define CHECK(X) y = check##X (y); +#define A(M, X) M(X##0) M(X##1) M(X##2) M(X##3) M(X##4) M(X##5) M(X##6) M(X##7) +#define B(M, X) A(M, X##0) A(M, X##1) A(M, X##2) +#define C(M, X) B(M, X) B(M, X) B(M, X) + +#define NM 2 +#define NA (NM * 8) +#define NB (NA * 3) +#define NC (NB * 3) + +extern void abort (void); + +B(DECLARE, tls) + +void __attribute__ ((noinline)) +setup (int *volatile *y) +{ + C(COPY, tls) +} + +int +main (void) +{ + int *volatile array[NC]; + int *volatile *y = array; + int i; + + setup (array); + C(CHECK, tls); + if (!y) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/tls-test.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/tls-test.c new file mode 100644 index 000000000..8a23e77c1 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/tls-test.c @@ -0,0 +1,52 @@ +/* { dg-do run } */ +/* { dg-require-effective-target tls } */ +/* { dg-require-effective-target pthread } */ +/* { dg-options "-pthread" } */ + +#include <pthread.h> +extern int printf (char *,...); +__thread int a = 5; +int *volatile a_in_other_thread = (int *) 12345; + +static void * +thread_func (void *arg) +{ + a_in_other_thread = &a; + a+=5; + *((int *) arg) = a; + return (void *)0; +} + +int +main () +{ + pthread_t thread; + void *thread_retval; + int *volatile a_in_main_thread; + int *volatile again ; + int thr_a; + + a_in_main_thread = &a; + + if (pthread_create (&thread, (pthread_attr_t *)0, thread_func, &thr_a)) + return 0; + + if (pthread_join (thread, &thread_retval)) + return 0; + + again = &a; + if (again != a_in_main_thread) + { + printf ("FAIL: main thread addy changed from 0x%0x to 0x%0x\n", + a_in_other_thread, again); + return 1; + } + + if (a != 5 || thr_a != 10 || (a_in_other_thread == a_in_main_thread)) + { + printf ("FAIL: a= %d, thr_a = %d Addr = 0x%0x\n", + a, thr_a, a_in_other_thread); + return 1; + } + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/tls.exp b/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/tls.exp new file mode 100644 index 000000000..e8404232b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/tls/tls.exp @@ -0,0 +1,57 @@ +# Copyright (C) 2010-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. + +# Load support procs. +load_lib gcc-dg.exp +load_lib torture-options.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" +} + +global DG_TORTURE_OPTIONS LTO_TORTURE_OPTIONS +set TLS_TORTURE_OPTIONS $DG_TORTURE_OPTIONS +if { [check_effective_target_fpic] } then { + foreach pic {fpic fPIC} { + foreach option $DG_TORTURE_OPTIONS { + lappend TLS_TORTURE_OPTIONS "$option -$pic" + } + } +} +if { [check_effective_target_pie] } then { + foreach pie {fpie fPIE} { + foreach option $DG_TORTURE_OPTIONS { + lappend TLS_TORTURE_OPTIONS "$option -pie -$pie" + } + } +} + +# Initialize `dg'. +dg-init +torture-init +set-torture-options $TLS_TORTURE_OPTIONS {{}} $LTO_TORTURE_OPTIONS + +# Main loop. +gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \ + $DEFAULT_CFLAGS + +# All done. +torture-finish +dg-finish diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/transpose-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/transpose-1.c new file mode 100644 index 000000000..188f3b51b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/transpose-1.c @@ -0,0 +1,97 @@ +/* { dg-do run } */ +/* { dg-options "-fwhole-program" } */ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <string.h> + +void mem_init (void); +int ARCHnodes, ARCHnodes1; +int ***vel; + +/* The whole matrix VEL is flattened (3 dimensions). + All dimensions are transposed : dim 0 -> dim 2 + dim 1 -> dim 0 + dim 2 -> dim 1 +*/ +/*--------------------------------------------------------------------------*/ + +int +main (int argc, char **argv) +{ + int i, j, k; + + ARCHnodes = 2; + ARCHnodes1 = 4; + +/* Dynamic memory allocations and initializations */ + + mem_init (); + + for (i = 0; i < 3; i++) + { + for (j = 0; j < 4; j++) + { + for (k = 0; k < 2; k++) + { + printf ("[%d][%d][%d]=%d ", i, j, k, vel[k][i][j]); + } + printf ("\n"); + } + printf ("\n"); + } + for (i = 0; i < ARCHnodes; i++) + for (j = 0; j < 3; j++) + free (vel[i][j]); + + for (i = 0; i < ARCHnodes; i++) + free (vel[i]); + + free (vel); + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* Dynamic memory allocations and initializations */ + +void +mem_init (void) +{ + + int i, j, k,d; + + d = 0; + vel = (int ***) malloc (ARCHnodes * sizeof (int **)); + + for (i = 0; i < ARCHnodes; i++) + { + vel[i] = (int **) malloc (3 * sizeof (int *)); + if (vel[i] == (int **) NULL) + { + fprintf (stderr, "malloc failed for vel[%d]\n", i); + fflush (stderr); + exit (0); + } + } + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int)); + } + } + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + for (k = 0; k < ARCHnodes1; k++) + { + vel[i][j][k] = d; + d++; + } + } + } +} + +/*--------------------------------------------------------------------------*/ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/transpose-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/transpose-2.c new file mode 100644 index 000000000..bff6a3aba --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/transpose-2.c @@ -0,0 +1,94 @@ +/* { dg-do run } */ +/* { dg-options "-fwhole-program" } */ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <string.h> + +void mem_init (void); +int ARCHnodes, ARCHnodes1; +int ***vel; + +/* The whole matrix VEL is flattened (3 dimensions). + No transposing is necessary. */ +/*--------------------------------------------------------------------------*/ + +int +main (int argc, char **argv) +{ + int i, j, k; + + ARCHnodes = 2; + ARCHnodes1 = 4; + +/* Dynamic memory allocations and initializations */ + + mem_init (); + + for (j = 0; j < 2; j++) + { + for (i = 0; i < 4; i++) + { + for (k = 0; k < 2; k++) + { + printf ("[%d][%d][%d]=%d ", i, j, k, vel[k][k][k]); + } + printf ("\n"); + } + printf ("\n"); + } + for (i = 0; i < ARCHnodes; i++) + for (j = 0; j < 3; j++) + free (vel[i][j]); + + for (i = 0; i < ARCHnodes; i++) + free (vel[i]); + + free (vel); + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* Dynamic memory allocations and initializations */ + +void +mem_init (void) +{ + + int i, j, k,d; + + d = 0; + vel = (int ***) malloc (ARCHnodes * sizeof (int **)); + + for (i = 0; i < ARCHnodes; i++) + { + vel[i] = (int **) malloc (3 * sizeof (int *)); + if (vel[i] == (int **) NULL) + { + fprintf (stderr, "malloc failed for vel[%d]\n", i); + fflush (stderr); + exit (0); + } + } + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int)); + } + } + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + for (k = 0; k < ARCHnodes1; k++) + { + vel[i][j][k] = d; + d++; + } + } + } +} + +/*--------------------------------------------------------------------------*/ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/transpose-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/transpose-3.c new file mode 100644 index 000000000..da7e88701 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/transpose-3.c @@ -0,0 +1,101 @@ +/* { dg-do run } */ +/* { dg-options "-fwhole-program" } */ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <string.h> + +void mem_init (void); +int ARCHnodes, ARCHnodes1; +int ***vel; +/* The inner most dimension escapes. + The two external dimensions are flattened + after being transposed. */ +/*--------------------------------------------------------------------------*/ + +int +main (int argc, char **argv) +{ + int i, j, k; + + ARCHnodes = 2; + ARCHnodes1 = 4; + +/* Dynamic memory allocations and initializations */ + + mem_init (); + + for (j = 0; j < 4; j++) + { + for (i = 0; i < 3; i++) + { + for (k = 0; k < 2; k++) + { + printf ("[%d][%d][%d]=%d ", i, j, k, vel[k][i][j]); + } + printf ("\n"); + } + printf ("\n"); + } + vel[0][0]=vel[1][1]; + + for (i = 0; i < 2; i++) + for (j = 0; j < 3; j++) + if (i==1 && j==1) + continue; + else + free (vel[i][j]); + + for (i = 0; i < 2; i++) + free (vel[i]); + + free (vel); + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* Dynamic memory allocations and initializations */ + +void +mem_init (void) +{ + + signed int i, j, k,d; + + d = 0; + vel = (int ***) malloc (ARCHnodes * sizeof (int **)); + + for (i = 0; i < ARCHnodes; i++) + { + vel[i] = (int **) malloc (3 * sizeof (int *)); + if (vel[i] == (int **) NULL) + { + fprintf (stderr, "malloc failed for vel[%d]\n", i); + fflush (stderr); + exit (0); + } + } + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int)); + } + } + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + for (k = 0; k < ARCHnodes1; k++) + { + printf ("acc to dim2 "); + vel[i][j][k] = d; + d++; + } + } + } + printf ("\n"); +} + +/*--------------------------------------------------------------------------*/ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/transpose-4.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/transpose-4.c new file mode 100644 index 000000000..5a96a5163 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/transpose-4.c @@ -0,0 +1,100 @@ +/* { dg-do run } */ +/* { dg-options "-fwhole-program" } */ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <string.h> + +void mem_init (void); +int ARCHnodes, ARCHnodes1; +int ***vel; + +/* The whole matrix VEL is flattened (3 dimensions). + The two inner dimensions are transposed. + dim 1 -> dim 2 + dim 2 -> dim 1 +*/ +/*--------------------------------------------------------------------------*/ + +int +main (int argc, char **argv) +{ + int i, j, k; + + ARCHnodes = 2; + ARCHnodes1 = 4; + +/* Dynamic memory allocations and initializations */ + + mem_init (); + + for (j = 0; j < 4; j++) + { + for (i = 0; i < 2; i++) + { + for (k = 0; k < 3; k++) + { + printf ("[%d][%d][%d]=%d ", i, j, k, vel[i][k][j]); + } + printf ("\n"); + } + printf ("\n"); + } + for (i = 0; i < 2; i++) + for (j = 0; j < 3; j++) + free (vel[i][j]); + + for (i = 0; i < 2; i++) + free (vel[i]); + + free (vel); + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* Dynamic memory allocations and initializations */ + +void +mem_init (void) +{ + + signed int i, j, k,d; + + d = 0; + vel = (int ***) malloc (ARCHnodes * sizeof (int **)); + + for (i = 0; i < ARCHnodes; i++) + { + vel[i] = (int **) malloc (3 * sizeof (int *)); + if (vel[i] == (int **) NULL) + { + fprintf (stderr, "malloc failed for vel[%d]\n", i); + fflush (stderr); + exit (0); + } + } + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int)); + } + } + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + for (k = 0; k < ARCHnodes1; k++) + { + printf ("acc to dim2 "); + vel[i][j][k] = d; + d++; + } + } + } + printf ("\n"); + +} + +/*--------------------------------------------------------------------------*/ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/transpose-5.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/transpose-5.c new file mode 100644 index 000000000..049d7b03e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/transpose-5.c @@ -0,0 +1,96 @@ +/* { dg-do run } */ +/* { dg-options "-fwhole-program" } */ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <string.h> + +void mem_init (void); +int ARCHnodes, ARCHnodes1; +int ***vel; + +/* The whole matrix VEL is flattened (3 dimensions). + The dimensions are NOT transposed. */ +/*--------------------------------------------------------------------------*/ + +int +main (int argc, char **argv) +{ + int i, j, k; + + ARCHnodes = 2; + ARCHnodes1 = 4; + +/* Dynamic memory allocations and initializations */ + + mem_init (); + + for (j = 0; j < 3; j++) + { + for (i = 0; i < 2; i++) + { + for (k = 0; k < 4; k++) + { + printf ("[%d][%d][%d]=%d ", i, j, k, vel[i][j][k]); + } + printf ("\n"); + } + printf ("\n"); + } + for (i = 0; i < 2; i++) + for (j = 0; j < 3; j++) + free (vel[i][j]); + + for (i = 0; i < 2; i++) + free (vel[i]); + + free (vel); + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* Dynamic memory allocations and initializations */ + +void +mem_init (void) +{ + + signed int i, j, k,d; + + d = 0; + vel = (int ***) malloc (ARCHnodes * sizeof (int **)); + + for (i = 0; i < ARCHnodes; i++) + { + vel[i] = (int **) malloc (3 * sizeof (int *)); + if (vel[i] == (int **) NULL) + { + fprintf (stderr, "malloc failed for vel[%d]\n", i); + fflush (stderr); + exit (0); + } + } + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int)); + } + } + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + for (k = 0; k < ARCHnodes1; k++) + { + printf ("acc to dim2 "); + vel[i][j][k] = d; + d++; + } + } + } + printf ("\n"); +} + +/*--------------------------------------------------------------------------*/ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/transpose-6.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/transpose-6.c new file mode 100644 index 000000000..9b3329b53 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/transpose-6.c @@ -0,0 +1,96 @@ +/* { dg-do run } */ +/* { dg-options "-fwhole-program" } */ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <string.h> + +void mem_init (void); +int ARCHnodes, ARCHnodes1; +int ***vel; + +/* The whole matrix VEL is flattened (3 dimensions). + The dimensions are NOT transposed. */ +/*--------------------------------------------------------------------------*/ + +int +main (int argc, char **argv) +{ + int i, j, k; + + ARCHnodes = 2; + ARCHnodes1 = 4; + +/* Dynamic memory allocations and initializations */ + + mem_init (); + + for (j = 0; j < 3; j++) + { + for (i = 0; i < 2; i++) + { + for (k = 0; k < 3; k++) + { + printf ("[%d][%d][%d]=%d ", i, j, k, vel[i][k][k]); + } + printf ("\n"); + } + printf ("\n"); + } + for (i = 0; i < 2; i++) + for (j = 0; j < 3; j++) + free (vel[i][j]); + + for (i = 0; i < 2; i++) + free (vel[i]); + + free (vel); + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* Dynamic memory allocations and initializations */ + +void +mem_init (void) +{ + + signed int i, j, k,d; + + d = 0; + vel = (int ***) malloc (ARCHnodes * sizeof (int **)); + + for (i = 0; i < ARCHnodes; i++) + { + vel[i] = (int **) malloc (3 * sizeof (int *)); + if (vel[i] == (int **) NULL) + { + fprintf (stderr, "malloc failed for vel[%d]\n", i); + fflush (stderr); + exit (0); + } + } + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int)); + } + } + for (i = 0; i < ARCHnodes; i++) + { + for (j = 0; j < 3; j++) + { + for (k = 0; k < ARCHnodes1; k++) + { + printf ("acc to dim2 "); + vel[i][j][k] = d; + d++; + } + } + } + printf ("\n"); +} + +/*--------------------------------------------------------------------------*/ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/tree-loop-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/tree-loop-1.c new file mode 100644 index 000000000..1d3869178 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/tree-loop-1.c @@ -0,0 +1,21 @@ +/* PR tree-optimization/20640 */ + +/* After unrolling the loop, we'd turn some conditional branches into + unconditional ones, but branch redirection would fail to compute + the PHI args for the PHI nodes in the replacement edge + destination, so they'd remain NULL causing crashes later on. */ + +/* { dg-do compile } */ + +static int a = 0; +extern int foo (void); +extern int *bar (void) __attribute__ ((__const__)); + +void +test (int x) +{ + int b = 10; + while (foo () == -1 && *bar () == 4 && b > 0) + --b; + a = x; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/type-generic-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/type-generic-1.c new file mode 100644 index 000000000..f6949cff1 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/type-generic-1.c @@ -0,0 +1,14 @@ +/* Do the type-generic tests. Unlike pr28796-2.c, we test these + without any fast-math flags. */ + +/* { dg-do run } */ +/* { dg-skip-if "No Inf/NaN support" { spu-*-* } } */ +/* { dg-options "-DUNSAFE" { target tic6x*-*-* } } */ +/* { dg-add-options ieee } */ + +#include "../tg-tests.h" + +int main(void) +{ + return main_tests (); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/va-arg-25.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/va-arg-25.c new file mode 100644 index 000000000..64aaffac8 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/va-arg-25.c @@ -0,0 +1,44 @@ +/* Varargs and vectors! */ + +/* { dg-do run } */ +/* { dg-options "-msse" { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-require-effective-target sse_runtime { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-options "-mabi=altivec -maltivec" { target { powerpc-*-* powerpc64-*-* } } } */ +/* { dg-require-effective-target vmx_hw { target { powerpc-*-* powerpc64-*-* } } } */ + +#include <stdarg.h> +#include <stdlib.h> +#include <limits.h> + +#define vector __attribute__((vector_size(16))) + +const vector unsigned int v1 = {10,11,12,13}; +const vector unsigned int v2 = {20,21,22,23}; + +void foo(int a, ...) +{ + va_list args; + vector unsigned int v; + + va_start (args, a); + v = va_arg (args, vector unsigned int); + if (a != 1 || memcmp (&v, &v1, sizeof (v)) != 0) + abort (); + a = va_arg (args, int); + if (a != 2) + abort (); + v = va_arg (args, vector unsigned int); + if (memcmp (&v, &v2, sizeof (v)) != 0) + abort (); + va_end (args); +} + +int main(void) +{ +#if INT_MAX == 2147483647 + foo (1, (vector unsigned int){10,11,12,13}, 2, + (vector unsigned int){20,21,22,23}); +#endif + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vec-cvt-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vec-cvt-1.c new file mode 100644 index 000000000..78a900956 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vec-cvt-1.c @@ -0,0 +1,213 @@ +/* { dg-do run } */ +/* This test is too big for small targets. */ +/* { dg-require-effective-target size32plus } */ + +#include <stdlib.h> + +#define N 1024 +signed char sc[N]; +short ss[N]; +int si[N]; +long long sl[N]; +unsigned char uc[N]; +unsigned short us[N]; +unsigned int ui[N]; +unsigned long long ul[N]; +float f[N]; +double d[N]; + +#define FN1(from, to) \ +__attribute__((noinline, noclone)) void \ +from##2##to (void) \ +{ \ + int i; \ + for (i = 0; i < N; i++) \ + to[i] = from[i]; \ +} +#define FN(intt, fltt) FN1 (intt, fltt) FN1 (fltt, intt) + +FN (sc, f) +FN (ss, f) +FN (si, f) +FN (sl, f) +FN (uc, f) +FN (us, f) +FN (ui, f) +FN (ul, f) +FN (sc, d) +FN (ss, d) +FN (si, d) +FN (sl, d) +FN (uc, d) +FN (us, d) +FN (ui, d) +FN (ul, d) + +#define FLTTEST(min, max, intt) \ +__attribute__((noinline, noclone)) void \ +flttointtest##intt (void) \ +{ \ + int i; \ + volatile float fltmin, fltmax, vf, vf2; \ + volatile double dblmin, dblmax, vd, vd2; \ + if (min == 0) \ + fltmin = 0.0f; \ + else \ + { \ + vf2 = fltmin = min - 1.0f; \ + for (vf = 1.0f; (fltmin = vf2 + vf) == vf2; vf = vf * 2.0f) \ + ; \ + } \ + vf2 = fltmax = max + 1.0f; \ + for (vf = 1.0f; (fltmax = vf2 - vf) == vf2; vf = vf * 2.0f) \ + ; \ + if (min == 0) \ + dblmin = 0.0; \ + else \ + { \ + vd2 = dblmin = min - 1.0; \ + for (vd = 1.0; (dblmin = vd2 + vd) == vd2; vd = vd * 2.0) \ + ; \ + } \ + vd2 = dblmax = max + 1.0; \ + for (vd = 1.0; (dblmax = vd2 - vd) == vd2; vd = vd * 2.0) \ + ; \ + for (i = 0; i < N; i++) \ + { \ + asm (""); \ + if (i == 0) \ + f[i] = fltmin; \ + else if (i < N / 4) \ + f[i] = fltmin + i + 0.25f; \ + else if (i < 3 * N / 4) \ + f[i] = (fltmax + fltmin) / 2.0 - N * 8 + 16.0f * i; \ + else \ + f[i] = fltmax - N + 1 + i; \ + if (f[i] < fltmin) f[i] = fltmin; \ + if (f[i] > fltmax) f[i] = fltmax; \ + if (i == 0) \ + d[i] = dblmin; \ + else if (i < N / 4) \ + d[i] = dblmin + i + 0.25f; \ + else if (i < 3 * N / 4) \ + d[i] = (dblmax + dblmin) / 2.0 - N * 8 + 16.0f * i; \ + else \ + d[i] = dblmax - N + 1 + i; \ + if (d[i] < dblmin) d[i] = dblmin; \ + if (d[i] > dblmax) d[i] = dblmax; \ + } \ + f2##intt (); \ + for (i = 0; i < N; i++) \ + if (intt[i] != (__typeof (intt[0])) f[i]) \ + abort (); \ + d2##intt (); \ + for (i = 0; i < N; i++) \ + if (intt[i] != (__typeof (intt[0])) d[i]) \ + abort (); \ + for (i = 0; i < N; i++) \ + { \ + unsigned long long r = rand (); \ + r = (r << 21) ^ (unsigned) rand (); \ + r = (r << 21) ^ (unsigned) rand (); \ + asm (""); \ + f[i] = (r >> 59) / 32.0f + (__typeof (intt[0])) r; \ + if (f[i] < fltmin) f[i] = fltmin; \ + if (f[i] > fltmax) f[i] = fltmax; \ + d[i] = (r >> 59) / 32.0 + (__typeof (intt[0])) r; \ + if (d[i] < dblmin) f[i] = dblmin; \ + if (d[i] > dblmax) f[i] = dblmax; \ + } \ + f2##intt (); \ + for (i = 0; i < N; i++) \ + if (intt[i] != (__typeof (intt[0])) f[i]) \ + abort (); \ + d2##intt (); \ + for (i = 0; i < N; i++) \ + if (intt[i] != (__typeof (intt[0])) d[i]) \ + abort (); \ +} \ + \ +__attribute__((noinline, noclone)) void \ +inttoflttest##intt (void) \ +{ \ + int i; \ + volatile float vf; \ + volatile double vd; \ + for (i = 0; i < N; i++) \ + { \ + asm (""); \ + if (i < N / 4) \ + intt[i] = min + i; \ + else if (i < 3 * N / 4) \ + intt[i] = (max + min) / 2 - N * 8 + 16 * i; \ + else \ + intt[i] = max - N + 1 + i; \ + } \ + intt##2f (); \ + for (i = 0; i < N; i++) \ + { \ + vf = intt[i]; \ + if (f[i] != vf) \ + abort (); \ + } \ + intt##2d (); \ + for (i = 0; i < N; i++) \ + { \ + vd = intt[i]; \ + if (d[i] != vd) \ + abort (); \ + } \ + for (i = 0; i < N; i++) \ + { \ + unsigned long long r = rand (); \ + r = (r << 21) ^ (unsigned) rand (); \ + r = (r << 21) ^ (unsigned) rand (); \ + asm (""); \ + intt[i] = r; \ + } \ + intt##2f (); \ + for (i = 0; i < N; i++) \ + { \ + vf = intt[i]; \ + if (f[i] != vf) \ + abort (); \ + } \ + intt##2d (); \ + for (i = 0; i < N; i++) \ + { \ + vd = intt[i]; \ + if (d[i] != vd) \ + abort (); \ + } \ +} + +FLTTEST (- __SCHAR_MAX__ - 1, __SCHAR_MAX__, sc) +FLTTEST (- __SHRT_MAX__ - 1, __SHRT_MAX__, ss) +FLTTEST (- __INT_MAX__ - 1, __INT_MAX__, si) +FLTTEST (- __LONG_LONG_MAX__ - 1LL, __LONG_LONG_MAX__, sl) +FLTTEST (0, 2U * __SCHAR_MAX__ + 1, uc) +FLTTEST (0, 2U * __SHRT_MAX__ + 1, us) +FLTTEST (0, 2U * __INT_MAX__ + 1, ui) +FLTTEST (0, 2ULL * __LONG_LONG_MAX__ + 1, ul) + +int +main () +{ + flttointtestsc (); + flttointtestss (); + flttointtestsi (); + flttointtestsl (); + flttointtestuc (); + flttointtestus (); + flttointtestui (); + flttointtestul (); + inttoflttestsc (); + inttoflttestss (); + inttoflttestsi (); + inttoflttestsl (); + inttoflttestuc (); + inttoflttestus (); + inttoflttestui (); + inttoflttestul (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vector-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vector-1.c new file mode 100644 index 000000000..205fee6d6 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vector-1.c @@ -0,0 +1,42 @@ +/* Check that vector extraction works correctly. */ + +/* { dg-do run } */ +/* { dg-options "-msse" { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-require-effective-target sse_runtime { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-options "-mabi=altivec" { target { powerpc-*-* powerpc64-*-* } } } */ +/* { dg-require-effective-target vmx_hw { target { powerpc-*-* powerpc64--*-* } } } */ + +#define vector __attribute__((vector_size(16) )) + +int f0(vector int t) +{ + return ((int*)&t)[0]; +} +int f1(vector int t) +{ + return ((int*)&t)[1]; +} +int f2(vector int t) +{ + return ((int*)&t)[2]; +} +int f3(vector int t) +{ + return ((int*)&t)[3]; +} +int main(void) +{ + vector int a = {0, 1, 2, 3}; + /* Make sure that we have the correct size for the vectors. */ + if (sizeof(int) != 4) + __builtin_exit (0); + if (f0(a) != 0) + __builtin_abort (); + if (f1(a) != 1) + __builtin_abort (); + if (f2(a) != 2) + __builtin_abort (); + if (f3(a) != 3) + __builtin_abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vector-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vector-2.c new file mode 100644 index 000000000..6cc56cfae --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vector-2.c @@ -0,0 +1,52 @@ +/* Check that vector insertion works correctly. */ + +/* { dg-do run } */ +/* { dg-options "-msse" { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-require-effective-target sse_runtime { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-options "-mabi=altivec" { target { powerpc-*-* powerpc64-*-* } } } */ +/* { dg-require-effective-target vmx_hw { target { powerpc-*-* powerpc64--*-* } } } */ + +#define vector __attribute__((vector_size(16) )) + +vector int f0(vector int t, int a) +{ + ((int*)&t)[0] = a; + return t; +} +vector int f1(vector int t, int a) +{ + ((int*)&t)[1] = a; + return t; +} +vector int f2(vector int t, int a) +{ + ((int*)&t)[2] = a; + return t; +} +vector int f3(vector int t, int a) +{ + ((int*)&t)[3] = a; + return t; +} +int main(void) +{ + vector int a = {0, 0, 0, 0}; + vector int b = {1, 0, 0, 0}; + vector int c = {0, 1, 0, 0}; + vector int d = {0, 0, 1, 0}; + vector int e = {0, 0, 0, 1}; + vector int a0; + a0 = f0(a, 1); + if (memcmp (&a0, &b, sizeof(a0))) + __builtin_abort (); + a0 = f1(a, 1); + if (memcmp (&a0, &c, sizeof(a0))) + __builtin_abort (); + a0 = f2(a, 1); + if (memcmp (&a0, &d, sizeof(a0))) + __builtin_abort (); + a0 = f3(a, 1); + if (memcmp (&a0, &e, sizeof(a0))) + __builtin_abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vector-shift2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vector-shift2.c new file mode 100644 index 000000000..0e8a0eb24 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vector-shift2.c @@ -0,0 +1,61 @@ +/* { dg-do run } */ + +#define vector(elcount, type) \ +__attribute__((vector_size((elcount)*sizeof(type)))) type + +#define vidx(type, vec, idx) (*((type *) &(vec) + idx)) +#define schar signed char +#define uchar unsigned char + +#define ch14 1,2,3,4 +#define ch1 1,1,1,1 +#define chm1 -1,-1,-1,-1 + +int main (int argc, char *argv[]) { + vector(16, uchar) vuchar = { ch14, ch14, ch14, ch14}; + vector(16, schar) vchar0 = { ch1, ch1, ch1, ch1}; + vector(16, schar) vchar1 = { chm1, chm1, chm1, chm1}; + + vector(16, schar) i1, i2, i3; + vector(16, uchar) u1, u2, u3; + + i1 = vchar1<< vchar0; + + if (vidx(schar, i1, 0) != ((schar)-1 << (schar)1)) + __builtin_abort (); + if (vidx(schar, i1, 1) != ((schar)-1 << (schar)1)) + __builtin_abort (); + if (vidx(schar, i1, 2) != ((schar)-1 << (schar)1)) + __builtin_abort (); + if (vidx(schar, i1, 3) != ((schar)-1 << (schar)1)) + __builtin_abort (); + u1 = vuchar << vchar0; + + if (vidx(uchar, u1, 0) != ((uchar)1 << (schar)1)) + __builtin_abort (); + if (vidx(uchar, u1, 1) != ((uchar)2 << (schar)1)) + __builtin_abort (); + if (vidx(uchar, u1, 2) != ((uchar)3 << (schar)1)) + __builtin_abort (); + if (vidx(uchar, u1, 3) != ((uchar)4 << (schar)1)) + __builtin_abort (); + + + i2 = vchar1 >> vuchar; + + if (vidx(schar, i2, 0) != ((schar)-1 >> (uchar)1)) + __builtin_abort (); + if (vidx(schar, i2, 1) != ((schar)-1 >> (uchar)2)) + __builtin_abort (); + if (vidx(schar, i2, 2) != ((schar)-1 >> (uchar)3)) + __builtin_abort (); + if (vidx(schar, i2, 3) != ((schar)-1 >> (uchar)4)) + __builtin_abort (); + + vchar1 >>= vuchar; + vuchar <<= vchar0; + vuchar <<= vchar1; + + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vector-shuffle1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vector-shuffle1.c new file mode 100644 index 000000000..14e435b8a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vector-shuffle1.c @@ -0,0 +1,21 @@ +/* PR54219 */ +/* { dg-do run } */ + +extern void abort (void); + +typedef int v2si __attribute__((vector_size(2*sizeof(int)))); + +void f(v2si *x) +{ + /* This requires canonicalization of the mask to { 1, 0 }. */ + *x = __builtin_shuffle(*x, *x, (v2si) { 5, 0 }); +} + +int main() +{ + v2si y = { 1, 2 }; + f(&y); + if (y[0] != 2 || y[1] != 1) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-16.inc b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-16.inc new file mode 100644 index 000000000..f04b8dded --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-16.inc @@ -0,0 +1,139 @@ +#define N 16 +#define TESTS \ +T (0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15) \ +T (1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) \ +T (2, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7) \ +T (3, 0, 18, 7, 16, 23, 5, 4, 22, 1, 6, 21, 20, 19, 3, 17, 2) \ +T (4, 0, 1, 2, 3, 4, 5, 6, 7, 7, 1, 2, 0, 4, 5, 6, 3) \ +T (5, 0, 19, 16, 3, 2, 17, 18, 1, 24, 8, 11, 10, 27, 26, 25, 9) \ +T (6, 4, 23, 20, 7, 6, 21, 22, 5, 28, 12, 15, 14, 31, 30, 29, 13) \ +T (7, 7, 1, 2, 0, 4, 5, 6, 3, 7, 1, 2, 0, 4, 5, 6, 3) \ +T (8, 7, 3, 0, 5, 4, 1, 6, 2, 31, 27, 24, 29, 28, 25, 30, 26) \ +T (9, 7, 1, 2, 0, 4, 5, 6, 3, 15, 9, 14, 10, 8, 12, 13, 11) \ +T (10, 15, 0, 3, 12, 14, 2, 1, 13, 4, 11, 9, 6, 5, 10, 7, 8) \ +T (11, 15, 9, 14, 10, 8, 12, 13, 11, 7, 1, 2, 0, 4, 5, 6, 3) \ +T (12, 2, 5, 24, 23, 17, 22, 20, 21, 12, 14, 13, 8, 6, 20, 10, 18) \ +T (13, 23, 11, 15, 9, 0, 14, 8, 12, 10, 13, 19, 11, 2, 26, 24, 30) \ +T (14, 25, 5, 17, 1, 9, 15, 21, 7, 28, 2, 18, 13, 30, 14, 10, 4) \ +T (15, 1, 30, 27, 31, 9, 18, 25, 12, 7, 4, 2, 16, 25, 20, 10, 3) \ +T (16, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30) \ +T (17, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31) \ +T (18, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3) \ +T (19, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) \ +T (20, 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23) \ +T (21, 8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29, 14, 30, 15, 31) \ +T (22, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0) \ +T (23, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 15) +#define EXPTESTS \ +T (116, 28, 13, 27, 11, 21, 1, 5, 22, 29, 14, 15, 6, 3, 10, 16, 30) \ +T (117, 22, 26, 1, 13, 29, 3, 18, 18, 11, 21, 12, 28, 19, 5, 7, 4) \ +T (118, 1, 28, 26, 11, 4, 27, 30, 12, 10, 19, 6, 7, 13, 31, 0, 24) \ +T (119, 7, 30, 17, 27, 0, 10, 13, 21, 3, 29, 24, 21, 12, 6, 15, 18) \ +T (120, 28, 13, 26, 24, 21, 16, 29, 9, 10, 2, 27, 19, 20, 17, 18, 14) \ +T (121, 22, 21, 1, 8, 14, 15, 0, 28, 25, 30, 10, 17, 19, 27, 26, 13) \ +T (122, 28, 13, 27, 2, 21, 29, 22, 4, 8, 0, 18, 1, 31, 7, 19, 14) \ +T (123, 15, 0, 9, 2, 31, 3, 17, 24, 1, 8, 26, 20, 30, 11, 22, 5) \ +T (124, 28, 14, 5, 7, 9, 10, 21, 31, 2, 11, 22, 27, 7, 27, 30, 2) \ +T (125, 17, 13, 1, 7, 20, 22, 8, 15, 4, 25, 10, 28, 23, 24, 9, 21) \ +T (126, 17, 5, 3, 4, 0, 7, 19, 13, 29, 25, 26, 1, 15, 8, 2, 7) \ +T (127, 16, 6, 3, 22, 31, 15, 13, 21, 14, 20, 29, 17, 18, 2, 23, 25) \ +T (128, 18, 22, 21, 28, 10, 13, 6, 17, 29, 20, 7, 16, 2, 9, 1, 11) \ +T (129, 30, 11, 11, 22, 21, 10, 3, 18, 15, 26, 20, 16, 17, 13, 29, 7) \ +T (130, 5, 9, 21, 16, 29, 11, 4, 2, 17, 28, 3, 19, 9, 10, 13, 20) \ +T (131, 13, 3, 19, 25, 1, 28, 31, 30, 10, 12, 21, 26, 27, 14, 5, 17) \ +T (132, 8, 28, 26, 31, 5, 14, 4, 13, 6, 15, 3, 17, 6, 20, 27, 29) \ +T (133, 7, 26, 8, 17, 31, 11, 25, 16, 19, 4, 0, 27, 7, 20, 19, 13) \ +T (134, 14, 23, 19, 4, 9, 11, 16, 6, 7, 3, 27, 20, 24, 18, 26, 31) \ +T (135, 7, 25, 14, 2, 16, 5, 29, 3, 4, 24, 21, 9, 20, 19, 27, 1) \ +T (136, 5, 14, 29, 12, 3, 3, 1, 4, 8, 7, 9, 13, 10, 4, 12, 23) \ +T (137, 2, 6, 21, 28, 5, 23, 16, 24, 22, 18, 30, 12, 31, 16, 4, 1) \ +T (138, 4, 31, 11, 26, 16, 23, 5, 12, 15, 14, 19, 3, 18, 21, 27, 6) \ +T (139, 29, 14, 19, 18, 23, 27, 16, 7, 8, 26, 0, 12, 15, 17, 9, 1) \ +T (140, 18, 27, 20, 31, 8, 10, 9, 17, 13, 19, 12, 15, 28, 3, 25, 5) \ +T (141, 28, 13, 23, 20, 10, 5, 22, 17, 27, 0, 21, 27, 11, 25, 24, 30) \ +T (142, 24, 17, 31, 22, 9, 15, 28, 6, 12, 23, 30, 1, 21, 5, 27, 29) \ +T (143, 12, 19, 16, 0, 8, 15, 13, 22, 17, 4, 31, 20, 2, 9, 21, 30) \ +T (144, 5, 13, 26, 12, 27, 0, 17, 1, 25, 8, 10, 25, 18, 11, 29, 4) \ +T (145, 6, 18, 13, 29, 14, 31, 16, 10, 2, 12, 20, 25, 23, 28, 24, 10) \ +T (146, 17, 0, 21, 0, 12, 13, 16, 5, 19, 29, 30, 27, 4, 9, 1, 20) \ +T (147, 14, 26, 28, 17, 31, 10, 6, 3, 29, 22, 18, 1, 6, 5, 30, 8) \ +T (148, 10, 17, 12, 18, 26, 16, 5, 24, 2, 7, 20, 15, 30, 2, 29, 25) \ +T (149, 30, 27, 15, 23, 8, 12, 29, 2, 4, 9, 25, 13, 21, 7, 16, 20) \ +T (150, 7, 13, 4, 22, 24, 0, 31, 28, 18, 5, 2, 16, 17, 1, 1, 6) \ +T (151, 24, 27, 17, 25, 27, 6, 14, 30, 21, 19, 23, 29, 12, 19, 15, 9) \ +T (152, 1, 16, 24, 19, 29, 27, 17, 9, 8, 23, 22, 12, 11, 2, 26, 25) \ +T (153, 2, 25, 22, 8, 11, 16, 20, 26, 29, 15, 6, 15, 30, 10, 21, 24) \ +T (154, 19, 20, 23, 11, 20, 1, 18, 29, 21, 24, 6, 8, 19, 2, 4, 9) \ +T (155, 30, 12, 29, 21, 7, 8, 31, 15, 3, 1, 10, 4, 2, 9, 19, 2) \ +T (156, 14, 27, 5, 23, 15, 22, 4, 26, 30, 19, 29, 18, 16, 24, 21, 7) \ +T (157, 14, 15, 26, 17, 30, 16, 6, 0, 10, 8, 2, 23, 20, 13, 3, 27) \ +T (158, 2, 14, 13, 22, 24, 26, 17, 16, 4, 27, 7, 31, 9, 1, 28, 3) \ +T (159, 13, 15, 19, 12, 31, 23, 16, 8, 0, 2, 17, 27, 30, 14, 18, 1) \ +T (160, 3, 9, 30, 28, 31, 24, 5, 1, 23, 0, 13, 24, 20, 18, 3, 26) \ +T (161, 6, 10, 28, 8, 15, 14, 17, 26, 9, 0, 11, 2, 16, 2, 27, 24) \ +T (162, 20, 29, 7, 11, 5, 21, 0, 8, 12, 28, 13, 4, 26, 10, 28, 23) \ +T (163, 31, 25, 24, 10, 18, 3, 5, 12, 18, 2, 17, 22, 30, 16, 8, 6) \ +T (164, 0, 5, 22, 3, 21, 28, 31, 20, 12, 14, 18, 4, 13, 2, 0, 29) \ +T (165, 26, 18, 25, 20, 2, 0, 10, 30, 27, 11, 9, 3, 31, 4, 29, 21) \ +T (166, 15, 21, 3, 9, 22, 6, 29, 13, 24, 30, 31, 5, 26, 17, 0, 12) \ +T (167, 3, 28, 19, 27, 26, 14, 5, 10, 16, 24, 12, 30, 23, 13, 18, 26) \ +T (168, 0, 13, 10, 16, 23, 17, 8, 24, 20, 25, 21, 3, 12, 22, 6, 1) \ +T (169, 11, 18, 7, 26, 23, 6, 24, 21, 29, 18, 7, 19, 12, 31, 15, 28) \ +T (170, 14, 5, 21, 6, 9, 11, 12, 4, 0, 8, 30, 10, 24, 19, 18, 3) \ +T (171, 6, 3, 5, 13, 10, 2, 24, 31, 23, 2, 29, 4, 22, 7, 19, 20) \ +T (172, 12, 26, 13, 18, 19, 9, 1, 27, 14, 7, 20, 31, 11, 8, 30, 4) \ +T (173, 1, 23, 10, 31, 12, 26, 6, 13, 7, 30, 18, 4, 0, 27, 21, 19) \ +T (174, 20, 15, 13, 22, 10, 14, 5, 3, 31, 8, 0, 11, 4, 9, 1, 0) \ +T (175, 12, 29, 23, 28, 8, 20, 19, 7, 20, 24, 6, 26, 11, 17, 2, 5) \ +T (176, 19, 0, 31, 26, 30, 16, 17, 14, 5, 7, 3, 27, 1, 22, 29, 9) \ +T (177, 17, 15, 4, 1, 7, 13, 23, 28, 2, 8, 26, 12, 21, 24, 3, 19) \ +T (178, 17, 23, 21, 2, 12, 27, 8, 15, 6, 25, 7, 28, 4, 26, 1, 23) \ +T (179, 17, 25, 19, 4, 7, 20, 13, 30, 18, 3, 25, 21, 24, 26, 16, 31) \ +T (180, 7, 20, 18, 9, 3, 16, 12, 22, 0, 30, 10, 25, 17, 29, 19, 5) \ +T (181, 4, 17, 23, 1, 16, 22, 12, 31, 25, 9, 8, 21, 26, 15, 29, 29) \ +T (182, 31, 25, 14, 17, 8, 24, 4, 29, 27, 0, 20, 5, 13, 12, 5, 30) \ +T (183, 29, 26, 3, 22, 24, 30, 0, 15, 19, 7, 18, 6, 25, 14, 3, 3) \ +T (184, 23, 22, 7, 18, 10, 30, 29, 6, 16, 13, 11, 28, 5, 26, 4, 24) \ +T (185, 27, 15, 8, 29, 21, 23, 12, 11, 26, 22, 21, 6, 10, 23, 20, 27) \ +T (186, 19, 23, 20, 7, 8, 14, 6, 17, 20, 1, 5, 12, 25, 18, 10, 29) \ +T (187, 12, 14, 2, 5, 31, 21, 30, 18, 2, 6, 17, 22, 22, 28, 0, 18) \ +T (188, 10, 8, 13, 29, 20, 18, 8, 5, 4, 3, 26, 19, 24, 29, 6, 30) \ +T (189, 23, 19, 8, 2, 21, 18, 26, 1, 27, 12, 10, 4, 3, 20, 10, 17) \ +T (190, 31, 30, 21, 8, 15, 9, 3, 22, 7, 17, 25, 5, 13, 6, 1, 11) \ +T (191, 0, 5, 26, 6, 18, 1, 9, 31, 11, 3, 10, 23, 30, 27, 17, 14) \ +T (192, 19, 7, 29, 27, 8, 17, 22, 20, 10, 22, 2, 11, 9, 14, 31, 23) \ +T (193, 3, 23, 10, 18, 14, 9, 4, 24, 8, 30, 9, 13, 16, 17, 4, 22) \ +T (194, 13, 22, 8, 3, 9, 24, 9, 7, 15, 17, 26, 19, 11, 5, 18, 24) \ +T (195, 1, 18, 17, 13, 14, 0, 6, 15, 31, 22, 9, 2, 23, 19, 20, 3) \ +T (196, 9, 8, 17, 4, 28, 20, 6, 1, 11, 12, 23, 0, 15, 27, 31, 18) \ +T (197, 11, 2, 16, 1, 29, 21, 14, 9, 23, 30, 22, 8, 27, 9, 18, 10) \ +T (198, 10, 6, 26, 22, 13, 28, 18, 31, 4, 17, 27, 5, 7, 25, 20, 21) \ +T (199, 9, 8, 0, 0, 10, 7, 4, 24, 16, 3, 20, 1, 31, 11, 17, 26) \ +T (200, 19, 24, 31, 25, 7, 4, 14, 4, 9, 21, 29, 30, 10, 16, 6, 13) \ +T (201, 27, 4, 25, 12, 11, 3, 29, 1, 16, 6, 12, 5, 26, 25, 10, 15) \ +T (202, 11, 28, 9, 3, 20, 30, 18, 6, 13, 12, 25, 24, 5, 26, 0, 31) \ +T (203, 7, 23, 14, 16, 1, 31, 3, 0, 18, 6, 4, 10, 11, 15, 13, 29) \ +T (204, 28, 15, 6, 4, 21, 18, 22, 29, 13, 3, 18, 27, 21, 7, 31, 26) \ +T (205, 2, 13, 7, 22, 21, 9, 24, 15, 6, 20, 14, 29, 16, 27, 31, 0) \ +T (206, 23, 3, 13, 0, 18, 19, 10, 29, 16, 22, 21, 30, 17, 5, 6, 31) \ +T (207, 0, 3, 6, 29, 7, 10, 20, 17, 5, 8, 27, 18, 12, 4, 30, 28) \ +T (208, 5, 31, 20, 6, 14, 11, 28, 19, 7, 25, 27, 26, 10, 8, 22, 4) \ +T (209, 26, 22, 12, 9, 25, 0, 21, 14, 4, 7, 17, 30, 29, 24, 13, 31) \ +T (210, 15, 1, 6, 10, 26, 12, 8, 25, 3, 31, 23, 5, 30, 2, 0, 27) \ +T (211, 2, 11, 1, 27, 4, 17, 28, 22, 5, 28, 16, 20, 6, 3, 0, 15) \ +T (212, 25, 2, 6, 18, 16, 12, 4, 27, 1, 29, 7, 3, 21, 20, 17, 19) \ +T (213, 16, 0, 19, 21, 29, 23, 18, 31, 24, 12, 4, 20, 2, 8, 27, 30) \ +T (214, 20, 28, 9, 28, 22, 13, 2, 0, 8, 26, 10, 23, 24, 12, 31, 11) \ +T (215, 27, 22, 12, 15, 10, 20, 4, 25, 29, 9, 17, 3, 28, 21, 31, 23) \ +T (216, 16, 29, 20, 19, 16, 6, 18, 28, 3, 15, 29, 30, 1, 22, 10, 0) \ +T (217, 24, 14, 27, 3, 16, 30, 6, 0, 13, 12, 19, 7, 11, 20, 5, 26) \ +T (218, 19, 30, 26, 17, 13, 5, 10, 15, 16, 28, 24, 20, 0, 25, 9, 14) \ +T (219, 11, 0, 29, 5, 16, 30, 22, 19, 25, 4, 17, 7, 18, 2, 14, 13) \ +T (220, 27, 9, 16, 10, 19, 23, 12, 21, 3, 30, 18, 4, 15, 6, 29, 13) \ +T (221, 26, 12, 25, 22, 11, 18, 1, 7, 0, 19, 29, 31, 8, 4, 9, 15) \ +T (222, 18, 23, 31, 7, 26, 5, 15, 11, 25, 4, 22, 21, 14, 10, 20, 8) \ +T (223, 2, 18, 4, 24, 6, 20, 9, 25, 16, 3, 5, 22, 10, 7, 23, 30) \ +T (224, 4, 13, 6, 8, 22, 2, 12, 24, 31, 29, 20, 23, 0, 10, 1, 3) \ +T (225, 26, 3, 30, 18, 4, 19, 22, 31, 28, 24, 15, 14, 1, 23, 27, 7) \ +T (226, 18, 6, 23, 16, 25, 26, 17, 5, 28, 10, 30, 24, 12, 14, 15, 20) \ +T (227, 5, 19, 23, 22, 1, 7, 26, 12, 30, 17, 0, 0, 10, 6, 18, 4) diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-2.inc b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-2.inc new file mode 100644 index 000000000..70b2e5c13 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-2.inc @@ -0,0 +1,19 @@ +#define N 2 +#define TESTS \ +T (0, 0, 0) \ +T (1, 0, 1) \ +T (2, 0, 2) \ +T (3, 0, 3) \ +T (4, 1, 0) \ +T (5, 1, 1) \ +T (6, 1, 2) \ +T (7, 1, 3) \ +T (8, 2, 0) \ +T (9, 2, 1) \ +T (10, 2, 2) \ +T (11, 2, 3) \ +T (12, 3, 0) \ +T (13, 3, 1) \ +T (14, 3, 2) \ +T (15, 3, 3) +#define EXPTESTS diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-32.inc b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-32.inc new file mode 100644 index 000000000..c7fced062 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-32.inc @@ -0,0 +1,139 @@ +#define N 32 +#define TESTS \ +T (0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31) \ +T (1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) \ +T (2, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15) \ +T (3, 26, 60, 14, 40, 44, 51, 12, 45, 9, 37, 4, 47, 35, 63, 54, 30, 28, 10, 48, 32, 5, 59, 7, 52, 11, 6, 62, 49, 25, 25, 20, 55) \ +T (4, 32, 16, 54, 20, 62, 60, 56, 9, 38, 26, 42, 12, 17, 51, 4, 58, 59, 25, 50, 27, 41, 37, 8, 30, 18, 24, 40, 36, 25, 7, 37, 63) \ +T (5, 0, 4, 60, 9, 23, 19, 45, 6, 5, 12, 38, 60, 34, 36, 26, 11, 47, 52, 63, 39, 7, 56, 17, 54, 53, 39, 18, 2, 37, 55, 22, 21) \ +T (6, 2, 44, 46, 13, 40, 38, 52, 10, 50, 55, 11, 15, 9, 0, 12, 42, 45, 19, 11, 34, 26, 24, 62, 25, 5, 17, 1, 47, 21, 7, 60, 41) \ +T (7, 50, 13, 37, 62, 9, 49, 14, 53, 15, 42, 36, 1, 33, 27, 63, 41, 57, 12, 7, 2, 44, 48, 16, 39, 25, 31, 20, 10, 3, 60, 43, 21) \ +T (8, 1, 37, 22, 61, 5, 14, 46, 47, 6, 35, 10, 48, 30, 26, 33, 13, 18, 18, 11, 21, 44, 29, 60, 45, 19, 37, 7, 43, 36, 1, 28, 59) \ +T (9, 30, 44, 42, 51, 6, 7, 38, 13, 43, 31, 58, 0, 56, 17, 27, 32, 10, 53, 3, 29, 21, 12, 15, 50, 28, 24, 16, 61, 9, 34, 59, 19) \ +T (10, 20, 49, 50, 14, 54, 53, 33, 40, 46, 15, 0, 28, 25, 30, 10, 17, 51, 59, 26, 13, 45, 27, 2, 61, 4, 36, 8, 0, 18, 33, 22, 63) \ +T (11, 13, 40, 7, 33, 51, 21, 59, 46, 47, 32, 9, 34, 63, 35, 41, 17, 24, 1, 8, 26, 52, 62, 11, 22, 37, 28, 5, 39, 10, 53, 60, 2) \ +T (12, 39, 43, 54, 27, 53, 39, 27, 30, 2, 17, 13, 33, 7, 52, 40, 15, 36, 57, 10, 28, 22, 23, 25, 24, 41, 47, 8, 20, 5, 3, 4, 0) \ +T (13, 7, 51, 13, 61, 25, 4, 19, 58, 35, 33, 29, 15, 40, 2, 39, 16, 38, 3, 54, 63, 15, 6, 48, 21, 14, 52, 17, 50, 34, 55, 57, 50) \ +T (14, 22, 53, 28, 42, 45, 38, 49, 13, 54, 61, 21, 52, 7, 16, 34, 9, 1, 43, 62, 43, 35, 50, 47, 58, 20, 3, 30, 15, 37, 53, 43, 36) \ +T (15, 2, 43, 49, 34, 28, 35, 29, 36, 51, 9, 17, 48, 10, 37, 45, 21, 52, 19, 25, 33, 60, 31, 30, 42, 12, 26, 27, 46, 5, 40, 14, 36) \ +T (16, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62) \ +T (17, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63) \ +T (18, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3) \ +T (19, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) \ +T (20, 0, 32, 1, 33, 2, 34, 3, 35, 4, 36, 5, 37, 6, 38, 7, 39, 8, 40, 9, 41, 10, 42, 11, 43, 12, 44, 13, 45, 14, 46, 15, 47) \ +T (21, 16, 48, 17, 49, 18, 50, 19, 51, 20, 52, 21, 53, 22, 54, 23, 55, 24, 56, 25, 57, 26, 58, 27, 59, 28, 60, 29, 61, 30, 62, 31, 63) \ +T (22, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 0) \ +T (23, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31) +#define EXPTESTS \ +T (116, 13, 38, 47, 3, 17, 8, 38, 20, 59, 61, 39, 26, 7, 49, 63, 43, 57, 16, 40, 19, 4, 32, 27, 7, 52, 19, 46, 55, 36, 41, 48, 6) \ +T (117, 39, 35, 59, 20, 56, 18, 58, 63, 57, 14, 2, 16, 5, 61, 35, 4, 53, 9, 52, 51, 27, 33, 61, 12, 3, 35, 36, 40, 37, 7, 45, 42) \ +T (118, 4, 5, 8, 14, 35, 12, 55, 34, 6, 53, 60, 5, 48, 56, 22, 18, 62, 44, 38, 31, 28, 16, 33, 36, 43, 26, 16, 23, 37, 47, 51, 3) \ +T (119, 26, 50, 53, 27, 6, 29, 14, 19, 23, 48, 39, 8, 58, 0, 12, 15, 17, 41, 33, 18, 52, 31, 10, 9, 49, 13, 51, 45, 47, 60, 35, 57) \ +T (120, 37, 60, 13, 55, 52, 42, 5, 22, 17, 59, 0, 21, 59, 11, 25, 56, 62, 56, 31, 54, 9, 47, 28, 6, 44, 33, 61, 12, 19, 16, 8, 40) \ +T (121, 47, 45, 44, 40, 22, 17, 4, 31, 8, 52, 34, 32, 41, 21, 62, 37, 5, 13, 58, 27, 0, 17, 33, 57, 42, 57, 18, 43, 61, 36, 38, 14) \ +T (122, 31, 16, 42, 6, 34, 2, 12, 20, 57, 29, 23, 60, 24, 10, 17, 0, 21, 32, 45, 5, 19, 30, 59, 4, 9, 1, 46, 14, 26, 63, 3, 22) \ +T (123, 46, 61, 50, 1, 38, 37, 62, 40, 10, 49, 44, 26, 16, 24, 5, 2, 39, 20, 15, 30, 34, 29, 57, 27, 47, 55, 8, 44, 36, 4, 9, 25) \ +T (124, 45, 53, 7, 48, 23, 21, 20, 7, 13, 4, 22, 24, 39, 0, 63, 60, 18, 37, 34, 36, 54, 49, 1, 1, 38, 27, 17, 57, 27, 14, 59, 62) \ +T (125, 30, 57, 46, 21, 51, 23, 25, 62, 29, 12, 51, 15, 41, 33, 16, 56, 19, 61, 27, 49, 41, 40, 55, 54, 44, 43, 2, 26, 34, 22, 11, 20) \ +T (126, 26, 29, 15, 57, 6, 15, 30, 10, 53, 24, 19, 52, 23, 43, 20, 1, 18, 29, 56, 51, 38, 8, 51, 2, 4, 41, 62, 12, 7, 63, 3, 33) \ +T (127, 42, 10, 36, 2, 41, 34, 19, 2, 46, 27, 5, 55, 15, 22, 36, 26, 30, 58, 51, 61, 18, 48, 24, 21, 56, 7, 14, 47, 17, 6, 0, 8) \ +T (128, 34, 23, 16, 20, 15, 13, 3, 30, 59, 46, 54, 24, 26, 45, 17, 48, 4, 27, 7, 31, 2, 41, 1, 28, 51, 12, 63, 8, 32, 19, 18, 33) \ +T (129, 3, 41, 62, 28, 30, 63, 24, 5, 33, 60, 55, 32, 37, 45, 56, 52, 50, 35, 26, 38, 10, 40, 15, 14, 17, 58, 46, 41, 11, 34, 48, 2) \ +T (130, 59, 60, 24, 20, 61, 39, 43, 37, 53, 32, 8, 44, 28, 13, 36, 58, 0, 42, 60, 55, 31, 57, 56, 10, 18, 3, 5, 12, 18, 34, 49, 54) \ +T (131, 3, 62, 16, 40, 38, 32, 5, 54, 53, 28, 63, 20, 12, 14, 50, 4, 13, 34, 32, 29, 26, 18, 25, 52, 2, 42, 30, 59, 43, 41, 27, 10) \ +T (132, 35, 31, 57, 52, 4, 0, 61, 21, 15, 3, 9, 54, 38, 13, 24, 30, 37, 58, 41, 6, 49, 32, 12, 28, 19, 59, 14, 42, 16, 48, 56, 23) \ +T (133, 62, 12, 13, 50, 26, 32, 45, 10, 48, 55, 49, 8, 24, 42, 52, 57, 53, 3, 54, 38, 33, 43, 7, 26, 23, 6, 21, 61, 18, 7, 51, 44) \ +T (134, 31, 15, 38, 39, 60, 14, 5, 21, 53, 6, 9, 43, 12, 36, 32, 40, 30, 10, 56, 51, 50, 35, 38, 3, 37, 13, 2, 24, 63, 34, 55, 34) \ +T (135, 29, 36, 22, 7, 63, 23, 19, 20, 12, 58, 13, 50, 41, 1, 59, 33, 46, 39, 52, 11, 8, 51, 62, 42, 31, 10, 58, 38, 45, 4, 32, 53) \ +T (136, 19, 20, 47, 13, 22, 10, 14, 37, 35, 31, 8, 15, 32, 54, 43, 40, 4, 9, 1, 32, 12, 29, 23, 60, 52, 51, 39, 52, 56, 6, 26, 11) \ +T (137, 39, 11, 49, 34, 37, 51, 32, 63, 26, 62, 16, 49, 14, 5, 7, 3, 59, 33, 54, 58, 61, 9, 47, 36, 13, 23, 28, 2, 40, 4, 44, 1) \ +T (138, 53, 24, 33, 35, 19, 49, 55, 34, 44, 27, 40, 47, 38, 17, 25, 39, 60, 4, 26, 15, 7, 36, 55, 51, 39, 20, 45, 62, 57, 50, 57, 21) \ +T (139, 24, 58, 16, 63, 7, 20, 18, 9, 35, 48, 12, 54, 0, 62, 41, 42, 25, 50, 17, 61, 51, 37, 4, 55, 33, 22, 12, 40, 53, 26, 47, 29) \ +T (140, 55, 53, 40, 61, 63, 57, 46, 17, 8, 56, 4, 29, 27, 32, 24, 52, 5, 13, 12, 5, 44, 30, 26, 3, 22, 0, 47, 19, 39, 50, 38, 15) \ +T (141, 15, 46, 3, 18, 3, 55, 22, 39, 10, 62, 61, 38, 48, 16, 6, 45, 11, 60, 5, 26, 4, 50, 24, 59, 47, 8, 29, 53, 12, 21, 43, 58) \ +T (142, 22, 8, 21, 6, 55, 10, 55, 20, 59, 19, 55, 23, 52, 39, 46, 49, 20, 1, 40, 5, 12, 14, 57, 50, 29, 2, 37, 31, 62, 18, 34, 54) \ +T (143, 54, 28, 50, 0, 62, 18, 10, 8, 13, 29, 52, 8, 5, 36, 35, 4, 58, 19, 56, 29, 38, 30, 55, 51, 40, 34, 53, 26, 33, 59, 12, 27) \ +T (144, 42, 4, 35, 20, 52, 3, 10, 21, 17, 63, 62, 40, 15, 41, 54, 39, 8, 57, 5, 45, 37, 38, 1, 43, 32, 58, 6, 50, 33, 3, 55, 9) \ +T (145, 27, 62, 49, 14, 19, 39, 61, 40, 22, 20, 10, 22, 34, 43, 9, 46, 31, 42, 54, 23, 35, 50, 4, 3, 41, 24, 8, 30, 9, 45, 48, 17) \ +T (146, 4, 40, 22, 45, 8, 35, 9, 24, 9, 41, 7, 47, 49, 58, 51, 43, 54, 37, 18, 39, 56, 1, 46, 0, 33, 38, 15, 13, 17, 31, 54, 2) \ +T (147, 55, 19, 20, 3, 41, 8, 49, 36, 28, 38, 1, 11, 44, 55, 32, 15, 59, 0, 63, 50, 2, 16, 61, 21, 14, 23, 30, 22, 33, 46, 48, 62) \ +T (148, 30, 40, 59, 11, 9, 8, 50, 42, 10, 6, 58, 22, 45, 60, 63, 4, 49, 31, 5, 7, 25, 18, 52, 13, 53, 0, 0, 39, 24, 48, 3, 20) \ +T (149, 41, 1, 63, 11, 49, 24, 26, 51, 31, 57, 7, 36, 46, 4, 53, 19, 29, 21, 30, 14, 10, 48, 38, 13, 59, 25, 44, 43, 35, 61, 33, 16) \ +T (150, 38, 44, 5, 26, 25, 42, 16, 15, 43, 28, 41, 3, 52, 62, 50, 11, 6, 35, 13, 12, 57, 24, 32, 31, 39, 55, 46, 33, 0, 18, 4, 47) \ +T (151, 45, 29, 60, 15, 6, 36, 53, 18, 54, 47, 61, 13, 3, 50, 21, 27, 28, 21, 7, 63, 26, 34, 9, 24, 52, 46, 38, 56, 48, 59, 31, 2) \ +T (152, 32, 23, 3, 13, 35, 55, 18, 19, 42, 29, 48, 54, 53, 30, 17, 62, 37, 38, 31, 32, 6, 61, 7, 10, 52, 8, 27, 12, 59, 50, 36, 28) \ +T (153, 37, 63, 52, 6, 46, 43, 28, 51, 7, 25, 59, 26, 42, 40, 22, 5, 4, 58, 54, 44, 41, 32, 53, 14, 39, 17, 30, 61, 24, 45, 31, 47) \ +T (154, 33, 38, 42, 58, 12, 10, 8, 25, 3, 63, 55, 37, 31, 30, 2, 0, 59, 34, 43, 11, 36, 27, 49, 28, 22, 60, 48, 20, 1, 6, 35, 47) \ +T (155, 57, 2, 6, 50, 16, 12, 36, 59, 1, 61, 39, 35, 21, 20, 17, 51, 48, 32, 19, 53, 29, 23, 18, 31, 24, 4, 52, 8, 27, 62, 60, 9) \ +T (156, 60, 54, 13, 2, 32, 8, 58, 42, 23, 24, 12, 63, 43, 59, 22, 44, 15, 20, 4, 57, 61, 27, 47, 9, 49, 35, 28, 21, 48, 52, 19, 48) \ +T (157, 61, 38, 50, 28, 35, 15, 29, 51, 30, 20, 1, 54, 10, 0, 24, 46, 59, 3, 16, 32, 45, 12, 7, 11, 48, 37, 26, 19, 62, 49, 13, 5) \ +T (158, 10, 15, 16, 60, 24, 52, 19, 0, 25, 41, 46, 11, 29, 5, 62, 22, 43, 36, 17, 7, 18, 34, 49, 45, 59, 9, 42, 51, 55, 44, 21, 3) \ +T (159, 30, 18, 51, 36, 21, 15, 6, 61, 13, 58, 44, 25, 57, 22, 11, 54, 33, 39, 43, 0, 26, 19, 29, 63, 8, 4, 41, 23, 31, 58, 5, 47) \ +T (160, 43, 57, 36, 22, 21, 46, 53, 50, 63, 10, 20, 52, 8, 34, 18, 4, 56, 38, 41, 48, 35, 5, 39, 23, 54, 30, 4, 13, 40, 45, 2, 12) \ +T (161, 24, 31, 61, 52, 55, 36, 32, 10, 33, 3, 58, 35, 62, 50, 51, 54, 63, 30, 28, 4, 26, 47, 14, 56, 23, 59, 39, 38, 16, 25, 17, 37) \ +T (162, 60, 17, 42, 30, 56, 12, 14, 47, 6, 20, 5, 19, 55, 54, 33, 39, 58, 30, 22, 32, 0, 7, 18, 4, 63, 48, 36, 10, 3, 21, 28, 35) \ +T (163, 11, 12, 21, 42, 0, 50, 48, 35, 20, 48, 38, 46, 52, 36, 43, 31, 28, 52, 48, 27, 1, 13, 60, 58, 39, 16, 32, 37, 57, 53, 24, 41) \ +T (164, 10, 17, 45, 30, 36, 24, 55, 59, 5, 50, 15, 56, 13, 38, 25, 29, 53, 20, 6, 1, 26, 51, 36, 32, 23, 35, 62, 3, 34, 10, 12, 52) \ +T (165, 15, 0, 34, 40, 12, 13, 28, 39, 39, 20, 48, 14, 22, 27, 51, 34, 11, 18, 16, 38, 62, 58, 6, 41, 44, 42, 36, 7, 33, 37, 37, 5) \ +T (166, 35, 44, 35, 56, 39, 57, 11, 35, 1, 0, 61, 31, 52, 32, 33, 24, 37, 49, 18, 29, 24, 12, 5, 43, 55, 25, 60, 40, 4, 30, 38, 3) \ +T (167, 25, 2, 53, 19, 62, 59, 49, 43, 15, 12, 15, 28, 22, 35, 40, 31, 47, 11, 16, 10, 41, 5, 7, 23, 48, 24, 60, 52, 30, 50, 55, 7) \ +T (168, 49, 27, 41, 40, 42, 20, 39, 50, 17, 58, 9, 54, 2, 38, 48, 16, 62, 43, 18, 59, 22, 63, 29, 61, 60, 6, 33, 24, 14, 57, 4, 28) \ +T (169, 13, 41, 9, 55, 51, 0, 46, 18, 42, 53, 37, 5, 7, 39, 15, 36, 30, 50, 11, 20, 52, 47, 1, 44, 63, 43, 6, 60, 2, 34, 31, 54) \ +T (170, 49, 35, 62, 17, 55, 14, 30, 11, 8, 29, 2, 54, 31, 44, 36, 46, 37, 21, 15, 28, 27, 23, 57, 53, 51, 37, 34, 19, 47, 16, 43, 59) \ +T (171, 50, 37, 40, 26, 46, 58, 54, 59, 17, 30, 23, 11, 43, 61, 31, 8, 60, 34, 25, 63, 4, 41, 39, 48, 51, 13, 49, 22, 52, 57, 29, 13) \ +T (172, 42, 47, 27, 36, 47, 41, 45, 24, 8, 20, 35, 22, 38, 50, 57, 52, 28, 46, 53, 54, 37, 2, 48, 33, 32, 5, 60, 17, 19, 34, 55, 43) \ +T (173, 19, 12, 42, 37, 36, 13, 0, 1, 62, 53, 54, 50, 44, 0, 24, 59, 2, 6, 10, 29, 3, 63, 34, 28, 13, 61, 46, 33, 7, 26, 27, 5) \ +T (174, 32, 5, 30, 54, 15, 26, 25, 28, 1, 51, 11, 39, 2, 30, 27, 13, 43, 6, 7, 25, 31, 8, 3, 16, 41, 29, 26, 5, 19, 58, 42, 59) \ +T (175, 48, 5, 7, 28, 40, 56, 49, 42, 47, 61, 24, 13, 44, 18, 38, 53, 30, 10, 21, 6, 29, 2, 33, 22, 14, 59, 42, 21, 45, 31, 27, 54) \ +T (176, 56, 39, 62, 32, 46, 48, 36, 27, 3, 53, 22, 42, 31, 9, 40, 0, 19, 58, 16, 26, 1, 10, 16, 21, 63, 54, 23, 2, 15, 6, 7, 47) \ +T (177, 31, 18, 57, 52, 5, 32, 56, 7, 11, 6, 9, 20, 30, 56, 46, 23, 42, 38, 3, 34, 19, 45, 21, 55, 0, 8, 53, 24, 29, 60, 25, 49) \ +T (178, 32, 2, 48, 34, 7, 57, 1, 58, 39, 16, 53, 33, 31, 12, 21, 6, 4, 62, 50, 46, 61, 23, 5, 40, 44, 9, 28, 11, 11, 37, 25, 13) \ +T (179, 47, 40, 12, 47, 26, 3, 33, 30, 46, 61, 33, 10, 19, 1, 20, 5, 37, 9, 28, 27, 25, 63, 15, 23, 43, 54, 11, 30, 6, 24, 57, 18) \ +T (180, 16, 27, 2, 62, 63, 52, 26, 21, 37, 18, 41, 45, 15, 9, 51, 46, 28, 38, 60, 30, 35, 20, 7, 52, 53, 24, 42, 56, 33, 22, 48, 31) \ +T (181, 0, 40, 54, 27, 2, 3, 21, 10, 32, 31, 55, 31, 34, 53, 36, 22, 59, 41, 1, 20, 13, 42, 46, 17, 52, 49, 28, 41, 37, 40, 4, 43) \ +T (182, 35, 7, 38, 12, 27, 41, 8, 17, 1, 23, 46, 3, 28, 24, 61, 60, 21, 19, 48, 33, 26, 29, 45, 51, 48, 56, 34, 22, 10, 62, 25, 39) \ +T (183, 61, 14, 56, 62, 44, 59, 54, 26, 61, 27, 52, 24, 3, 33, 12, 16, 48, 47, 28, 9, 21, 38, 23, 0, 55, 5, 22, 39, 9, 35, 59, 63) \ +T (184, 41, 27, 35, 53, 49, 26, 12, 14, 3, 39, 19, 2, 16, 46, 47, 52, 24, 59, 6, 51, 52, 34, 4, 50, 32, 13, 63, 20, 45, 10, 28, 40) \ +T (185, 14, 7, 4, 53, 23, 11, 9, 41, 26, 20, 46, 51, 3, 8, 18, 56, 31, 48, 38, 15, 12, 46, 42, 59, 40, 57, 16, 2, 21, 33, 37, 11) \ +T (186, 46, 10, 6, 33, 7, 2, 37, 4, 11, 32, 59, 60, 2, 4, 12, 47, 26, 39, 27, 52, 5, 58, 30, 24, 36, 55, 63, 28, 62, 25, 43, 25) \ +T (187, 6, 60, 15, 13, 18, 56, 39, 43, 61, 20, 63, 26, 37, 53, 23, 33, 44, 10, 14, 58, 35, 2, 17, 37, 41, 12, 1, 22, 10, 16, 5, 55) \ +T (188, 31, 62, 49, 57, 22, 42, 61, 6, 34, 35, 3, 13, 16, 56, 2, 28, 38, 49, 22, 49, 0, 29, 17, 57, 59, 27, 5, 22, 26, 24, 40, 30) \ +T (189, 3, 24, 42, 30, 19, 13, 9, 57, 6, 46, 36, 52, 16, 55, 60, 4, 2, 50, 32, 33, 58, 15, 22, 33, 21, 39, 20, 37, 27, 0, 1, 53) \ +T (190, 19, 62, 32, 12, 18, 61, 31, 60, 14, 6, 15, 17, 22, 39, 30, 56, 49, 48, 16, 63, 42, 43, 1, 11, 20, 59, 27, 25, 63, 29, 37, 2) \ +T (191, 0, 15, 16, 7, 56, 54, 8, 63, 39, 18, 32, 46, 12, 35, 17, 38, 41, 34, 36, 40, 51, 21, 61, 26, 43, 57, 53, 4, 45, 6, 57, 2) \ +T (192, 52, 12, 62, 8, 60, 56, 29, 5, 6, 7, 9, 21, 44, 47, 48, 53, 58, 54, 45, 40, 15, 17, 1, 28, 4, 55, 22, 57, 32, 19, 33, 10) \ +T (193, 14, 48, 58, 51, 60, 30, 42, 4, 3, 17, 44, 36, 34, 9, 8, 16, 46, 43, 32, 24, 47, 21, 2, 49, 59, 55, 10, 62, 11, 25, 29, 57) \ +T (194, 35, 0, 38, 57, 14, 16, 12, 7, 10, 40, 20, 44, 42, 40, 22, 47, 31, 5, 54, 8, 13, 26, 62, 28, 32, 37, 48, 34, 41, 39, 60, 4) \ +T (195, 30, 15, 1, 38, 55, 58, 7, 14, 13, 12, 11, 35, 17, 22, 39, 32, 50, 13, 5, 62, 51, 63, 46, 10, 8, 61, 9, 49, 59, 4, 0, 34) \ +T (196, 37, 31, 6, 15, 23, 0, 30, 35, 4, 54, 56, 63, 3, 20, 44, 27, 43, 25, 4, 41, 5, 1, 38, 51, 59, 26, 42, 48, 58, 50, 5, 2) \ +T (197, 3, 21, 28, 5, 22, 62, 16, 17, 56, 45, 46, 33, 41, 24, 25, 31, 10, 54, 19, 14, 0, 59, 42, 34, 12, 23, 53, 35, 55, 30, 18, 8) \ +T (198, 3, 56, 16, 31, 45, 6, 37, 26, 34, 41, 36, 52, 21, 48, 13, 27, 22, 51, 62, 60, 59, 0, 25, 62, 44, 9, 23, 42, 11, 33, 39, 57) \ +T (199, 59, 20, 31, 41, 24, 27, 26, 54, 7, 42, 30, 5, 25, 37, 53, 11, 21, 42, 39, 3, 2, 28, 47, 59, 32, 10, 57, 61, 52, 22, 19, 15) \ +T (200, 3, 57, 34, 47, 8, 31, 63, 39, 34, 19, 52, 42, 51, 28, 50, 44, 59, 27, 21, 24, 30, 61, 28, 20, 56, 20, 37, 32, 12, 22, 14, 4) \ +T (201, 1, 61, 23, 43, 21, 38, 13, 42, 45, 40, 24, 16, 59, 4, 46, 11, 43, 10, 30, 55, 20, 5, 49, 62, 22, 31, 54, 21, 53, 36, 17, 8) \ +T (202, 49, 56, 60, 30, 24, 23, 40, 15, 32, 61, 37, 13, 56, 5, 57, 0, 28, 39, 27, 59, 60, 42, 3, 6, 51, 36, 8, 53, 34, 22, 35, 10) \ +T (203, 27, 13, 16, 12, 30, 31, 15, 47, 23, 22, 37, 29, 40, 55, 6, 44, 11, 4, 49, 9, 50, 1, 25, 38, 59, 61, 2, 18, 28, 8, 17, 57) \ +T (204, 5, 62, 5, 37, 27, 2, 31, 25, 9, 40, 58, 34, 60, 17, 14, 0, 8, 47, 44, 43, 21, 54, 15, 20, 57, 35, 30, 61, 36, 7, 16, 32) \ +T (205, 55, 22, 9, 29, 54, 52, 0, 13, 39, 36, 63, 12, 43, 56, 58, 0, 10, 18, 48, 1, 20, 60, 4, 62, 2, 51, 41, 61, 1, 26, 24, 21) \ +T (206, 29, 14, 52, 20, 49, 59, 31, 55, 61, 15, 20, 11, 1, 16, 39, 43, 53, 13, 35, 7, 38, 28, 41, 10, 63, 56, 2, 23, 0, 57, 30, 26) \ +T (207, 31, 45, 56, 4, 19, 1, 32, 44, 20, 50, 8, 39, 58, 33, 59, 29, 62, 3, 55, 11, 28, 6, 32, 29, 43, 41, 7, 5, 18, 15, 21, 14) \ +T (208, 29, 1, 31, 17, 10, 58, 27, 5, 63, 27, 23, 49, 60, 4, 33, 3, 9, 51, 28, 37, 35, 61, 42, 19, 18, 39, 34, 15, 21, 14, 7, 36) \ +T (209, 47, 2, 8, 51, 56, 61, 12, 0, 37, 49, 24, 29, 44, 60, 30, 63, 33, 55, 5, 4, 27, 45, 50, 13, 59, 14, 39, 46, 40, 28, 19, 11) \ +T (210, 50, 2, 52, 36, 3, 59, 4, 24, 20, 41, 8, 49, 48, 5, 28, 37, 22, 18, 26, 16, 61, 38, 43, 33, 30, 16, 6, 42, 55, 54, 14, 32) \ +T (211, 56, 57, 33, 0, 47, 43, 50, 22, 15, 53, 1, 17, 60, 20, 63, 2, 27, 18, 51, 45, 23, 7, 31, 47, 4, 38, 34, 35, 49, 10, 9, 32) \ +T (212, 42, 54, 63, 4, 20, 3, 48, 34, 28, 10, 6, 60, 33, 29, 37, 14, 35, 13, 11, 57, 43, 44, 24, 39, 7, 56, 37, 22, 41, 31, 49, 32) \ +T (213, 40, 25, 61, 33, 60, 4, 1, 28, 29, 63, 47, 56, 9, 6, 22, 39, 7, 16, 38, 55, 18, 10, 34, 3, 24, 59, 9, 51, 44, 35, 14, 47) \ +T (214, 14, 11, 0, 4, 25, 6, 13, 60, 2, 26, 11, 27, 31, 30, 41, 58, 48, 24, 35, 44, 32, 49, 17, 8, 3, 1, 54, 16, 61, 15, 10, 18) \ +T (215, 7, 30, 38, 10, 26, 20, 54, 1, 28, 41, 0, 0, 5, 32, 56, 61, 48, 42, 14, 4, 34, 55, 39, 53, 46, 13, 62, 31, 53, 37, 24, 11) \ +T (216, 43, 36, 2, 21, 0, 28, 16, 53, 23, 7, 47, 30, 37, 28, 6, 35, 40, 60, 50, 32, 60, 9, 32, 46, 55, 49, 29, 13, 22, 14, 8, 62) \ +T (217, 15, 53, 9, 63, 0, 6, 29, 26, 35, 55, 38, 23, 50, 45, 2, 25, 16, 7, 53, 48, 47, 4, 18, 34, 28, 22, 43, 8, 60, 61, 21, 1) \ +T (218, 60, 32, 56, 46, 28, 61, 35, 57, 2, 11, 44, 34, 13, 23, 39, 50, 18, 5, 1, 40, 59, 3, 51, 49, 43, 14, 12, 27, 43, 31, 1, 25) \ +T (219, 4, 10, 19, 21, 46, 37, 30, 61, 45, 45, 40, 59, 39, 18, 42, 50, 2, 3, 23, 15, 32, 26, 52, 31, 35, 38, 48, 53, 20, 6, 12, 57) \ +T (220, 37, 43, 11, 32, 25, 41, 42, 54, 19, 27, 46, 12, 35, 16, 58, 48, 38, 21, 52, 56, 13, 22, 24, 1, 30, 24, 51, 50, 59, 20, 15, 31) \ +T (221, 31, 52, 23, 52, 42, 57, 3, 59, 56, 34, 35, 50, 25, 2, 45, 8, 11, 16, 62, 21, 25, 0, 15, 28, 18, 7, 24, 33, 1, 4, 20, 48) \ +T (222, 2, 37, 10, 34, 16, 28, 56, 57, 42, 11, 0, 27, 60, 25, 23, 61, 44, 36, 55, 53, 62, 41, 13, 27, 24, 20, 14, 39, 19, 8, 50, 56) \ +T (223, 47, 23, 30, 12, 48, 20, 63, 38, 60, 46, 43, 54, 1, 53, 6, 62, 2, 0, 37, 55, 39, 33, 19, 28, 26, 5, 41, 35, 44, 31, 9, 33) \ +T (224, 8, 3, 25, 48, 57, 1, 24, 23, 32, 22, 12, 10, 5, 43, 46, 39, 56, 19, 33, 27, 0, 56, 13, 2, 38, 51, 60, 35, 15, 59, 23, 28) \ +T (225, 15, 40, 34, 53, 58, 22, 7, 47, 54, 5, 33, 13, 60, 17, 52, 45, 24, 20, 36, 16, 61, 21, 46, 56, 23, 2, 42, 63, 43, 59, 57, 9) \ +T (226, 43, 21, 31, 3, 24, 2, 53, 41, 25, 12, 47, 19, 48, 28, 36, 45, 29, 23, 9, 50, 63, 20, 1, 61, 7, 6, 37, 26, 10, 55, 60, 58) \ +T (227, 59, 13, 48, 58, 52, 5, 16, 39, 7, 36, 37, 41, 47, 26, 40, 42, 25, 54, 6, 51, 63, 27, 12, 56, 28, 19, 49, 62, 38, 44, 61, 9) diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-4.inc b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-4.inc new file mode 100644 index 000000000..c50fa8e9d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-4.inc @@ -0,0 +1,139 @@ +#define N 4 +#define TESTS \ +T (0, 0, 1, 2, 3) \ +T (1, 0, 0, 0, 0) \ +T (2, 6, 3, 1, 5) \ +T (3, 1, 3, 5, 0) \ +T (4, 6, 3, 5, 4) \ +T (5, 6, 4, 1, 0) \ +T (6, 6, 1, 4, 2) \ +T (7, 3, 7, 4, 4) \ +T (8, 3, 2, 4, 4) \ +T (9, 3, 2, 6, 1) \ +T (10, 5, 4, 5, 6) \ +T (11, 1, 4, 0, 7) \ +T (12, 1, 5, 7, 2) \ +T (13, 2, 3, 0, 4) \ +T (14, 7, 6, 4, 2) \ +T (15, 6, 1, 3, 4) \ +T (16, 0, 2, 4, 6) \ +T (17, 1, 3, 5, 7) \ +T (18, 3, 3, 3, 3) \ +T (19, 3, 2, 1, 0) \ +T (20, 0, 4, 1, 5) \ +T (21, 2, 6, 3, 7) \ +T (22, 1, 2, 3, 0) \ +T (23, 2, 1, 0, 3) +#define EXPTESTS \ +T (116, 1, 2, 4, 3) \ +T (117, 7, 3, 3, 0) \ +T (118, 5, 3, 2, 7) \ +T (119, 0, 3, 5, 6) \ +T (120, 0, 0, 1, 5) \ +T (121, 4, 6, 2, 1) \ +T (122, 2, 5, 6, 3) \ +T (123, 4, 6, 3, 2) \ +T (124, 4, 7, 5, 6) \ +T (125, 0, 4, 2, 4) \ +T (126, 2, 4, 6, 0) \ +T (127, 4, 3, 5, 1) \ +T (128, 5, 4, 7, 3) \ +T (129, 7, 5, 6, 4) \ +T (130, 2, 0, 5, 3) \ +T (131, 7, 4, 3, 0) \ +T (132, 6, 1, 3, 1) \ +T (133, 3, 4, 1, 7) \ +T (134, 0, 0, 6, 4) \ +T (135, 6, 4, 0, 1) \ +T (136, 6, 0, 2, 4) \ +T (137, 1, 3, 4, 2) \ +T (138, 3, 1, 2, 4) \ +T (139, 3, 1, 5, 0) \ +T (140, 1, 6, 0, 2) \ +T (141, 0, 2, 6, 4) \ +T (142, 1, 7, 5, 2) \ +T (143, 7, 0, 4, 1) \ +T (144, 7, 3, 5, 6) \ +T (145, 0, 7, 5, 4) \ +T (146, 6, 4, 2, 3) \ +T (147, 1, 5, 7, 6) \ +T (148, 5, 7, 4, 7) \ +T (149, 5, 2, 2, 0) \ +T (150, 7, 1, 6, 4) \ +T (151, 5, 2, 4, 6) \ +T (152, 5, 0, 4, 6) \ +T (153, 4, 2, 7, 3) \ +T (154, 7, 1, 0, 6) \ +T (155, 0, 4, 2, 5) \ +T (156, 3, 4, 3, 2) \ +T (157, 2, 0, 6, 1) \ +T (158, 5, 1, 7, 4) \ +T (159, 2, 1, 5, 6) \ +T (160, 1, 6, 5, 7) \ +T (161, 2, 4, 1, 6) \ +T (162, 3, 7, 1, 6) \ +T (163, 2, 1, 4, 7) \ +T (164, 4, 2, 1, 0) \ +T (165, 0, 7, 1, 3) \ +T (166, 7, 4, 2, 3) \ +T (167, 4, 5, 3, 5) \ +T (168, 1, 5, 6, 7) \ +T (169, 6, 3, 2, 0) \ +T (170, 6, 2, 1, 5) \ +T (171, 5, 6, 1, 3) \ +T (172, 2, 2, 3, 1) \ +T (173, 5, 4, 3, 5) \ +T (174, 7, 3, 4, 1) \ +T (175, 4, 2, 3, 6) \ +T (176, 7, 6, 5, 3) \ +T (177, 7, 2, 0, 6) \ +T (178, 1, 3, 0, 2) \ +T (179, 5, 3, 0, 5) \ +T (180, 4, 6, 7, 2) \ +T (181, 4, 5, 2, 0) \ +T (182, 5, 0, 1, 2) \ +T (183, 2, 3, 4, 1) \ +T (184, 2, 6, 5, 1) \ +T (185, 0, 6, 7, 4) \ +T (186, 4, 1, 6, 2) \ +T (187, 1, 3, 2, 3) \ +T (188, 2, 5, 4, 3) \ +T (189, 2, 5, 6, 4) \ +T (190, 4, 0, 5, 0) \ +T (191, 2, 1, 6, 0) \ +T (192, 7, 5, 0, 1) \ +T (193, 3, 5, 6, 7) \ +T (194, 0, 1, 2, 7) \ +T (195, 3, 1, 0, 2) \ +T (196, 2, 4, 6, 3) \ +T (197, 6, 0, 5, 4) \ +T (198, 6, 5, 7, 1) \ +T (199, 2, 5, 4, 6) \ +T (200, 7, 2, 3, 6) \ +T (201, 3, 5, 7, 3) \ +T (202, 1, 7, 4, 6) \ +T (203, 4, 0, 7, 1) \ +T (204, 7, 1, 0, 4) \ +T (205, 5, 1, 3, 4) \ +T (206, 0, 7, 3, 5) \ +T (207, 3, 2, 1, 5) \ +T (208, 7, 5, 0, 2) \ +T (209, 7, 0, 6, 3) \ +T (210, 6, 6, 7, 7) \ +T (211, 5, 6, 0, 4) \ +T (212, 5, 1, 2, 2) \ +T (213, 7, 1, 2, 6) \ +T (214, 5, 4, 2, 6) \ +T (215, 1, 5, 6, 4) \ +T (216, 7, 0, 2, 1) \ +T (217, 1, 5, 3, 6) \ +T (218, 3, 3, 6, 5) \ +T (219, 2, 3, 5, 7) \ +T (220, 2, 4, 3, 0) \ +T (221, 1, 5, 6, 3) \ +T (222, 7, 5, 1, 5) \ +T (223, 0, 5, 3, 4) \ +T (224, 2, 3, 1, 4) \ +T (225, 2, 3, 5, 1) \ +T (226, 4, 3, 1, 0) \ +T (227, 2, 3, 5, 5) diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-8.inc b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-8.inc new file mode 100644 index 000000000..a39d71da6 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-8.inc @@ -0,0 +1,139 @@ +#define N 8 +#define TESTS \ +T (0, 0, 1, 2, 3, 4, 5, 6, 7) \ +T (1, 0, 0, 0, 0, 0, 0, 0, 0) \ +T (2, 0, 1, 2, 3, 0, 1, 2, 3) \ +T (3, 0, 10, 3, 8, 1, 11, 10, 2) \ +T (4, 0, 1, 2, 3, 3, 0, 2, 1) \ +T (5, 12, 5, 14, 9, 8, 15, 1, 7) \ +T (6, 9, 10, 11, 8, 4, 15, 14, 12) \ +T (7, 4, 10, 14, 9, 11, 1, 12, 11) \ +T (8, 15, 3, 3, 8, 5, 11, 2, 10) \ +T (9, 13, 11, 10, 15, 8, 5, 14, 8) \ +T (10, 9, 13, 12, 14, 10, 1, 5, 14) \ +T (11, 5, 11, 12, 6, 3, 2, 4, 15) \ +T (12, 5, 13, 14, 8, 4, 10, 4, 12) \ +T (13, 14, 8, 12, 3, 13, 9, 5, 4) \ +T (14, 15, 3, 13, 6, 14, 12, 10, 0) \ +T (15, 0, 5, 11, 7, 4, 6, 14, 1) \ +T (16, 0, 2, 4, 6, 8, 10, 12, 14) \ +T (17, 1, 3, 5, 7, 9, 11, 13, 15) \ +T (18, 3, 3, 3, 3, 3, 3, 3, 3) \ +T (19, 7, 6, 5, 4, 3, 2, 1, 0) \ +T (20, 0, 8, 1, 9, 2, 10, 3, 11) \ +T (21, 4, 12, 5, 13, 6, 14, 7, 15) \ +T (22, 1, 2, 3, 4, 5, 6, 7, 0) \ +T (23, 6, 5, 4, 3, 2, 1, 0, 7) +#define EXPTESTS \ +T (116, 9, 3, 9, 4, 7, 0, 0, 6) \ +T (117, 4, 14, 12, 8, 9, 6, 0, 10) \ +T (118, 10, 12, 1, 3, 4, 11, 9, 2) \ +T (119, 4, 11, 9, 5, 8, 14, 0, 2) \ +T (120, 0, 10, 8, 6, 4, 9, 7, 5) \ +T (121, 10, 15, 0, 4, 12, 9, 7, 3) \ +T (122, 13, 6, 0, 7, 5, 12, 12, 2) \ +T (123, 4, 10, 11, 15, 12, 7, 3, 8) \ +T (124, 1, 13, 15, 9, 6, 5, 7, 4) \ +T (125, 7, 13, 2, 5, 2, 8, 1, 6) \ +T (126, 4, 5, 2, 12, 14, 13, 8, 6) \ +T (127, 4, 10, 2, 7, 11, 15, 9, 0) \ +T (128, 14, 8, 12, 10, 13, 3, 11, 2) \ +T (129, 10, 8, 14, 9, 5, 1, 15, 7) \ +T (130, 12, 2, 9, 13, 5, 14, 1, 15) \ +T (131, 10, 4, 1, 14, 11, 15, 9, 2) \ +T (132, 9, 12, 7, 4, 2, 1, 0, 9) \ +T (133, 11, 15, 4, 10, 3, 12, 13, 5) \ +T (134, 1, 5, 6, 13, 14, 15, 3, 10) \ +T (135, 0, 14, 6, 10, 1, 13, 3, 2) \ +T (136, 2, 11, 1, 5, 12, 13, 3, 5) \ +T (137, 7, 11, 4, 1, 12, 10, 14, 10) \ +T (138, 3, 6, 7, 13, 11, 15, 10, 0) \ +T (139, 10, 8, 7, 14, 1, 11, 0, 13) \ +T (140, 5, 3, 13, 11, 8, 5, 12, 6) \ +T (141, 15, 2, 12, 13, 10, 8, 5, 0) \ +T (142, 13, 9, 10, 2, 11, 3, 4, 1) \ +T (143, 2, 14, 6, 5, 1, 8, 15, 0) \ +T (144, 12, 9, 14, 10, 1, 3, 11, 13) \ +T (145, 12, 13, 11, 2, 5, 6, 4, 8) \ +T (146, 5, 0, 2, 1, 6, 8, 15, 13) \ +T (147, 8, 7, 1, 3, 5, 11, 14, 15) \ +T (148, 0, 9, 2, 15, 3, 1, 8, 10) \ +T (149, 4, 14, 11, 6, 8, 5, 12, 7) \ +T (150, 5, 9, 10, 12, 14, 15, 2, 7) \ +T (151, 11, 6, 5, 7, 11, 14, 2, 1) \ +T (152, 13, 1, 7, 4, 6, 8, 15, 9) \ +T (153, 10, 12, 9, 1, 6, 7, 8, 15) \ +T (154, 8, 4, 5, 1, 3, 0, 7, 13) \ +T (155, 13, 9, 3, 4, 10, 1, 15, 7) \ +T (156, 13, 8, 2, 7, 0, 6, 3, 6) \ +T (157, 15, 15, 13, 6, 0, 5, 14, 4) \ +T (158, 13, 1, 2, 2, 7, 9, 2, 6) \ +T (159, 5, 12, 10, 13, 6, 1, 4, 7) \ +T (160, 0, 2, 9, 1, 5, 11, 14, 11) \ +T (161, 14, 6, 5, 10, 3, 2, 15, 4) \ +T (162, 3, 10, 0, 1, 13, 14, 11, 15) \ +T (163, 13, 7, 5, 9, 5, 0, 11, 4) \ +T (164, 2, 11, 1, 12, 3, 13, 4, 9) \ +T (165, 1, 0, 10, 11, 5, 13, 4, 3) \ +T (166, 3, 9, 1, 12, 15, 14, 10, 5) \ +T (167, 3, 10, 11, 14, 5, 1, 8, 12) \ +T (168, 10, 15, 5, 14, 4, 13, 6, 3) \ +T (169, 1, 8, 6, 4, 11, 13, 7, 10) \ +T (170, 8, 7, 1, 15, 11, 9, 0, 3) \ +T (171, 4, 0, 11, 7, 1, 15, 3, 13) \ +T (172, 14, 7, 3, 4, 9, 11, 0, 6) \ +T (173, 7, 3, 11, 4, 8, 2, 10, 15) \ +T (174, 7, 9, 14, 2, 0, 5, 13, 3) \ +T (175, 4, 8, 5, 9, 3, 11, 1, 14) \ +T (176, 13, 12, 3, 3, 1, 4, 8, 5) \ +T (177, 7, 12, 9, 13, 10, 4, 5, 8) \ +T (178, 14, 3, 12, 7, 2, 6, 5, 5) \ +T (179, 7, 0, 8, 6, 2, 14, 12, 15) \ +T (180, 2, 12, 0, 4, 1, 15, 11, 10) \ +T (181, 0, 7, 5, 12, 15, 10, 14, 3) \ +T (182, 3, 10, 2, 5, 11, 6, 13, 14) \ +T (183, 3, 2, 7, 11, 0, 13, 8, 10) \ +T (184, 0, 12, 15, 1, 9, 2, 11, 4) \ +T (185, 11, 15, 8, 10, 9, 1, 13, 3) \ +T (186, 12, 13, 15, 12, 3, 9, 5, 7) \ +T (187, 4, 10, 5, 6, 1, 11, 0, 11) \ +T (188, 11, 6, 7, 9, 0, 8, 14, 8) \ +T (189, 1, 15, 6, 9, 12, 6, 7, 14) \ +T (190, 1, 5, 6, 11, 12, 13, 3, 0) \ +T (191, 0, 8, 15, 13, 12, 6, 1, 4) \ +T (192, 12, 15, 8, 4, 2, 0, 9, 5) \ +T (193, 14, 5, 13, 10, 12, 11, 0, 1) \ +T (194, 12, 1, 9, 8, 10, 9, 0, 2) \ +T (195, 11, 0, 13, 4, 6, 2, 14, 15) \ +T (196, 0, 10, 6, 2, 12, 4, 9, 13) \ +T (197, 7, 12, 8, 10, 1, 0, 5, 0) \ +T (198, 12, 13, 0, 5, 3, 14, 11, 4) \ +T (199, 9, 1, 4, 14, 10, 12, 15, 6) \ +T (200, 3, 12, 13, 6, 14, 2, 1, 6) \ +T (201, 5, 14, 8, 10, 1, 12, 2, 0) \ +T (202, 5, 8, 2, 7, 4, 15, 14, 2) \ +T (203, 14, 13, 10, 9, 11, 15, 7, 8) \ +T (204, 12, 13, 14, 2, 4, 9, 5, 7) \ +T (205, 0, 7, 5, 4, 7, 13, 6, 8) \ +T (206, 7, 0, 15, 6, 12, 2, 5, 4) \ +T (207, 8, 6, 0, 1, 1, 11, 1, 9) \ +T (208, 11, 6, 14, 9, 5, 3, 7, 13) \ +T (209, 12, 3, 15, 9, 1, 0, 8, 13) \ +T (210, 11, 1, 9, 8, 7, 6, 12, 2) \ +T (211, 10, 9, 2, 6, 8, 11, 0, 4) \ +T (212, 10, 13, 15, 9, 6, 15, 14, 10) \ +T (213, 9, 5, 8, 3, 4, 7, 11, 4) \ +T (214, 1, 2, 13, 5, 8, 4, 3, 6) \ +T (215, 8, 3, 2, 4, 9, 14, 12, 13) \ +T (216, 5, 7, 8, 15, 3, 1, 10, 4) \ +T (217, 2, 9, 3, 2, 14, 11, 5, 7) \ +T (218, 15, 6, 4, 10, 14, 3, 13, 2) \ +T (219, 0, 8, 14, 5, 15, 7, 10, 1) \ +T (220, 14, 0, 6, 10, 8, 2, 7, 4) \ +T (221, 15, 13, 3, 14, 11, 2, 14, 6) \ +T (222, 8, 2, 10, 13, 1, 0, 4, 11) \ +T (223, 7, 15, 2, 9, 1, 12, 11, 3) \ +T (224, 13, 15, 3, 12, 15, 7, 0, 8) \ +T (225, 0, 2, 1, 11, 14, 3, 9, 14) \ +T (226, 12, 14, 3, 15, 8, 5, 1, 7) \ +T (227, 0, 5, 13, 8, 4, 2, 1, 3) diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-main.inc b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-main.inc new file mode 100644 index 000000000..52b75ee73 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-main.inc @@ -0,0 +1,55 @@ +/* Driver fragment for __builtin_shuffle of any vector shape. */ + +extern void abort (void); + +#ifndef UNSUPPORTED +V a, b, c, d; + +#define T(num, msk...) \ +__attribute__((noinline, noclone)) void \ +test_##num (void) \ +{ \ + VI mask = { msk }; \ + int i; \ + c = __builtin_shuffle (a, mask); \ + d = __builtin_shuffle (a, b, mask); \ + __asm ("" : : "r" (&c), "r" (&d) : "memory"); \ + for (i = 0; i < N; ++i) \ + if (c[i] != a[mask[i] & (N - 1)]) \ + abort (); \ + else if ((mask[i] & N)) \ + { \ + if (d[i] != b[mask[i] & (N - 1)]) \ + abort (); \ + } \ + else if (d[i] != a[mask[i] & (N - 1)]) \ + abort (); \ +} +TESTS +#ifdef EXPENSIVE +EXPTESTS +#endif +#endif + +int +main () +{ +#ifndef UNSUPPORTED + int i; + for (i = 0; i < N; ++i) + { + a[i] = i + 2; + b[i] = N + i + 2; + } + +#undef T +#define T(num, msk...) \ + test_##num (); + TESTS +#ifdef EXPENSIVE + EXPTESTS +#endif +#endif + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v16hi.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v16hi.c new file mode 100644 index 000000000..9ff3ebbfa --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v16hi.c @@ -0,0 +1,11 @@ +/* { dg-do run } */ +/* { dg-options "-DEXPENSIVE" { target run_expensive_tests } } */ +/* { dg-options "-fno-common" { target hppa*-*-hpux* } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +typedef unsigned short V __attribute__((vector_size(32))); +typedef V VI; + +#include "vshuf-16.inc" +#include "vshuf-main.inc" diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v16qi.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v16qi.c new file mode 100644 index 000000000..062324d7b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v16qi.c @@ -0,0 +1,11 @@ +/* { dg-do run } */ +/* { dg-options "-DEXPENSIVE" { target run_expensive_tests } } */ +/* { dg-options "-fno-common" { target hppa*-*-hpux* } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +typedef unsigned char V __attribute__((vector_size(16))); +typedef V VI; + +#include "vshuf-16.inc" +#include "vshuf-main.inc" diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v2df.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v2df.c new file mode 100644 index 000000000..8e33d1d04 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v2df.c @@ -0,0 +1,15 @@ +/* { dg-do run } */ +/* { dg-options "-DEXPENSIVE" { target run_expensive_tests } } */ +/* { dg-options "-fno-common" { target hppa*-*-hpux* } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __SIZEOF_DOUBLE__ == 8 && __SIZEOF_LONG_LONG__ == 8 +typedef double V __attribute__((vector_size(16))); +typedef unsigned long long VI __attribute__((vector_size(16))); +#else +#define UNSUPPORTED +#endif + +#include "vshuf-2.inc" +#include "vshuf-main.inc" diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v2di.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v2di.c new file mode 100644 index 000000000..d498c28f0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v2di.c @@ -0,0 +1,15 @@ +/* { dg-do run } */ +/* { dg-options "-DEXPENSIVE" { target run_expensive_tests } } */ +/* { dg-options "-fno-common" { target hppa*-*-hpux* } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __SIZEOF_LONG_LONG__ == 8 +typedef unsigned long long V __attribute__((vector_size(16))); +typedef V VI; +#else +#define UNSUPPORTED +#endif + +#include "vshuf-2.inc" +#include "vshuf-main.inc" diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v2sf.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v2sf.c new file mode 100644 index 000000000..22bcaa98d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v2sf.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-DEXPENSIVE" { target run_expensive_tests } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __SIZEOF_FLOAT__ == 4 +typedef float V __attribute__((vector_size(8))); +# if __SIZEOF_INT__ == 4 +typedef unsigned int VI __attribute__((vector_size(8))); +# elif __SIZEOF_LONG__ == 4 +typedef unsigned long VI __attribute__((vector_size(8))); +# else +# define UNSUPPORTED +# endif +#else +# define UNSUPPORTED +#endif + +#include "vshuf-2.inc" +#include "vshuf-main.inc" diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v2si.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v2si.c new file mode 100644 index 000000000..2138c6ca6 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v2si.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ +/* { dg-options "-DEXPENSIVE" { target run_expensive_tests } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __SIZEOF_INT__ == 4 +typedef unsigned int V __attribute__((vector_size(8))); +typedef V VI; +#elif __SIZEOF_LONG__ == 4 +typedef unsigned long V __attribute__((vector_size(8))); +typedef V VI; +#else +#define UNSUPPORTED +#endif + +#include "vshuf-2.inc" +#include "vshuf-main.inc" diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v32qi.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v32qi.c new file mode 100644 index 000000000..017900687 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v32qi.c @@ -0,0 +1,11 @@ +/* { dg-do run } */ +/* { dg-options "-DEXPENSIVE" { target run_expensive_tests } } */ +/* { dg-options "-fno-common" { target hppa*-*-hpux* } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +typedef unsigned char V __attribute__((vector_size(32))); +typedef V VI; + +#include "vshuf-32.inc" +#include "vshuf-main.inc" diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v4df.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v4df.c new file mode 100644 index 000000000..c11d6396d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v4df.c @@ -0,0 +1,15 @@ +/* { dg-do run } */ +/* { dg-options "-DEXPENSIVE" { target run_expensive_tests } } */ +/* { dg-options "-fno-common" { target hppa*-*-hpux* } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __SIZEOF_DOUBLE__ == 8 && __SIZEOF_LONG_LONG__ == 8 +typedef double V __attribute__((vector_size(32))); +typedef unsigned long long VI __attribute__((vector_size(32))); +#else +#define UNSUPPORTED +#endif + +#include "vshuf-4.inc" +#include "vshuf-main.inc" diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v4di.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v4di.c new file mode 100644 index 000000000..494cb7826 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v4di.c @@ -0,0 +1,15 @@ +/* { dg-do run } */ +/* { dg-options "-DEXPENSIVE" { target run_expensive_tests } } */ +/* { dg-options "-fno-common" { target hppa*-*-hpux* } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __SIZEOF_LONG_LONG__ == 8 +typedef unsigned long long V __attribute__((vector_size(32))); +typedef V VI; +#else +#define UNSUPPORTED +#endif + +#include "vshuf-4.inc" +#include "vshuf-main.inc" diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v4hi.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v4hi.c new file mode 100644 index 000000000..cfd56a613 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v4hi.c @@ -0,0 +1,10 @@ +/* { dg-do run } */ +/* { dg-options "-DEXPENSIVE" { target run_expensive_tests } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +typedef unsigned short V __attribute__((vector_size(8))); +typedef V VI; + +#include "vshuf-4.inc" +#include "vshuf-main.inc" diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v4sf.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v4sf.c new file mode 100644 index 000000000..4db59f9da --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v4sf.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ +/* { dg-options "-DEXPENSIVE" { target run_expensive_tests } } */ +/* { dg-options "-fno-common" { target hppa*-*-hpux* } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __SIZEOF_FLOAT__ == 4 +typedef float V __attribute__((vector_size(16))); +# if __SIZEOF_INT__ == 4 +typedef unsigned int VI __attribute__((vector_size(16))); +# elif __SIZEOF_LONG__ == 4 +typedef unsigned long VI __attribute__((vector_size(16))); +# else +# define UNSUPPORTED +# endif +#else +# define UNSUPPORTED +#endif + +#include "vshuf-4.inc" +#include "vshuf-main.inc" diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v4si.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v4si.c new file mode 100644 index 000000000..3ae86acd3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v4si.c @@ -0,0 +1,18 @@ +/* { dg-do run } */ +/* { dg-options "-DEXPENSIVE" { target run_expensive_tests } } */ +/* { dg-options "-fno-common" { target hppa*-*-hpux* } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __SIZEOF_INT__ == 4 +typedef unsigned int V __attribute__((vector_size(16))); +typedef V VI; +#elif __SIZEOF_LONG__ == 4 +typedef unsigned long V __attribute__((vector_size(16))); +typedef V VI; +#else +# define UNSUPPORTED +#endif + +#include "vshuf-4.inc" +#include "vshuf-main.inc" diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v8hi.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v8hi.c new file mode 100644 index 000000000..f4639880f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v8hi.c @@ -0,0 +1,11 @@ +/* { dg-do run } */ +/* { dg-options "-DEXPENSIVE" { target run_expensive_tests } } */ +/* { dg-options "-fno-common" { target hppa*-*-hpux* } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +typedef unsigned short V __attribute__((vector_size(16))); +typedef V VI; + +#include "vshuf-8.inc" +#include "vshuf-main.inc" diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v8qi.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v8qi.c new file mode 100644 index 000000000..4bc96bedc --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v8qi.c @@ -0,0 +1,10 @@ +/* { dg-do run } */ +/* { dg-options "-DEXPENSIVE" { target run_expensive_tests } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +typedef unsigned char V __attribute__((vector_size(8))); +typedef V VI; + +#include "vshuf-8.inc" +#include "vshuf-main.inc" diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v8sf.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v8sf.c new file mode 100644 index 000000000..d11aa0c95 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v8sf.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ +/* { dg-options "-DEXPENSIVE" { target run_expensive_tests } } */ +/* { dg-options "-fno-common" { target hppa*-*-hpux* } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __SIZEOF_FLOAT__ == 4 +typedef float V __attribute__((vector_size(32))); +# if __SIZEOF_INT__ == 4 +typedef unsigned int VI __attribute__((vector_size(32))); +# elif __SIZEOF_LONG__ == 4 +typedef unsigned long VI __attribute__((vector_size(32))); +# else +# define UNSUPPORTED +# endif +#else +# define UNSUPPORTED +#endif + +#include "vshuf-8.inc" +#include "vshuf-main.inc" diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v8si.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v8si.c new file mode 100644 index 000000000..64d97164d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/vshuf-v8si.c @@ -0,0 +1,18 @@ +/* { dg-do run } */ +/* { dg-options "-DEXPENSIVE" { target run_expensive_tests } } */ +/* { dg-options "-fno-common" { target hppa*-*-hpux* } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __SIZEOF_INT__ == 4 +typedef unsigned int V __attribute__((vector_size(32))); +typedef V VI; +#elif __SIZEOF_LONG__ == 4 +typedef unsigned long V __attribute__((vector_size(32))); +typedef V VI; +#else +# define UNSUPPORTED +#endif + +#include "vshuf-8.inc" +#include "vshuf-main.inc" |