1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
.include "t-macros.i"
start
### $f3 = $f2 / sqrt ($f1)
test_rsqrt:
loadfp $f1 4.0
loadfp $f2 1.0
rsqrt.s $f3, $f2, $f1
checkfp 0 $f3 0.5
################
## +1.0 / sqrt (+0.0)
## -> 0x7fffffff (+Max) D+SD
test_rsqrt_1:
clearfcsr
loadfp $f1, +1.0
loadfp $f2, +0.0
rsqrt.s $f3, $f1, $f2
checkfpx 1 0x00010021 $f3 0x7fffffff
## -1.0 / sqrt (+0.0)
## -> 0xffffffff (-Max) D+SD
test_rsqrt_2:
clearfcsr
loadfp $f1, -1.0
loadfp $f2, +0.0
rsqrt.s $f3, $f1, $f2
checkfpx 1 0x00010021 $f3 0xffffffff
## 0 / sqrt (-0)
##and 0 / sqrt (0)
## ->0x7fffffff I + SI
test_rsqrt_3a:
clearfcsr
loadfp $f1, +0.0
loadfp $f2, -0.0
rsqrt.s $f3, $f1, $f2
checkfpx 1 0x00020041 $f3 0x7fffffff
test_rsqrt_3b:
clearfcsr
loadfp $f1, +0.0
loadfp $f2, +0.0
rsqrt.s $f3, $f1, $f2
checkfpx 1 0x00020041 $f3 0x7fffffff
## Correctly:
## (-0) / sqrt (-0)
## ->FFFFFFFF (I + SI)
test_rsqrt_4a:
clearfcsr
loadfp $f1, -0.0
loadfp $f2, -0.0
rsqrt.s $f3, $f1, $f2
checkfpx 1 0x00020041 $f3 0xffffffff
test_rsqrt_4b:
clearfcsr
loadfp $f1, -0.0
loadfp $f2, +0.0
rsqrt.s $f3, $f1, $f2
checkfpx 1 0x00020041 $f3 0xffffffff
## (max) / sqrt (min*2) -> no O+SO
##
test_rsqrt_5aa:
clearfcsr
loadfpx $f1, 0x7fffffff
loadfpx $f2, 0x00800001
rsqrt.s $f3, $f1, $f2
checkfpx 1 0x00000001 $f3 0x7fffffff
test_rsqrt_5ab:
clearfcsr
loadfpx $f1, 0x7fffffff
loadfpx $f2, 0x80800001
rsqrt.s $f3, $f1, $f2
checkfpx 1 0x00020041 $f3 0x7fffffff
test_rsqrt_5ba:
clearfcsr
loadfpx $f1, 0xffffffff
loadfpx $f2, 0x00800001
rsqrt.s $f3, $f1, $f2
checkfpx 1 0x00000001 $f3 0xffffffff
test_rsqrt_5bb:
clearfcsr
loadfpx $f1, 0xffffffff
loadfpx $f2, 0x80800001
rsqrt.s $f3, $f1, $f2
checkfpx 1 0x00020041 $f3 0xffffffff
## (max) / sqrt (min*2) -> no U+SU
##
test_rsqrt_6aa:
clearfcsr
loadfpx $f1, 0x00800001
loadfpx $f2, 0x7fffffff
rsqrt.s $f3, $f1, $f2
checkfpx 1 0x00000001 $f3 0x00000000
test_rsqrt_6ab:
clearfcsr
loadfpx $f1, 0x00800001
loadfpx $f2, 0xffffffff
rsqrt.s $f3, $f1, $f2
checkfpx 1 0x00020041 $f3 0x00000000
test_rsqrt_6ba:
clearfcsr
loadfpx $f1, 0x80800001
loadfpx $f2, 0x7fffffff
rsqrt.s $f3, $f1, $f2
checkfpx 1 0x00000001 $f3 0x80000000
test_rsqrt_6bb:
clearfcsr
loadfpx $f1, 0x80800001
loadfpx $f2, 0xffffffff
rsqrt.s $f3, $f1, $f2
checkfpx 1 0x00020041 $f3 0x80000000
## Correctly:
## (max/min) / sqrt ([+-]0)
## ->MAX/MIN (D + SD)
test_rsqrt_7aa:
clearfcsr
loadfpx $f1, 0x7fffffff
loadfpx $f2, 0x00000000
rsqrt.s $f3, $f1, $f2
checkfpx 1 0x00010021 $f3 0x7fffffff
test_rsqrt_7ab:
clearfcsr
loadfpx $f1, 0x7fffffff
loadfpx $f2, 0x80000000
rsqrt.s $f3, $f1, $f2
checkfpx 1 0x00010021 $f3 0x7fffffff
test_rsqrt_7ba:
clearfcsr
loadfpx $f1, 0xffffffff
loadfpx $f2, 0x00000000
rsqrt.s $f3, $f1, $f2
checkfpx 1 0x00010021 $f3 0xffffffff
test_rsqrt_7bb:
clearfcsr
loadfpx $f1, 0xffffffff
loadfpx $f2, 0x80000000
rsqrt.s $f3, $f1, $f2
checkfpx 1 0x00010021 $f3 0xffffffff
## Like max/sqrt but check that bits are set/cleared
##
test_rsqrt_9aa:
clearfcsr
loadfpx $f1, 0x7fffffff
loadfpx $f2, 0x00000000
rsqrt.s $f3, $f1, $f2
loadfpx $f1, 0x00800001
loadfpx $f2, 0xffffffff
rsqrt.s $f3, $f1, $f2
checkfpx 1 0x00020061 $f3 0x00000000
exit0
|