1
1
#![ cfg_attr( f128_enabled, feature( f128) ) ]
2
2
3
3
use builtins_test:: float_bench;
4
- use compiler_builtins:: float:: cmp;
4
+ use compiler_builtins:: float:: cmp:: { self , CmpResult } ;
5
5
use criterion:: { Criterion , criterion_main} ;
6
6
7
7
/// `gt` symbols are allowed to return differing results, they just get compared
8
8
/// to 0.
9
- fn gt_res_eq ( a : i32 , b : i32 ) -> bool {
9
+ fn gt_res_eq ( mut a : CmpResult , mut b : CmpResult ) -> bool {
10
+ // FIXME: Our CmpResult used to be `i32`, but GCC/LLVM expect `isize`. on 64-bit platforms,
11
+ // this means the top half of the word may be garbage if built with an old version of
12
+ // `compiler-builtins`, so add a hack around this.
13
+ //
14
+ // This can be removed once a version of `compiler-builtins` with the return type fix makes
15
+ // it upstream.
16
+ if size_of :: < CmpResult > ( ) == 8 {
17
+ a = a as i32 as CmpResult ;
18
+ b = b as i32 as CmpResult ;
19
+ }
20
+
10
21
let a_lt_0 = a <= 0 ;
11
22
let b_lt_0 = b <= 0 ;
12
23
( a_lt_0 && b_lt_0) || ( !a_lt_0 && !b_lt_0)
13
24
}
14
25
15
26
float_bench ! {
16
27
name: cmp_f32_gt,
17
- sig: ( a: f32 , b: f32 ) -> i32 ,
28
+ sig: ( a: f32 , b: f32 ) -> CmpResult ,
18
29
crate_fn: cmp:: __gtsf2,
19
30
sys_fn: __gtsf2,
20
31
sys_available: all( ) ,
21
32
output_eq: gt_res_eq,
22
33
asm: [
23
34
#[ cfg( target_arch = "x86_64" ) ] {
24
- let ret: i32 ;
35
+ let ret: CmpResult ;
25
36
asm!(
26
37
"xor {ret:e}, {ret:e}" ,
27
38
"ucomiss {a}, {b}" ,
@@ -36,7 +47,7 @@ float_bench! {
36
47
} ;
37
48
38
49
#[ cfg( target_arch = "aarch64" ) ] {
39
- let ret: i32 ;
50
+ let ret: CmpResult ;
40
51
asm!(
41
52
"fcmp {a:s}, {b:s}" ,
42
53
"cset {ret:w}, gt" ,
@@ -53,13 +64,13 @@ float_bench! {
53
64
54
65
float_bench ! {
55
66
name: cmp_f32_unord,
56
- sig: ( a: f32 , b: f32 ) -> i32 ,
67
+ sig: ( a: f32 , b: f32 ) -> CmpResult ,
57
68
crate_fn: cmp:: __unordsf2,
58
69
sys_fn: __unordsf2,
59
70
sys_available: all( ) ,
60
71
asm: [
61
72
#[ cfg( target_arch = "x86_64" ) ] {
62
- let ret: i32 ;
73
+ let ret: CmpResult ;
63
74
asm!(
64
75
"xor {ret:e}, {ret:e}" ,
65
76
"ucomiss {a}, {b}" ,
@@ -74,7 +85,7 @@ float_bench! {
74
85
} ;
75
86
76
87
#[ cfg( target_arch = "aarch64" ) ] {
77
- let ret: i32 ;
88
+ let ret: CmpResult ;
78
89
asm!(
79
90
"fcmp {a:s}, {b:s}" ,
80
91
"cset {ret:w}, vs" ,
@@ -91,14 +102,14 @@ float_bench! {
91
102
92
103
float_bench ! {
93
104
name: cmp_f64_gt,
94
- sig: ( a: f64 , b: f64 ) -> i32 ,
105
+ sig: ( a: f64 , b: f64 ) -> CmpResult ,
95
106
crate_fn: cmp:: __gtdf2,
96
107
sys_fn: __gtdf2,
97
108
sys_available: all( ) ,
98
109
output_eq: gt_res_eq,
99
110
asm: [
100
111
#[ cfg( target_arch = "x86_64" ) ] {
101
- let ret: i32 ;
112
+ let ret: CmpResult ;
102
113
asm!(
103
114
"xor {ret:e}, {ret:e}" ,
104
115
"ucomisd {a}, {b}" ,
@@ -113,7 +124,7 @@ float_bench! {
113
124
} ;
114
125
115
126
#[ cfg( target_arch = "aarch64" ) ] {
116
- let ret: i32 ;
127
+ let ret: CmpResult ;
117
128
asm!(
118
129
"fcmp {a:d}, {b:d}" ,
119
130
"cset {ret:w}, gt" ,
@@ -130,13 +141,13 @@ float_bench! {
130
141
131
142
float_bench ! {
132
143
name: cmp_f64_unord,
133
- sig: ( a: f64 , b: f64 ) -> i32 ,
144
+ sig: ( a: f64 , b: f64 ) -> CmpResult ,
134
145
crate_fn: cmp:: __unorddf2,
135
146
sys_fn: __unorddf2,
136
147
sys_available: all( ) ,
137
148
asm: [
138
149
#[ cfg( target_arch = "x86_64" ) ] {
139
- let ret: i32 ;
150
+ let ret: CmpResult ;
140
151
asm!(
141
152
"xor {ret:e}, {ret:e}" ,
142
153
"ucomisd {a}, {b}" ,
@@ -151,7 +162,7 @@ float_bench! {
151
162
} ;
152
163
153
164
#[ cfg( target_arch = "aarch64" ) ] {
154
- let ret: i32 ;
165
+ let ret: CmpResult ;
155
166
asm!(
156
167
"fcmp {a:d}, {b:d}" ,
157
168
"cset {ret:w}, vs" ,
@@ -168,7 +179,7 @@ float_bench! {
168
179
169
180
float_bench ! {
170
181
name: cmp_f128_gt,
171
- sig: ( a: f128, b: f128) -> i32 ,
182
+ sig: ( a: f128, b: f128) -> CmpResult ,
172
183
crate_fn: cmp:: __gttf2,
173
184
crate_fn_ppc: cmp:: __gtkf2,
174
185
sys_fn: __gttf2,
@@ -180,7 +191,7 @@ float_bench! {
180
191
181
192
float_bench ! {
182
193
name: cmp_f128_unord,
183
- sig: ( a: f128, b: f128) -> i32 ,
194
+ sig: ( a: f128, b: f128) -> CmpResult ,
184
195
crate_fn: cmp:: __unordtf2,
185
196
crate_fn_ppc: cmp:: __unordkf2,
186
197
sys_fn: __unordtf2,
0 commit comments