diff options
Diffstat (limited to 'gcc-4.8/gcc/testsuite/gcc.c-torture/execute')
17 files changed, 488 insertions, 0 deletions
diff --git a/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/20131127-1.c b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/20131127-1.c new file mode 100644 index 000000000..8ec496577 --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/20131127-1.c @@ -0,0 +1,34 @@ +/* PR middle-end/59138 */ +/* Testcase by John Regehr <regehr@cs.utah.edu> */ + +extern void abort (void); + +#pragma pack(1) + +struct S0 { + int f0; + int f1; + int f2; + short f3; +}; + +short a = 1; + +struct S0 b = { 1 }, c, d, e; + +struct S0 fn1() { return c; } + +void fn2 (void) +{ + b = fn1 (); + a = 0; + d = e; +} + +int main (void) +{ + fn2 (); + if (a != 0) + abort (); + return 0; +} diff --git a/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/20140212-1.c b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/20140212-1.c new file mode 100644 index 000000000..8f1f84f3e --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/20140212-1.c @@ -0,0 +1,37 @@ +/* PR rtl-optimization/60116 */ +/* Reported by Zhendong Su <su@cs.ucdavis.edu> */ + +extern void abort (void); + +int a, b, c, d = 1, e, f = 1, h, i, k; +char g, j; + +void +fn1 (void) +{ + int l; + e = 0; + c = 0; + for (;;) + { + k = a && b; + j = k * 54; + g = j * 147; + l = ~g + (long long) e && 1; + if (d) + c = l; + else + h = i = l * 9UL; + if (f) + return; + } +} + +int +main (void) +{ + fn1 (); + if (c != 1) + abort (); + return 0; +} diff --git a/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/20140326-1.c b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/20140326-1.c new file mode 100644 index 000000000..552e21891 --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/20140326-1.c @@ -0,0 +1,10 @@ +int a; + +int +main (void) +{ + char e[2] = { 0, 0 }, f = 0; + if (a == 131072) + f = e[a]; + return f; +} diff --git a/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/20140425-1.c b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/20140425-1.c new file mode 100644 index 000000000..c447ef95b --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/20140425-1.c @@ -0,0 +1,23 @@ +/* PR target/60941 */ +/* Reported by Martin Husemann <martin@netbsd.org> */ + +extern void abort (void); + +static void __attribute__((noinline)) +set (unsigned long *l) +{ + *l = 31; +} + +int main (void) +{ + unsigned long l; + int i; + + set (&l); + i = (int) l; + l = (unsigned long)(2U << i); + if (l != 0) + abort (); + return 0; +} diff --git a/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr58726.c b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr58726.c new file mode 100644 index 000000000..9fa8b6953 --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr58726.c @@ -0,0 +1,26 @@ +/* PR rtl-optimization/58726 */ + +int a, c; +union { int f1; int f2 : 1; } b; + +short +foo (short p) +{ + return p < 0 ? p : a; +} + +int +main () +{ + if (sizeof (short) * __CHAR_BIT__ != 16 + || sizeof (int) * __CHAR_BIT__ != 32) + return 0; + b.f1 = 56374; + unsigned short d; + int e = b.f2; + d = e == 0 ? b.f1 : 0; + c = foo (d); + if (c != (short) 56374) + __builtin_abort (); + return 0; +} diff --git a/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr58831.c b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr58831.c new file mode 100644 index 000000000..a40cd54d2 --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr58831.c @@ -0,0 +1,40 @@ +#include <assert.h> + +int a, *b, c, d, f, **i, p, q, *r; +short o, j; + +static int __attribute__((noinline, noclone)) +fn1 (int *p1, int **p2) +{ + int **e = &b; + for (; p; p++) + *p1 = 1; + *e = *p2 = &d; + + assert (r); + + return c; +} + +static int ** __attribute__((noinline, noclone)) +fn2 (void) +{ + for (f = 0; f != 42; f++) + { + int *g[3] = {0, 0, 0}; + for (o = 0; o; o--) + for (; a > 1;) + { + int **h[1] = { &g[2] }; + } + } + return &r; +} + +int +main (void) +{ + i = fn2 (); + fn1 (b, i); + return 0; +} diff --git a/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr58984.c b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr58984.c new file mode 100644 index 000000000..e0f7669c7 --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr58984.c @@ -0,0 +1,57 @@ +/* PR tree-optimization/58984 */ + +struct S { int f0 : 8; int : 6; int f1 : 5; }; +struct T { char f0; int : 6; int f1 : 5; }; + +int a, *c = &a, e, n, b, m; + +static int +foo (struct S p) +{ + const unsigned short *f[36]; + for (; e < 2; e++) + { + const unsigned short **i = &f[0]; + *c ^= 1; + if (p.f1) + { + *i = 0; + return b; + } + } + return 0; +} + +static int +bar (struct T p) +{ + const unsigned short *f[36]; + for (; e < 2; e++) + { + const unsigned short **i = &f[0]; + *c ^= 1; + if (p.f1) + { + *i = 0; + return b; + } + } + return 0; +} + +int +main () +{ + struct S o = { 1, 1 }; + foo (o); + m = n || o.f0; + if (a != 1) + __builtin_abort (); + e = 0; + struct T p = { 1, 1 }; + bar (p); + m |= n || p.f0; + if (a != 0) + __builtin_abort (); + return 0; +} diff --git a/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr59014-2.c b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr59014-2.c new file mode 100644 index 000000000..18da0059e --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr59014-2.c @@ -0,0 +1,23 @@ +/* PR tree-optimization/59014 */ + +__attribute__((noinline, noclone)) long long int +foo (long long int x, long long int y) +{ + if (((int) x | (int) y) != 0) + return 6; + return x + y; +} + +int +main () +{ + if (sizeof (long long) == sizeof (int)) + return 0; + int shift_half = sizeof (int) * __CHAR_BIT__ / 2; + long long int x = (3LL << shift_half) << shift_half; + long long int y = (5LL << shift_half) << shift_half; + long long int z = foo (x, y); + if (z != ((8LL << shift_half) << shift_half)) + __builtin_abort (); + return 0; +} diff --git a/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr59014.c b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr59014.c new file mode 100644 index 000000000..10bf81a46 --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr59014.c @@ -0,0 +1,25 @@ +/* PR tree-optimization/59014 */ + +int a = 2, b, c, d; + +int +foo () +{ + for (;; c++) + if ((b > 0) | (a & 1)) + ; + else + { + d = a; + return 0; + } +} + +int +main () +{ + foo (); + if (d != 2) + __builtin_abort (); + return 0; +} diff --git a/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr59101.c b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr59101.c new file mode 100644 index 000000000..ed6a7e8fa --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr59101.c @@ -0,0 +1,15 @@ +/* PR target/59101 */ + +__attribute__((noinline, noclone)) int +foo (int a) +{ + return (~a & 4102790424LL) > 0 | 6; +} + +int +main () +{ + if (foo (0) != 7) + __builtin_abort (); + return 0; +} diff --git a/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr59358.c b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr59358.c new file mode 100644 index 000000000..674026d62 --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr59358.c @@ -0,0 +1,44 @@ +/* PR tree-optimization/59358 */ + +__attribute__((noinline, noclone)) int +foo (int *x, int y) +{ + int z = *x; + if (y > z && y <= 16) + while (y > z) + z *= 2; + return z; +} + +int +main () +{ + int i; + for (i = 1; i < 17; i++) + { + int j = foo (&i, 16); + int k; + if (i >= 8 && i <= 15) + k = 16 + (i - 8) * 2; + else if (i >= 4 && i <= 7) + k = 16 + (i - 4) * 4; + else if (i == 3) + k = 24; + else + k = 16; + if (j != k) + __builtin_abort (); + j = foo (&i, 7); + if (i >= 7) + k = i; + else if (i >= 4) + k = 8 + (i - 4) * 2; + else if (i == 3) + k = 12; + else + k = 8; + if (j != k) + __builtin_abort (); + } + return 0; +} diff --git a/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr59388.c b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr59388.c new file mode 100644 index 000000000..de3648a00 --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr59388.c @@ -0,0 +1,11 @@ +/* PR tree-optimization/59388 */ + +int a; +struct S { unsigned int f:1; } b; + +int +main () +{ + a = (0 < b.f) | b.f; + return a; +} diff --git a/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr60017.c b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr60017.c new file mode 100644 index 000000000..d72c12c8a --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr60017.c @@ -0,0 +1,33 @@ +/* PR target/60017 */ + +extern void abort (void); + +struct S0 +{ + short m0; + short m1; +}; + +struct S1 +{ + unsigned m0:1; + char m1[2][2]; + struct S0 m2[2]; +}; + +struct S1 x = { 1, {{2, 3}, {4, 5}}, {{6, 7}, {8, 9}} }; + +struct S1 func (void) +{ + return x; +} + +int main (void) +{ + struct S1 ret = func (); + + if (ret.m2[1].m1 != 9) + abort (); + + return 0; +} diff --git a/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr60062.c b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr60062.c new file mode 100644 index 000000000..62973d458 --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr60062.c @@ -0,0 +1,25 @@ +/* PR target/60062 */ + +int a; + +static void +foo (const char *p1, int p2) +{ + if (__builtin_strcmp (p1, "hello") != 0) + __builtin_abort (); +} + +static void +bar (const char *p1) +{ + if (__builtin_strcmp (p1, "hello") != 0) + __builtin_abort (); +} + +__attribute__((optimize (0))) int +main () +{ + foo ("hello", a); + bar ("hello"); + return 0; +} diff --git a/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr60072.c b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr60072.c new file mode 100644 index 000000000..566874d63 --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr60072.c @@ -0,0 +1,16 @@ +/* PR target/60072 */ + +int c = 1; + +__attribute__ ((optimize (1))) +static int *foo (int *p) +{ + return p; +} + +int +main () +{ + *foo (&c) = 2; + return c - 2; +} diff --git a/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr60454.c b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr60454.c new file mode 100644 index 000000000..ceec45e69 --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr60454.c @@ -0,0 +1,31 @@ +#ifdef __UINT32_TYPE__ +typedef __UINT32_TYPE__ uint32_t; +#else +typedef unsigned uint32_t; +#endif + +#define __fake_const_swab32(x) ((uint32_t)( \ + (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \ + (((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \ + (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 8) | \ + (((uint32_t)(x) & (uint32_t)0x0000ff00UL) ) | \ + (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24))) + +/* Previous version of bswap optimization would detect byte swap when none + happen. This test aims at catching such wrong detection to avoid + regressions. */ + +__attribute__ ((noinline, noclone)) uint32_t +fake_swap32 (uint32_t in) +{ + return __fake_const_swab32 (in); +} + +int main(void) +{ + if (sizeof (uint32_t) * __CHAR_BIT__ != 32) + return 0; + if (fake_swap32 (0x12345678UL) != 0x78567E12UL) + __builtin_abort (); + return 0; +} diff --git a/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr60960.c b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr60960.c new file mode 100644 index 000000000..b4f08d4c5 --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr60960.c @@ -0,0 +1,38 @@ +/* PR tree-optimization/60960 */ + +typedef unsigned char v4qi __attribute__ ((vector_size (4))); + +__attribute__((noinline, noclone)) v4qi +f1 (v4qi v) +{ + return v / 2; +} + +__attribute__((noinline, noclone)) v4qi +f2 (v4qi v) +{ + return v / (v4qi) { 2, 2, 2, 2 }; +} + +__attribute__((noinline, noclone)) v4qi +f3 (v4qi x, v4qi y) +{ + return x / y; +} + +int +main () +{ + v4qi x = { 5, 5, 5, 5 }; + v4qi y = { 2, 2, 2, 2 }; + v4qi z = f1 (x); + if (__builtin_memcmp (&y, &z, sizeof (y)) != 0) + __builtin_abort (); + z = f2 (x); + if (__builtin_memcmp (&y, &z, sizeof (y)) != 0) + __builtin_abort (); + z = f3 (x, y); + if (__builtin_memcmp (&y, &z, sizeof (y)) != 0) + __builtin_abort (); + return 0; +} |