OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [vector-shift.c] - Blame information for rev 774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 688 jeremybenn
 
2
#define vector __attribute__((vector_size(sizeof(int)*4) ))
3
 
4
static vector int allones = {1, 1, 1, 1};
5
static vector int allzeros = {0, 0, 0, 0};
6
static vector int numbers = {0, 1, 2, 3};
7
static vector int numbersleftshiftallones = {0, 2, 4, 6};
8
static vector int numbersrightshiftallones = {0, 0, 1, 1};
9
 
10
 
11
static vector unsigned int uallones = {1, 1, 1, 1};
12
static vector unsigned int uallzeros = {0, 0, 0, 0};
13
static vector unsigned int unumbers = {0, 1, 2, 3};
14
static vector unsigned int unumbersleftshiftallones = {0, 2, 4, 6};
15
static vector unsigned int unumbersrightshiftallones = {0, 0, 1, 1};
16
 
17
#define TEST(result, expected) \
18
do { \
19
  typeof(result) result1 = result; \
20
  if(sizeof (result1) != sizeof (expected)) \
21
    __builtin_abort (); \
22
  if (__builtin_memcmp (&result1, &expected, sizeof(result1)) != 0) \
23
    __builtin_abort (); \
24
}while (0);
25
 
26
int main(void)
27
{
28
  vector int result;
29
  TEST ((numbers << allzeros), numbers);
30
  TEST ((numbers >> allzeros), numbers);
31
  TEST((numbers << allones), numbersleftshiftallones);
32
  TEST((numbers >> allones), numbersrightshiftallones);
33
  /* Test left shift followed by a right shift, numbers should be back as
34
     numbers are all small numbers and no lose of precision happens.   */
35
  TEST((numbers << allones) >> allones, numbers);
36
 
37
 
38
 
39
  TEST ((unumbers << uallzeros), unumbers);
40
  TEST ((unumbers >> uallzeros), unumbers);
41
  TEST((unumbers << uallones), unumbersleftshiftallones);
42
  TEST((unumbers >> uallones), unumbersrightshiftallones);
43
  /* Test left shift followed by a right shift, numbers should be back as
44
     numbers are all small numbers and no lose of precision happens.   */
45
  TEST((unumbers << uallones) >> uallones, unumbers);
46
 
47
  return 0;
48
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.