summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/vmx/7-01a.c
blob: c09835b437e061cb42f095e1f8f5005ee293336d (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
/* { dg-do compile } */
#include <altivec.h>
extern vector signed short image[];
extern vector signed short band[];

#define load(a,b) vec_ld((b)*16, a)
#define store(v,a,b) vec_st(v,(b)*16,a)

void
haar (vector signed char a, vector signed char b, vector signed char c,
      vector signed char d, unsigned int N, int XX)
{
  unsigned int i;
  vector unsigned char high, low;
  vector signed int zero = ((vector signed int){0,0,0,0});

  for (i = 0; i < N; i++) {
    high = (vector unsigned char) (vec_vmrghh (load(image, i+XX),
					       load(image, i)));
    low = (vector unsigned char) (vec_vmrglh (load(image, i+XX),
					      load(image, i)));

    store (vec_vpkswss (vec_vmsummbm (a, high, zero),
			vec_vmsummbm (a, low, zero)),
	   band, i);
    store (vec_vpkswss (vec_vmsummbm (b, high, zero),
			vec_vmsummbm (b, low, zero)),
	   band, i+1);
    store(vec_vpkswss (vec_vmsummbm (c, high, zero),
		       vec_vmsummbm (c, low, zero)),
	  band, i+2);
    store(vec_vpkswss (vec_vmsummbm (d, high, zero),
		       vec_vmsummbm (d, low, zero)),
	  band, i+3);
  }
}