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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [torture/] [arm-fp16-ops.h] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* Test various operators on __fp16 and mixed __fp16/float operands.  */
2
 
3
#include <assert.h>
4
 
5
#define CHECK(e,r) assert ((e) == r)
6
#define CHECK2(e,r) (assert ((e) == r), temp = (e), assert (temp == r))
7
#define TEST(e) assert (e)
8
#define TESTNOT(e) assert (!(e))
9
 
10
volatile __fp16 h0 = 0.0;
11
volatile __fp16 h1 = 1.0;
12
volatile __fp16 h42 = 42.0;
13
volatile __fp16 hm2 = -2.0;
14
volatile __fp16 temp;
15
 
16
volatile float f0 = 0.0;
17
volatile float f1 = 1.0;
18
volatile float f42 = 42.0;
19
volatile float fm2 = -2.0;
20
 
21
int main (void)
22
{
23
  TEST (h1);
24
  TESTNOT (h0);
25
  TEST (!h0);
26
  TESTNOT (!h1);
27
 
28
  CHECK2 (-h1, -1.0);
29
  CHECK2 (+h1, 1.0);
30
 
31
  CHECK (h1++, 1.0);
32
  CHECK (h1, 2.0);
33
  CHECK (++h1, 3.0);
34
  CHECK (h1, 3.0);
35
 
36
  CHECK (--h1, 2.0);
37
  CHECK (h1, 2.0);
38
  CHECK (h1--, 2.0);
39
  CHECK (h1, 1.0);
40
 
41
  CHECK2 (h42 * hm2, -84.0);
42
  CHECK2 (h42 * (__fp16) -2.0, -84.0);
43
  CHECK2 (h42 * fm2, -84.0);
44
  CHECK2 (f42 * hm2, -84.0);
45
 
46
  CHECK2 (h42 / hm2, -21.0);
47
  CHECK2 (h42 / (__fp16) -2.0, -21.0);
48
  CHECK2 (h42 / fm2, -21.0);
49
  CHECK2 (f42 / hm2, -21.0);
50
 
51
  CHECK2 (hm2 + h42, 40.0);
52
  CHECK2 ((__fp16)-2.0 + h42, 40.0);
53
  CHECK2 (hm2 + f42, 40.0);
54
  CHECK2 (fm2 + h42, 40.0);
55
 
56
  CHECK2 (hm2 - h42, -44.0);
57
  CHECK2 ((__fp16)-2.0 - h42, -44.0);
58
  CHECK2 (hm2 - f42, -44.0);
59
  CHECK2 (fm2 - h42, -44.0);
60
 
61
  TEST (hm2 < h42);
62
  TEST (hm2 < (__fp16)42.0);
63
  TEST (hm2 < f42);
64
  TEST (fm2 < h42);
65
 
66
  TEST (h42 > hm2);
67
  TEST ((__fp16)42.0 > hm2);
68
  TEST (h42 > fm2);
69
  TEST (f42 > hm2);
70
 
71
  TEST (hm2 <= h42);
72
  TEST (hm2 <= (__fp16)42.0);
73
  TEST (hm2 <= f42);
74
  TEST (fm2 <= h42);
75
 
76
  TEST (h42 >= hm2);
77
  TEST (h42 >= (__fp16)-2.0);
78
  TEST (h42 >= fm2);
79
  TEST (f42 >= hm2);
80
 
81
  TESTNOT (h1 == hm2);
82
  TEST (h1 == h1);
83
  TEST (h1 == (__fp16)1.0);
84
  TEST (h1 == f1);
85
  TEST (f1 == h1);
86
 
87
  TEST (h1 != hm2);
88
  TESTNOT (h1 != h1);
89
  TESTNOT (h1 != (__fp16)1.0);
90
  TESTNOT (h1 != f1);
91
  TESTNOT (f1 != h1);
92
 
93
  CHECK2 ((h1 ? hm2 : h42), -2.0);
94
  CHECK2 ((h0 ? hm2 : h42), 42.0);
95
 
96
  CHECK (h0 = h42, 42.0);
97
  CHECK (h0, 42.0);
98
  CHECK (h0 = (__fp16)-2.0, -2.0);
99
  CHECK (h0, -2.0);
100
  CHECK (h0 = f0, 0.0);
101
  CHECK (h0, 0.0);
102
 
103
  CHECK (h0 += h1, 1.0);
104
  CHECK (h0, 1.0);
105
  CHECK (h0 += (__fp16)1.0, 2.0);
106
  CHECK (h0, 2.0);
107
  CHECK (h0 += fm2, 0.0);
108
  CHECK (h0, 0.0);
109
 
110
  CHECK (h0 -= h1, -1.0);
111
  CHECK (h0, -1.0);
112
  CHECK (h0 -= (__fp16)1.0, -2.0);
113
  CHECK (h0, -2.0);
114
  CHECK (h0 -= fm2, 0.0);
115
  CHECK (h0, 0.0);
116
 
117
  h0 = hm2;
118
  CHECK (h0 *= hm2, 4.0);
119
  CHECK (h0, 4.0);
120
  CHECK (h0 *= (__fp16)-2.0, -8.0);
121
  CHECK (h0, -8.0);
122
  CHECK (h0 *= fm2, 16.0);
123
  CHECK (h0, 16.0);
124
 
125
  CHECK (h0 /= hm2, -8.0);
126
  CHECK (h0, -8.0);
127
  CHECK (h0 /= (__fp16)-2.0, 4.0);
128
  CHECK (h0, 4.0);
129
  CHECK (h0 /= fm2, -2.0);
130
  CHECK (h0, -2.0);
131
 
132
  CHECK ((h0, h1), 1.0);
133
 
134
  return 0;
135
}

powered by: WebSVN 2.1.0

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