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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.target/] [powerpc/] [altivec-cell-2.c] - Blame information for rev 826

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 322 jeremybenn
/* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */
2
/* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */
3
/* { dg-require-effective-target powerpc_altivec_ok } */
4
/* { dg-options "-maltivec" } */
5
/* Test the vec_extract VMX intrinsics.  */
6
#include <altivec.h>
7
 
8
extern void abort (void);
9
 
10
vector int a = {0, 1, 2, 3};
11
vector short b = {0, 1, 2, 3, 4, 5, 6, 7};
12
 
13
int f(vector int a, int b)
14
{
15
  return vec_extract (a, b);
16
}
17
 
18
int f0 (vector int a)
19
{
20
  return vec_extract (a, 0);
21
}
22
int f1 (vector int a)
23
{
24
  return vec_extract (a, 1);
25
}
26
int f2 (vector int a)
27
{
28
  return vec_extract (a, 2);
29
}
30
int f3 (vector int a)
31
{
32
  return vec_extract (a, 3);
33
}
34
int f4 (vector int a)
35
{
36
  return vec_extract (a, 4);
37
}
38
 
39
int g(vector short a, int b)
40
{
41
  return vec_extract (a, b);
42
}
43
 
44
int g0 (vector short a)
45
{
46
  return vec_extract (a, 0);
47
}
48
int g1 (vector short a)
49
{
50
  return vec_extract (a, 1);
51
}
52
int g2 (vector short a)
53
{
54
  return vec_extract (a, 2);
55
}
56
int g3 (vector short a)
57
{
58
  return vec_extract (a, 3);
59
}
60
 
61
int g4 (vector short a)
62
{
63
  return vec_extract (a, 4);
64
}
65
int g5 (vector short a)
66
{
67
  return vec_extract (a, 5);
68
}
69
int g6 (vector short a)
70
{
71
  return vec_extract (a, 6);
72
}
73
int g7 (vector short a)
74
{
75
  return vec_extract (a, 7);
76
}
77
int g8 (vector short a)
78
{
79
  return vec_extract (a, 8);
80
}
81
int main1(void) __attribute__((noinline));
82
int main1(void)
83
{
84
  int i;
85
  /* Check vec_extract with a non constant element numbering */
86
  for(i=0;i<10;i++)
87
    {
88
      if (f(a, i) != (i&0x3))
89
        abort ();
90
    }
91
 
92
  /* Check vec_extract with a constant element numbering */
93
  if (f0(a) != 0)
94
    abort ();
95
  if (f1(a) != 1)
96
    abort ();
97
  if (f2(a) != 2)
98
    abort ();
99
  if (f3(a) != 3)
100
    abort ();
101
  /* Check that vec_extract works with a constant element higher than
102
     the number of elements.  */
103
  if (f4(a) != 0)
104
    abort ();
105
 
106
  /* Check vec_extract with a non constant element numbering */
107
  for(i=0;i<10;i++)
108
    {
109
      if (g(b, i) != (i&0x7))
110
        abort ();
111
    }
112
 
113
  /* Check vec_extract with a constant element numbering */
114
  if (g0(b) != 0)
115
    abort ();
116
  if (g1(b) != 1)
117
    abort ();
118
  if (g2(b) != 2)
119
    abort ();
120
  if (g3(b) != 3)
121
    abort ();
122
  if (g4(b) != 4)
123
    abort ();
124
  if (g5(b) != 5)
125
    abort ();
126
  if (g6(b) != 6)
127
    abort ();
128
  if (g7(b) != 7)
129
    abort ();
130
  /* Check that vec_extract works with a constant element higher than
131
     the number of elements.  */
132
  if (g8(b) != 0)
133
    abort ();
134
 
135
  return 0;
136
}
137
 
138
int main(void)
139
{
140
  return main1 ();
141
}

powered by: WebSVN 2.1.0

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