summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/powerpc/altivec-1.c
blob: b1809fe2c9c240de71815404c3ef57637ab3ba46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */
/* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */
/* { dg-require-effective-target powerpc_altivec_ok } */
/* { dg-options "-maltivec" } */

/* Program to test PowerPC AltiVec instructions.  */

#include <altivec.h>

extern void abort (void);

vector int a1 = { 100, 200, 300, 400 };
vector int a2 = { 500, 600, 700, 800 };
vector int addi = { 600, 800, 1000, 1200 };
vector int avgi = { 300, 400, 500, 600 };

vector float f1 = { 1.0, 2.0, 3.0, 4.0 };  
vector float f2 = { 5.0, 6.0, 7.0, 8.0 };
vector float f3;
vector float addf = { 6.0, 8.0, 10.0, 12.0 };

vector int k;
vector float f, g, h;

int main ()
{
  k = vec_add (a1, a2);
  if (!vec_all_eq (addi, k))
    abort ();

  k = vec_avg (a1, a2);
  if (!vec_all_eq (k, avgi))
    abort ();

  h = vec_add (f1, f2);
  if (!vec_all_eq (h, addf))
    abort ();

  return 0;
}