OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.target/] [powerpc/] [altivec-3.c] - Blame information for rev 378

Go to most recent revision | 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
 
6
extern void exit (int);
7
extern void abort (void);
8
 
9
typedef int int4 __attribute__ ((vector_size (16)));
10
typedef float float4 __attribute__ ((vector_size (16)));
11
 
12
int4 a1 = (int4) { 100, 200, 300, 400 };
13
int4 a2 = (int4) { 500, 600, 700, 800 };
14
 
15
float4 f1 = (float4) { 1.0, 2.0, 3.0, 4.0 };
16
float4 f2 = (float4) { 5.0, 6.0, 7.0, 8.0 };
17
 
18
int i3[4] __attribute__((aligned(16)));
19
int j3[4] __attribute__((aligned(16)));
20
float h3[4] __attribute__((aligned(16)));
21
float g3[4] __attribute__((aligned(16)));
22
 
23
#define vec_store(dst, src) \
24
  __builtin_vec_st (src, 0, (__typeof__ (src) *) dst)
25
 
26
#define vec_add_int4(x, y) \
27
  __builtin_altivec_vaddsws (x, y)
28
 
29
#define vec_add_float4(x, y) \
30
  __builtin_altivec_vaddfp (x, y)
31
 
32
#define my_abs(x) (x > 0.0F ? x : -x)
33
 
34
void
35
compare_int4 (int *a, int *b)
36
{
37
  int i;
38
 
39
  for (i = 0; i < 4; ++i)
40
    if (a[i] != b[i])
41
      abort ();
42
}
43
 
44
void
45
compare_float4 (float *a, float *b)
46
{
47
  int i;
48
 
49
  for (i = 0; i < 4; ++i)
50
    if (my_abs(a[i] - b[i]) >= 1.0e-6)
51
      abort ();
52
}
53
 
54
void
55
main1 ()
56
{
57
  int loc1 = 600, loc2 = 800;
58
  int4 a3 = (int4) { loc1, loc2, 1000, 1200 };
59
  int4 itmp;
60
  double locf = 12.0;
61
  float4 f3 = (float4) { 6.0, 8.0, 10.0, 12.0 };
62
  float4 ftmp;
63
 
64
  vec_store (i3, a3);
65
  itmp = vec_add_int4 (a1, a2);
66
  vec_store (j3, itmp);
67
  compare_int4 (i3, j3);
68
 
69
  vec_store (g3, f3);
70
  ftmp = vec_add_float4 (f1, f2);
71
  vec_store (h3, ftmp);
72
  compare_float4 (g3, h3);
73
}
74
 
75
int
76
main ()
77
{
78
  main1 ();
79
  exit (0);
80
}

powered by: WebSVN 2.1.0

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