OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [vector-compare-1.c] - Blame information for rev 688

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 688 jeremybenn
#define vector(elcount, type)  \
2
__attribute__((vector_size((elcount)*sizeof(type)))) type
3
 
4
#define check_compare(count, res, i0, i1, op, fmt) \
5
do { \
6
    int __i; \
7
    for (__i = 0; __i < count; __i ++) { \
8
      if ((res)[__i] != ((i0)[__i] op (i1)[__i] ? -1 : 0)) \
9
        { \
10
            __builtin_printf ("%i != ((" fmt " " #op " " fmt " ? -1 : 0) ", \
11
                              (res)[__i], (i0)[__i], (i1)[__i]); \
12
            __builtin_abort (); \
13
        } \
14
    } \
15
} while (0)
16
 
17
#define test(count, v0, v1, res, fmt); \
18
do { \
19
    res = (v0 > v1); \
20
    check_compare (count, res, v0, v1, >, fmt); \
21
    res = (v0 < v1); \
22
    check_compare (count, res, v0, v1, <, fmt); \
23
    res = (v0 >= v1); \
24
    check_compare (count, res, v0, v1, >=, fmt); \
25
    res = (v0 <= v1); \
26
    check_compare (count, res, v0, v1, <=, fmt); \
27
    res = (v0 == v1); \
28
    check_compare (count, res, v0, v1, ==, fmt); \
29
    res = (v0 != v1); \
30
    check_compare (count, res, v0, v1, !=, fmt); \
31
} while (0)
32
 
33
 
34
int main (int argc, char *argv[]) {
35
#define INT  int
36
    vector (4, INT) i0;
37
    vector (4, INT) i1;
38
    vector (4, int) ires;
39
    int i;
40
 
41
    i0 = (vector (4, INT)){argc, 1,  2,  10};
42
    i1 = (vector (4, INT)){0, 3, 2, (INT)-23};
43
    test (4, i0, i1, ires, "%i");
44
#undef INT
45
 
46
#define INT unsigned int
47
    vector (4, int) ures;
48
    vector (4, INT) u0;
49
    vector (4, INT) u1;
50
 
51
    u0 = (vector (4, INT)){argc, 1,  2,  10};
52
    u1 = (vector (4, INT)){0, 3, 2, (INT)-23};
53
    test (4, u0, u1, ures, "%u");
54
#undef INT
55
 
56
 
57
#define SHORT short
58
    vector (8, SHORT) s0;
59
    vector (8, SHORT) s1;
60
    vector (8, short) sres;
61
 
62
    s0 = (vector (8, SHORT)){argc, 1,  2,  10,  6, 87, (SHORT)-5, 2};
63
    s1 = (vector (8, SHORT)){0, 3, 2, (SHORT)-23, 12, 10, (SHORT)-2, 0};
64
    test (8, s0, s1, sres, "%i");
65
#undef SHORT
66
 
67
#define SHORT unsigned short
68
    vector (8, SHORT) us0;
69
    vector (8, SHORT) us1;
70
    vector (8, short) usres;
71
 
72
    us0 = (vector (8, SHORT)){argc, 1,  2,  10,  6, 87, (SHORT)-5, 2};
73
    us1 = (vector (8, SHORT)){0, 3, 2, (SHORT)-23, 12, 10, (SHORT)-2, 0};
74
    test (8, us0, us1, usres, "%u");
75
#undef SHORT
76
 
77
#define CHAR signed char
78
    vector (16, CHAR) c0;
79
    vector (16, CHAR) c1;
80
    vector (16, signed char) cres;
81
 
82
    c0 = (vector (16, CHAR)){argc, 1,  2,  10,  6, 87, (CHAR)-5, 2, \
83
                             argc, 1,  2,  10,  6, 87, (CHAR)-5, 2 };
84
 
85
    c1 = (vector (16, CHAR)){0, 3, 2, (CHAR)-23, 12, 10, (CHAR)-2, 0, \
86
                             0, 3, 2, (CHAR)-23, 12, 10, (CHAR)-2, 0};
87
    test (16, c0, c1, cres, "%i");
88
#undef CHAR
89
 
90
#define CHAR unsigned char
91
    vector (16, CHAR) uc0;
92
    vector (16, CHAR) uc1;
93
    vector (16, signed char) ucres;
94
 
95
    uc0 = (vector (16, CHAR)){argc, 1,  2,  10,  6, 87, (CHAR)-5, 2, \
96
                             argc, 1,  2,  10,  6, 87, (CHAR)-5, 2 };
97
 
98
    uc1 = (vector (16, CHAR)){0, 3, 2, (CHAR)-23, 12, 10, (CHAR)-2, 0, \
99
                             0, 3, 2, (CHAR)-23, 12, 10, (CHAR)-2, 0};
100
    test (16, uc0, uc1, ucres, "%u");
101
#undef CHAR
102
/* Float comparison.  */
103
    vector (4, float) f0;
104
    vector (4, float) f1;
105
    __typeof (f0 == f1) ifres;
106
 
107
    f0 = (vector (4, float)){(float)argc, 1.,  2.,  10.};
108
    f1 = (vector (4, float)){0., 3., 2., (float)-23};
109
    test (4, f0, f1, ifres, "%f");
110
 
111
/* Double comparison.  */
112
    vector (2, double) d0;
113
    vector (2, double) d1;
114
    __typeof (d0 == d1) idres;
115
 
116
    d0 = (vector (2, double)){(double)argc,  10.};
117
    d1 = (vector (2, double)){0., (double)-23};
118
    test (2, d0, d1, idres, "%f");
119
 
120
 
121
    return 0;
122
}
123
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.