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-1.c] - Blame information for rev 801

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

Line No. Rev Author Line
1 688 jeremybenn
/* dg-do run */
2
#define vector __attribute__((vector_size(sizeof(int)*4) ))
3
 
4
/* Check to make sure that we extract and insert the vector at the same
5
   location for vector subscripting and that vectors layout are the same
6
   as arrays. */
7
 
8
struct TV4
9
{
10
    vector int v;
11
};
12
 
13
typedef struct TV4 MYV4;
14
static inline int *f(MYV4 *a, int i)
15
{
16
  return &(a->v[i]);
17
}
18
 
19
static inline MYV4 myfunc2( int x, int y, int z, int w )
20
{
21
    MYV4 temp;
22
    *f(&temp, 0 ) = x;
23
    *f(&temp, 1 ) = y;
24
    *f(&temp, 2 ) = z;
25
    *f(&temp, 3 ) = w;
26
    return temp;
27
}
28
 
29
MYV4 val3;
30
 
31
__attribute__((noinline)) void modify (void)
32
{
33
    val3 = myfunc2( 1, 2, 3, 4 );
34
}
35
 
36
int main( int argc, char* argv[] )
37
{
38
  int a[4];
39
  int i;
40
 
41
  modify();
42
 
43
  if (*f(&val3, 0 ) != 1)
44
    __builtin_abort ();
45
  if (*f(&val3, 1 ) != 2)
46
    __builtin_abort ();
47
  if (*f(&val3, 2 ) != 3)
48
    __builtin_abort ();
49
  if (*f(&val3, 3 ) != 4)
50
    __builtin_abort ();
51
 
52
  __builtin_memcpy (a, &val3, sizeof(a));
53
  for(i = 0; i < 4; i++)
54
    if (a[i] != i+1)
55
      __builtin_abort ();
56
 
57
 
58
  return 0;
59
}
60
 

powered by: WebSVN 2.1.0

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