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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.target/] [powerpc/] [altivec-3.c] - Blame information for rev 867

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

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

powered by: WebSVN 2.1.0

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