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-subscript-2.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
#define vector __attribute__((vector_size(sizeof(int)*4) ))
2
 
3
/* Check to make sure that we extract and insert the vector at the same
4
   location for vector subscripting (with constant indexes) and
5
   that vectors layout are the same as arrays. */
6
 
7
struct TV4
8
{
9
    vector int v;
10
};
11
 
12
typedef struct TV4 MYV4;
13
 
14
static inline MYV4 myfunc2( int x, int y, int z, int w )
15
{
16
    MYV4 temp;
17
    temp.v[0] = x;
18
    temp.v[1] = y;
19
    temp.v[2] = z;
20
    temp.v[3] = w;
21
    return temp;
22
}
23
MYV4 val3;
24
__attribute__((noinline)) void modify (void)
25
{
26
    val3 = myfunc2( 1, 2, 3, 4 );
27
}
28
int main( int argc, char* argv[] )
29
{
30
  int a[4];
31
  int i;
32
 
33
  /* Set up the vector.  */
34
  modify();
35
 
36
  /* Check the vector via the global variable.  */
37
  if (val3.v[0] != 1)
38
    __builtin_abort ();
39
  if (val3.v[1] != 2)
40
    __builtin_abort ();
41
  if (val3.v[2] != 3)
42
    __builtin_abort ();
43
  if (val3.v[3] != 4)
44
    __builtin_abort ();
45
 
46
  vector int a1 = val3.v;
47
 
48
   /* Check the vector via a local variable.  */
49
  if (a1[0] != 1)
50
    __builtin_abort ();
51
  if (a1[1] != 2)
52
    __builtin_abort ();
53
  if (a1[2] != 3)
54
    __builtin_abort ();
55
  if (a1[3] != 4)
56
    __builtin_abort ();
57
 
58
  __builtin_memcpy(a, &val3, sizeof(a));
59
   /* Check the vector via copying it to an array.  */
60
  for(i = 0; i < 4; i++)
61
    if (a[i] != i+1)
62
      __builtin_abort ();
63
 
64
 
65
  return 0;
66
}
67
 

powered by: WebSVN 2.1.0

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