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/vector-shift.c | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 gcc/testsuite/gcc.c-torture/execute/vector-shift.c (limited to 'gcc/testsuite/gcc.c-torture/execute/vector-shift.c') diff --git a/gcc/testsuite/gcc.c-torture/execute/vector-shift.c b/gcc/testsuite/gcc.c-torture/execute/vector-shift.c new file mode 100644 index 000000000..f52eb58a1 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/vector-shift.c @@ -0,0 +1,48 @@ + +#define vector __attribute__((vector_size(sizeof(int)*4) )) + +static vector int allones = {1, 1, 1, 1}; +static vector int allzeros = {0, 0, 0, 0}; +static vector int numbers = {0, 1, 2, 3}; +static vector int numbersleftshiftallones = {0, 2, 4, 6}; +static vector int numbersrightshiftallones = {0, 0, 1, 1}; + + +static vector unsigned int uallones = {1, 1, 1, 1}; +static vector unsigned int uallzeros = {0, 0, 0, 0}; +static vector unsigned int unumbers = {0, 1, 2, 3}; +static vector unsigned int unumbersleftshiftallones = {0, 2, 4, 6}; +static vector unsigned int unumbersrightshiftallones = {0, 0, 1, 1}; + +#define TEST(result, expected) \ +do { \ + typeof(result) result1 = result; \ + if(sizeof (result1) != sizeof (expected)) \ + __builtin_abort (); \ + if (__builtin_memcmp (&result1, &expected, sizeof(result1)) != 0) \ + __builtin_abort (); \ +}while (0); + +int main(void) +{ + vector int result; + TEST ((numbers << allzeros), numbers); + TEST ((numbers >> allzeros), numbers); + TEST((numbers << allones), numbersleftshiftallones); + TEST((numbers >> allones), numbersrightshiftallones); + /* Test left shift followed by a right shift, numbers should be back as + numbers are all small numbers and no lose of precision happens. */ + TEST((numbers << allones) >> allones, numbers); + + + + TEST ((unumbers << uallzeros), unumbers); + TEST ((unumbers >> uallzeros), unumbers); + TEST((unumbers << uallones), unumbersleftshiftallones); + TEST((unumbers >> uallones), unumbersrightshiftallones); + /* Test left shift followed by a right shift, numbers should be back as + numbers are all small numbers and no lose of precision happens. */ + TEST((unumbers << uallones) >> uallones, unumbers); + + return 0; +} -- cgit v1.2.3