From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- gcc/testsuite/gcc.c-torture/execute/pr47538.c | 73 +++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 gcc/testsuite/gcc.c-torture/execute/pr47538.c (limited to 'gcc/testsuite/gcc.c-torture/execute/pr47538.c') diff --git a/gcc/testsuite/gcc.c-torture/execute/pr47538.c b/gcc/testsuite/gcc.c-torture/execute/pr47538.c new file mode 100644 index 000000000..99dea0843 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr47538.c @@ -0,0 +1,73 @@ +/* PR tree-optimization/47538 */ + +struct S +{ + double a, b, *c; + unsigned long d; +}; + +__attribute__((noinline, noclone)) void +foo (struct S *x, const struct S *y) +{ + const unsigned long n = y->d + 1; + const double m = 0.25 * (y->b - y->a); + x->a = y->a; + x->b = y->b; + if (n == 1) + { + x->c[0] = 0.; + } + else if (n == 2) + { + x->c[1] = m * y->c[0]; + x->c[0] = 2.0 * x->c[1]; + } + else + { + double o = 0.0, p = 1.0; + unsigned long i; + + for (i = 1; i <= n - 2; i++) + { + x->c[i] = m * (y->c[i - 1] - y->c[i + 1]) / (double) i; + o += p * x->c[i]; + p = -p; + } + x->c[n - 1] = m * y->c[n - 2] / (n - 1.0); + o += p * x->c[n - 1]; + x->c[0] = 2.0 * o; + } +} + +int +main (void) +{ + struct S x, y; + double c[4] = { 10, 20, 30, 40 }, d[4], e[4] = { 118, 118, 118, 118 }; + + y.a = 10; + y.b = 6; + y.c = c; + x.c = d; + y.d = 3; + __builtin_memcpy (d, e, sizeof d); + foo (&x, &y); + if (d[0] != 0 || d[1] != 20 || d[2] != 10 || d[3] != -10) + __builtin_abort (); + y.d = 2; + __builtin_memcpy (d, e, sizeof d); + foo (&x, &y); + if (d[0] != 60 || d[1] != 20 || d[2] != -10 || d[3] != 118) + __builtin_abort (); + y.d = 1; + __builtin_memcpy (d, e, sizeof d); + foo (&x, &y); + if (d[0] != -20 || d[1] != -10 || d[2] != 118 || d[3] != 118) + __builtin_abort (); + y.d = 0; + __builtin_memcpy (d, e, sizeof d); + foo (&x, &y); + if (d[0] != 0 || d[1] != 118 || d[2] != 118 || d[3] != 118) + __builtin_abort (); + return 0; +} -- cgit v1.2.3