From 19b472cc70745b42fc74b1ef9883e7da1031f47b Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 8 Sep 2014 22:15:31 +0200 Subject: [PATCH] re PR tree-optimization/60196 (Incorrect compilation with -fwrapv and -ftree-vectorize) PR tree-optimization/60196 PR tree-optimization/63189 * gcc.dg/vect/pr63189.c: New test. * gcc.dg/vect/pr60196-1.c: New test. * gcc.dg/vect/pr60196-2.c: New test. From-SVN: r215025 --- gcc/testsuite/ChangeLog | 8 +++++++ gcc/testsuite/gcc.dg/vect/pr60196-1.c | 34 +++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/vect/pr60196-2.c | 33 ++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/vect/pr63189.c | 26 ++++++++++++++++++++ 4 files changed, 101 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/vect/pr60196-1.c create mode 100644 gcc/testsuite/gcc.dg/vect/pr60196-2.c create mode 100644 gcc/testsuite/gcc.dg/vect/pr63189.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cd4650c610a..cce4f264bde 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2014-09-08 Jakub Jelinek + + PR tree-optimization/60196 + PR tree-optimization/63189 + * gcc.dg/vect/pr63189.c: New test. + * gcc.dg/vect/pr60196-1.c: New test. + * gcc.dg/vect/pr60196-2.c: New test. + 2014-09-08 Bill Schmidt * gcc.target/powerpc/swaps-p8-16.c: New test. diff --git a/gcc/testsuite/gcc.dg/vect/pr60196-1.c b/gcc/testsuite/gcc.dg/vect/pr60196-1.c new file mode 100644 index 00000000000..10ed4afebdf --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr60196-1.c @@ -0,0 +1,34 @@ +/* PR tree-optimization/63189 */ +/* { dg-additional-options "-fwrapv" } */ +/* { dg-do run } */ + +#include "tree-vect.h" + +__attribute__((noinline, noclone)) static int +bar (const short *a, int len) +{ + int x; + int x1 = 0; + + for (x = 0; x < len; x++) + x1 += x * a[x]; + return x1; +} + +__attribute__((noinline, noclone)) void +foo (void) +{ + short stuff[9] = {1, 1, 1, 1, 1, 1, 1, 1, 1 }; + if (bar (stuff, 9) != 36) + abort (); +} + +int +main () +{ + check_vect (); + foo (); + return 0; +} + +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/pr60196-2.c b/gcc/testsuite/gcc.dg/vect/pr60196-2.c new file mode 100644 index 00000000000..b2059c20cd5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr60196-2.c @@ -0,0 +1,33 @@ +/* PR tree-optimization/63189 */ +/* { dg-do run } */ + +#include "tree-vect.h" + +static const short a[8] = {1, 1, 1, 1, 1, 1, 1, 1 }; +static const unsigned char b[8] = {0, 0, 0, 0, 0, 0, 0, 0 }; + +__attribute__((noinline, noclone)) static int +bar (void) +{ + int sum = 0, i; + for (i = 0; i < 8; ++i) + sum += a[i] * b[i]; + return sum; +} + +__attribute__((noinline, noclone)) void +foo (void) +{ + if (bar () != 0) + abort (); +} + +int +main () +{ + check_vect (); + foo (); + return 0; +} + +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/pr63189.c b/gcc/testsuite/gcc.dg/vect/pr63189.c new file mode 100644 index 00000000000..da6fba4b1b3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr63189.c @@ -0,0 +1,26 @@ +/* PR tree-optimization/63189 */ +/* { dg-do run } */ + +#include "tree-vect.h" + +short int d[16] = { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 }; + +__attribute__((noinline, noclone)) void +foo (void) +{ + int j, s = 0; + for (j = 0; j < 8; j++) + s += d[j] * j; + if (s != 7) + abort (); +} + +int +main () +{ + check_vect (); + foo (); + return 0; +} + +/* { dg-final { cleanup-tree-dump "vect" } } */ -- 2.30.2