1 |
149 |
jeremybenn |
/* { dg-do run { target powerpc*-*-* } } */
|
2 |
|
|
/* { dg-require-effective-target powerpc_altivec_ok } */
|
3 |
|
|
/* { dg-options "-maltivec" } */
|
4 |
|
|
|
5 |
|
|
/* Program to test PowerPC AltiVec instructions. */
|
6 |
|
|
|
7 |
|
|
#include <altivec.h>
|
8 |
|
|
#include "altivec_check.h"
|
9 |
|
|
|
10 |
|
|
extern void abort (void);
|
11 |
|
|
#define CHECK_IF(E) if(!(E)) abort()
|
12 |
|
|
|
13 |
|
|
vector int a1 = (vector int){ 100, 200, 300, 400 };
|
14 |
|
|
vector int a2 = (vector int){ 500, 600, 700, 800 };
|
15 |
|
|
vector int addi = (vector int){ 600, 800, 1000, 1200 };
|
16 |
|
|
vector int avgi = (vector int){ 300, 400, 500, 600 };
|
17 |
|
|
|
18 |
|
|
vector float f1 = (vector float){ 1.0, 2.0, 3.0, 4.0 };
|
19 |
|
|
vector float f2 = (vector float){ 5.0, 6.0, 7.0, 8.0 };
|
20 |
|
|
vector float f3;
|
21 |
|
|
vector float addf1 = (vector float){ 6.0, 8.0, 10.0, 12.0 };
|
22 |
|
|
vector float addf2 = (vector float){ 6.1, 8.1, 10.1, 12.1 };
|
23 |
|
|
vector float addf3 = (vector float){ 6.0, 8.0, 9.9, 12.1 };
|
24 |
|
|
vector int k;
|
25 |
|
|
vector float f, g, h;
|
26 |
|
|
|
27 |
|
|
int main ()
|
28 |
|
|
{
|
29 |
|
|
|
30 |
|
|
altivec_check(); /* Exit if AltiVec not available. */
|
31 |
|
|
|
32 |
|
|
k = vec_add (a1, a2);
|
33 |
|
|
CHECK_IF (vec_all_eq (addi, k));
|
34 |
|
|
CHECK_IF (vec_all_ge (addi, k));
|
35 |
|
|
CHECK_IF (vec_all_le (addi, k));
|
36 |
|
|
CHECK_IF (vec_any_eq (addi, k));
|
37 |
|
|
CHECK_IF (vec_any_ge (addi, k));
|
38 |
|
|
CHECK_IF (vec_any_le (addi, k));
|
39 |
|
|
CHECK_IF (!vec_any_ne (addi, k));
|
40 |
|
|
CHECK_IF (!vec_any_lt (addi, k));
|
41 |
|
|
CHECK_IF (!vec_any_gt (addi, k));
|
42 |
|
|
CHECK_IF (!vec_any_ne (addi, k));
|
43 |
|
|
CHECK_IF (!vec_any_lt (addi, k));
|
44 |
|
|
CHECK_IF (!vec_any_gt (addi, k));
|
45 |
|
|
|
46 |
|
|
k = vec_avg (a1, a2);
|
47 |
|
|
CHECK_IF (vec_all_eq (k, avgi));
|
48 |
|
|
|
49 |
|
|
h = vec_add (f1, f2);
|
50 |
|
|
CHECK_IF (vec_all_eq (h, addf1));
|
51 |
|
|
CHECK_IF (vec_all_ge (h, addf1));
|
52 |
|
|
CHECK_IF (vec_all_le (h, addf1));
|
53 |
|
|
CHECK_IF (vec_any_eq (h, addf1));
|
54 |
|
|
CHECK_IF (vec_any_ge (h, addf1));
|
55 |
|
|
CHECK_IF (vec_any_le (h, addf1));
|
56 |
|
|
CHECK_IF (!vec_any_ne (h, addf1));
|
57 |
|
|
CHECK_IF (!vec_any_lt (h, addf1));
|
58 |
|
|
CHECK_IF (!vec_any_gt (h, addf1));
|
59 |
|
|
CHECK_IF (!vec_any_ne (h, addf1));
|
60 |
|
|
CHECK_IF (!vec_any_lt (h, addf1));
|
61 |
|
|
CHECK_IF (!vec_any_gt (h, addf1));
|
62 |
|
|
|
63 |
|
|
CHECK_IF (vec_all_gt (addf2, addf1));
|
64 |
|
|
CHECK_IF (vec_any_gt (addf2, addf1));
|
65 |
|
|
CHECK_IF (vec_all_ge (addf2, addf1));
|
66 |
|
|
CHECK_IF (vec_any_ge (addf2, addf1));
|
67 |
|
|
CHECK_IF (vec_all_ne (addf2, addf1));
|
68 |
|
|
CHECK_IF (vec_any_ne (addf2, addf1));
|
69 |
|
|
CHECK_IF (!vec_all_lt (addf2, addf1));
|
70 |
|
|
CHECK_IF (!vec_any_lt (addf2, addf1));
|
71 |
|
|
CHECK_IF (!vec_all_le (addf2, addf1));
|
72 |
|
|
CHECK_IF (!vec_any_le (addf2, addf1));
|
73 |
|
|
CHECK_IF (!vec_all_eq (addf2, addf1));
|
74 |
|
|
CHECK_IF (!vec_any_eq (addf2, addf1));
|
75 |
|
|
|
76 |
|
|
CHECK_IF (vec_any_eq (addf3, addf1));
|
77 |
|
|
CHECK_IF (vec_any_ne (addf3, addf1));
|
78 |
|
|
CHECK_IF (vec_any_lt (addf3, addf1));
|
79 |
|
|
CHECK_IF (vec_any_le (addf3, addf1));
|
80 |
|
|
CHECK_IF (vec_any_gt (addf3, addf1));
|
81 |
|
|
CHECK_IF (vec_any_ge (addf3, addf1));
|
82 |
|
|
CHECK_IF (!vec_all_eq (addf3, addf1));
|
83 |
|
|
CHECK_IF (!vec_all_ne (addf3, addf1));
|
84 |
|
|
CHECK_IF (!vec_all_lt (addf3, addf1));
|
85 |
|
|
CHECK_IF (!vec_all_le (addf3, addf1));
|
86 |
|
|
CHECK_IF (!vec_all_gt (addf3, addf1));
|
87 |
|
|
CHECK_IF (!vec_all_ge (addf3, addf1));
|
88 |
|
|
|
89 |
|
|
CHECK_IF (vec_all_numeric (addf3));
|
90 |
|
|
CHECK_IF (vec_all_in (addf1, addf2));
|
91 |
|
|
|
92 |
|
|
CHECK_IF (vec_step (vector bool char) == 16);
|
93 |
|
|
CHECK_IF (vec_step (addf3) == 4);
|
94 |
|
|
|
95 |
|
|
return 0;
|
96 |
|
|
}
|