- fixed comment: bs cannot be NULL anymore (and was never NULL previously)
[libfirm] / ir / be / test / fehler051.c
1 /************************************************************************
2 * Program:  maxps.c
3 * Function: Add 2 vectors (lying in memory) and store the result in
4 *           a another vector in memory.
5 *           Used as a test for the simd optimization.
6 * Author:   Andreas Schoesser
7 * Date:     2007-02-13
8 ************************************************************************/
9
10 #include <stdio.h>
11 #include <malloc.h>
12 #include <stdlib.h>
13
14 float maxps();
15 float ueberlappung();
16 //void vadd_loop();
17 //void array_test(int *a[]);
18
19 int main()
20 {
21         int a[5][5];
22
23         a[1][1] = 20;
24
25         srand(12345);
26
27         printf("1. vload -> vadd -> vstore\n===================\n\n");
28         ueberlappung();
29
30         printf("2. vload -> vadd -> vstore, multi dimensional array, in loop\n==========================================\n\n");
31         //      vadd_loop();
32
33         //      array_test(a);
34
35         return 0;
36 }
37
38 float ueberlappung()
39 {
40         float a[4], b[4], c[4], d[4];
41         float a0, a1, a2, a3;
42         float b0, b1, b2, b3;
43         float c0, c1, c2, c3;
44         float sp1, sp2;
45         int i;
46
47         for(i = 0; i < 4; i++)
48         {
49                 a[i] = rand() % 10;
50                 b[i] = rand() % 10;
51                 c[i] = rand() % 10;
52                 d[i] = rand() % 10;
53         }
54
55
56
57         // find vload 2x
58         sp1 = a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
59
60         // find vmul
61         sp2 = b[0] * d[0] + b[1] * d[1] + b[2] * d[2] + b[3] * d[3];
62
63         // Usage to prevent optimizations other than SIMD opt
64         for(i = 0; i < 4; i++)
65                 printf("%f %f %f %f\n", a[i], b[i], c[i], d[i]);
66         printf("\n");
67         return(sp1 + sp2);
68 }