fehler120: Backend discards float->int Conv for shift amount.
[libfirm] / ir / be / test / simd1.c
1 #include <stdio.h>
2
3 #define ITERS 8
4
5 unsigned int sse8_16bit_c(      const short * b1,
6                                 const short * b2,
7                                 const unsigned int stride)
8 {
9         int i;
10         int sse = 0;
11
12         for (i=0; i<ITERS; i++) {
13                 sse += (b1[0] - b2[0])*(b1[0] - b2[0]);
14                 sse += (b1[1] - b2[1])*(b1[1] - b2[1]);
15                 sse += (b1[2] - b2[2])*(b1[2] - b2[2]);
16                 sse += (b1[3] - b2[3])*(b1[3] - b2[3]);
17                 sse += (b1[4] - b2[4])*(b1[4] - b2[4]);
18                 sse += (b1[5] - b2[5])*(b1[5] - b2[5]);
19                 sse += (b1[6] - b2[6])*(b1[6] - b2[6]);
20                 sse += (b1[7] - b2[7])*(b1[7] - b2[7]);
21
22                 b1 = (const short*)((char*)b1+stride);
23                 b2 = (const short*)((char*)b2+stride);
24         }
25
26         return(sse);
27 }
28
29 #define STRIDE 16
30 //#define MAX 65536
31 #define MAX (ITERS * STRIDE)
32
33 int main(int argc, char** argv){
34         short cur[MAX];
35         short ref[MAX];
36         int sum = 0;
37         int numofruns = 10;
38         int i,ii;
39
40         if(argc > 1) {
41                 numofruns = atoi(argv[1]);
42         }
43
44         for (i=0;i < numofruns; i++){
45                 // Reset cache. Alles andere ist unrealistisch.
46                 for(ii = 0; ii < MAX; ++ii) {
47                         cur[ii]=(ii)&0xff;
48                         ref[ii]=(ii+i+3)&0xff;
49                 }
50                 sum = sse8_16bit_c(cur, ref, STRIDE);
51                 if(i < 10)
52                         printf("sum[%i] = %i\n",i, sum);
53         }
54
55         return 0 ;
56 }