From: Richard Sandiford Date: Tue, 3 May 2011 07:51:13 +0000 (+0000) Subject: vect-strided-u16-i3.c: New test. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=539d6b4aec3bbbcacf918db6edb57fe7c65e54d8;p=gcc.git vect-strided-u16-i3.c: New test. gcc/testsuite/ * gcc.dg/vect/vect-strided-u16-i3.c: New test. From-SVN: r173296 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0a29bb2113c..d9094f09c47 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2011-05-03 Richard Sandiford + + * gcc.dg/vect/vect-strided-u16-i3.c: New test. + 2011-05-03 Richard Sandiford * lib/target-supports.exp (check_effective_target_vect_strided): diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-u16-i3.c b/gcc/testsuite/gcc.dg/vect/vect-strided-u16-i3.c new file mode 100644 index 00000000000..e423148407d --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-u16-i3.c @@ -0,0 +1,112 @@ +#include +#include "tree-vect.h" + +#define N 128 + +typedef struct { + unsigned short a; + unsigned short b; + unsigned short c; +} s; + +#define A(I) (I) +#define B(I) ((I) * 2) +#define C(I) ((unsigned short) ~((I) ^ 0x18)) + +void __attribute__ ((noinline)) +check1 (s *res) +{ + int i; + + for (i = 0; i < N; i++) + if (res[i].a != C (i) + || res[i].b != A (i) + || res[i].c != B (i)) + abort (); +} + +void __attribute__ ((noinline)) +check2 (unsigned short *res) +{ + int i; + + for (i = 0; i < N; i++) + if (res[i] != (unsigned short) (A (i) + B (i) + C (i))) + abort (); +} + +void __attribute__ ((noinline)) +check3 (s *res) +{ + int i; + + for (i = 0; i < N; i++) + if (res[i].a != i + || res[i].b != i + || res[i].c != i) + abort (); +} + +void __attribute__ ((noinline)) +check4 (unsigned short *res) +{ + int i; + + for (i = 0; i < N; i++) + if (res[i] != (unsigned short) (A (i) + B (i))) + abort (); +} + +void __attribute__ ((noinline)) +main1 (s *arr) +{ + int i; + s *ptr = arr; + s res1[N]; + unsigned short res2[N]; + + for (i = 0; i < N; i++) + { + res1[i].a = arr[i].c; + res1[i].b = arr[i].a; + res1[i].c = arr[i].b; + } + check1 (res1); + + for (i = 0; i < N; i++) + res2[i] = arr[i].a + arr[i].b + arr[i].c; + check2 (res2); + + for (i = 0; i < N; i++) + { + res1[i].a = i; + res1[i].b = i; + res1[i].c = i; + } + check3 (res1); + + for (i = 0; i < N; i++) + res2[i] = arr[i].a + arr[i].b; + check4 (res2); +} + +int main (void) +{ + int i; + s arr[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + arr[i].a = A (i); + arr[i].b = B (i); + arr[i].c = C (i); + } + main1 (arr); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 4 loops" 1 "vect" { target vect_strided3 } } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */