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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [c-c++-common/] [dfp/] [pr39902.c] - Blame information for rev 709

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

Line No. Rev Author Line
1 686 jeremybenn
/* Check that optimizations like (x * 1) to x, or (x * -1) to -x,
2
   do not apply to decimal float computations where trailing zeroes
3
   are significant.  */
4
 
5
#include "dfp-dbg.h"
6
 
7
#define COMPARE32(A,B) \
8
  A.i == B.i
9
 
10
#define COMPARE64(A,B) \
11
  A.i[0] == B.i[0] && A.i[1] == B.i[1]
12
 
13
#define COMPARE128(A,B) \
14
  A.i[0] == B.i[0] && A.i[1] == B.i[1] && A.i[2] == B.i[2] && A.i[3] == B.i[3]
15
 
16
typedef union {
17
  _Decimal32 d;
18
  unsigned int i;
19
} u32;
20
 
21
typedef union {
22
  _Decimal64 d;
23
  unsigned int i[2];
24
} u64;
25
 
26
typedef union {
27
  _Decimal128 d;
28
  unsigned int i[4];
29
} u128;
30
 
31
volatile u32 p32_1;
32
volatile u32 p32_1_0;
33
volatile u32 p32_2_0;
34
volatile u32 m32_1;
35
volatile u32 m32_1_0;
36
volatile u32 m32_2_0;
37
volatile u32 a32;
38
 
39
volatile u64 p64_1;
40
volatile u64 p64_1_0;
41
volatile u64 p64_2_0;
42
volatile u64 m64_1;
43
volatile u64 m64_1_0;
44
volatile u64 m64_2_0;
45
volatile u64 a64;
46
 
47
volatile u128 p128_1;
48
volatile u128 p128_1_0;
49
volatile u128 p128_2_0;
50
volatile u128 m128_1;
51
volatile u128 m128_1_0;
52
volatile u128 m128_2_0;
53
volatile u128 a128;
54
 
55
void
56
init32 (void)
57
{
58
  p32_1.d = 1.DF;
59
  p32_1_0.d = 1.0DF;
60
  p32_2_0.d = 2.0DF;
61
  m32_1.d = -1.DF;
62
  m32_1_0.d = -1.0DF;
63
  m32_2_0.d = -2.0DF;
64
}
65
 
66
void
67
init64 (void)
68
{
69
  p64_1.d = 1.DD;
70
  p64_1_0.d = 1.0DD;
71
  p64_2_0.d = 2.0DD;
72
  m64_1.d = -1.DD;
73
  m64_1_0.d = -1.0DD;
74
  m64_2_0.d = -2.0DD;
75
}
76
 
77
void
78
init128 (void)
79
{
80
  p128_1.d = 1.DL;
81
  p128_1_0.d = 1.0DL;
82
  p128_2_0.d = 2.0DL;
83
  m128_1.d = -1.DL;
84
  m128_1_0.d = -1.0DL;
85
  m128_2_0.d = -2.0DL;
86
}
87
 
88
void
89
doit32 (void)
90
{
91
  /* Multiplying by a value with no trailing zero should not change the
92
     quantum exponent.  */
93
 
94
  a32.d = p32_2_0.d * p32_1.d;
95
  if (! (COMPARE32 (a32, p32_2_0)))
96
    FAILURE
97
 
98
  a32.d = p32_2_0.d * 1.DF;
99
  if (! (COMPARE32 (a32, p32_2_0)))
100
    FAILURE
101
 
102
  a32.d = p32_2_0.d * m32_1.d;
103
  if (! (COMPARE32 (a32, m32_2_0)))
104
    FAILURE
105
 
106
  a32.d = p32_2_0.d * -1.DF;
107
  if (! (COMPARE32 (a32, m32_2_0)))
108
    FAILURE
109
 
110
  /* Multiplying by a value with a trailing zero should change the
111
     quantum exponent.  */
112
 
113
  a32.d = p32_2_0.d * p32_1_0.d;
114
  if (COMPARE32 (a32, p32_2_0))
115
    FAILURE
116
 
117
  a32.d = p32_2_0.d * 1.0DF;
118
  if (COMPARE32 (a32, p32_2_0))
119
    FAILURE
120
 
121
  a32.d = p32_2_0.d * m32_1_0.d;
122
  if (COMPARE32 (a32, m32_2_0))
123
    FAILURE
124
 
125
  a32.d = p32_2_0.d * -1.0DF;
126
  if (COMPARE32 (a32, m32_2_0))
127
    FAILURE
128
}
129
 
130
void
131
doit64 (void)
132
{
133
  /* Multiplying by a value with no trailing zero should not change the
134
     quantum exponent.  */
135
 
136
  a64.d = p64_2_0.d * p64_1.d;
137
  if (! (COMPARE64 (a64, p64_2_0)))
138
    FAILURE
139
 
140
  a64.d = p64_2_0.d * 1.DD;
141
  if (! (COMPARE64 (a64, p64_2_0)))
142
    FAILURE
143
 
144
  a64.d = p64_2_0.d * m64_1.d;
145
  if (! (COMPARE64 (a64, m64_2_0)))
146
    FAILURE
147
 
148
  a64.d = p64_2_0.d * -1.DD;
149
  if (! (COMPARE64 (a64, m64_2_0)))
150
    FAILURE
151
 
152
  /* Multiplying by a value with a trailing zero should change the
153
     quantum exponent.  */
154
 
155
  a64.d = p64_2_0.d * p64_1_0.d;
156
  if (COMPARE64 (a64, p64_2_0))
157
    FAILURE
158
 
159
  a64.d = p64_2_0.d * 1.0DD;
160
  if (COMPARE64 (a64, p64_2_0))
161
    FAILURE
162
 
163
  a64.d = p64_2_0.d * m64_1_0.d;
164
  if (COMPARE64 (a64, m64_2_0))
165
    FAILURE
166
 
167
  a64.d = p64_2_0.d * -1.0DD;
168
  if (COMPARE64 (a64, m64_2_0))
169
    FAILURE
170
}
171
 
172
void
173
doit128 (void)
174
{
175
  /* Multiplying by a value with no trailing zero should not change the
176
     quantum exponent.  */
177
 
178
  a128.d = p128_2_0.d * p128_1_0.d;
179
  if (COMPARE128 (a128, p128_2_0))
180
    FAILURE
181
 
182
  a128.d = p128_2_0.d * 1.0DL;
183
  if (COMPARE128 (a128, p128_2_0))
184
    FAILURE
185
 
186
  a128.d = p128_2_0.d * m128_1_0.d;
187
  if (COMPARE128 (a128, m128_2_0))
188
    FAILURE
189
 
190
  a128.d = p128_2_0.d * -1.0DL;
191
  if (COMPARE128 (a128, m128_2_0))
192
    FAILURE
193
 
194
  /* Multiplying by a value with a trailing zero should change the
195
     quantum exponent.  */
196
 
197
  a128.d = p128_2_0.d * p128_1.d;
198
  if (! (COMPARE128 (a128, p128_2_0)))
199
    FAILURE
200
 
201
  a128.d = p128_2_0.d * 1.DL;
202
  if (! (COMPARE128 (a128, p128_2_0)))
203
    FAILURE
204
 
205
  a128.d = p128_2_0.d * m128_1.d;
206
  if (! (COMPARE128 (a128, m128_2_0)))
207
    FAILURE
208
 
209
  a128.d = p128_2_0.d * -1.DL;
210
  if (! (COMPARE128 (a128, m128_2_0)))
211
    FAILURE
212
}
213
 
214
int
215
main (void)
216
{
217
  init32 ();
218
  init64 ();
219
  init128 ();
220
 
221
  doit32 ();
222
  doit64 ();
223
  doit128 ();
224
 
225
  FINISH
226
}

powered by: WebSVN 2.1.0

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