OSDN Git Service

PR c/20740
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / altivec-1.c
1 /* { dg-do run { target powerpc*-*-* } } */
2 /* { dg-xfail-if "" { "powerpc-*-eabispe*" "powerpc-ibm-aix*" } { "-maltivec" } { "" } } */
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
12 vector int a1 = { 100, 200, 300, 400 };
13 vector int a2 = { 500, 600, 700, 800 };
14 vector int addi = { 600, 800, 1000, 1200 };
15 vector int avgi = { 300, 400, 500, 600 };
16
17 vector float f1 = { 1.0, 2.0, 3.0, 4.0 };  
18 vector float f2 = { 5.0, 6.0, 7.0, 8.0 };
19 vector float f3;
20 vector float addf = { 6.0, 8.0, 10.0, 12.0 };
21
22 vector int k;
23 vector float f, g, h;
24
25 int main ()
26 {
27   altivec_check();  /* Exits if AltiVec not supported */
28
29   k = vec_add (a1, a2);
30   if (!vec_all_eq (addi, k))
31     abort ();
32
33   k = vec_avg (a1, a2);
34   if (!vec_all_eq (k, avgi))
35     abort ();
36
37   h = vec_add (f1, f2);
38   if (!vec_all_eq (h, addf))
39     abort ();
40
41   return 0;
42 }