11#![ cfg_attr( f128_enabled, feature( f128) ) ]
22
33use builtins_test:: float_bench;
4- use compiler_builtins:: float:: cmp;
4+ use compiler_builtins:: float:: cmp:: { self , CmpResult } ;
55use criterion:: { Criterion , criterion_main} ;
66
77/// `gt` symbols are allowed to return differing results, they just get compared
88/// 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+ dbg ! ( a, b, size_of:: <CmpResult >( ) ) ;
17+ if size_of :: < CmpResult > ( ) == 8 {
18+ a = a as i32 as CmpResult ;
19+ b = b as i32 as CmpResult ;
20+ }
21+
1022 let a_lt_0 = a <= 0 ;
1123 let b_lt_0 = b <= 0 ;
1224 ( a_lt_0 && b_lt_0) || ( !a_lt_0 && !b_lt_0)
1325}
1426
1527float_bench ! {
1628 name: cmp_f32_gt,
17- sig: ( a: f32 , b: f32 ) -> i32 ,
29+ sig: ( a: f32 , b: f32 ) -> CmpResult ,
1830 crate_fn: cmp:: __gtsf2,
1931 sys_fn: __gtsf2,
2032 sys_available: all( ) ,
2133 output_eq: gt_res_eq,
2234 asm: [
2335 #[ cfg( target_arch = "x86_64" ) ] {
24- let ret: i32 ;
36+ let ret: CmpResult ;
2537 asm!(
2638 "xor {ret:e}, {ret:e}" ,
2739 "ucomiss {a}, {b}" ,
@@ -36,7 +48,7 @@ float_bench! {
3648 } ;
3749
3850 #[ cfg( target_arch = "aarch64" ) ] {
39- let ret: i32 ;
51+ let ret: CmpResult ;
4052 asm!(
4153 "fcmp {a:s}, {b:s}" ,
4254 "cset {ret:w}, gt" ,
@@ -53,13 +65,13 @@ float_bench! {
5365
5466float_bench ! {
5567 name: cmp_f32_unord,
56- sig: ( a: f32 , b: f32 ) -> i32 ,
68+ sig: ( a: f32 , b: f32 ) -> CmpResult ,
5769 crate_fn: cmp:: __unordsf2,
5870 sys_fn: __unordsf2,
5971 sys_available: all( ) ,
6072 asm: [
6173 #[ cfg( target_arch = "x86_64" ) ] {
62- let ret: i32 ;
74+ let ret: CmpResult ;
6375 asm!(
6476 "xor {ret:e}, {ret:e}" ,
6577 "ucomiss {a}, {b}" ,
@@ -74,7 +86,7 @@ float_bench! {
7486 } ;
7587
7688 #[ cfg( target_arch = "aarch64" ) ] {
77- let ret: i32 ;
89+ let ret: CmpResult ;
7890 asm!(
7991 "fcmp {a:s}, {b:s}" ,
8092 "cset {ret:w}, vs" ,
@@ -91,14 +103,14 @@ float_bench! {
91103
92104float_bench ! {
93105 name: cmp_f64_gt,
94- sig: ( a: f64 , b: f64 ) -> i32 ,
106+ sig: ( a: f64 , b: f64 ) -> CmpResult ,
95107 crate_fn: cmp:: __gtdf2,
96108 sys_fn: __gtdf2,
97109 sys_available: all( ) ,
98110 output_eq: gt_res_eq,
99111 asm: [
100112 #[ cfg( target_arch = "x86_64" ) ] {
101- let ret: i32 ;
113+ let ret: CmpResult ;
102114 asm!(
103115 "xor {ret:e}, {ret:e}" ,
104116 "ucomisd {a}, {b}" ,
@@ -113,7 +125,7 @@ float_bench! {
113125 } ;
114126
115127 #[ cfg( target_arch = "aarch64" ) ] {
116- let ret: i32 ;
128+ let ret: CmpResult ;
117129 asm!(
118130 "fcmp {a:d}, {b:d}" ,
119131 "cset {ret:w}, gt" ,
@@ -130,13 +142,13 @@ float_bench! {
130142
131143float_bench ! {
132144 name: cmp_f64_unord,
133- sig: ( a: f64 , b: f64 ) -> i32 ,
145+ sig: ( a: f64 , b: f64 ) -> CmpResult ,
134146 crate_fn: cmp:: __unorddf2,
135147 sys_fn: __unorddf2,
136148 sys_available: all( ) ,
137149 asm: [
138150 #[ cfg( target_arch = "x86_64" ) ] {
139- let ret: i32 ;
151+ let ret: CmpResult ;
140152 asm!(
141153 "xor {ret:e}, {ret:e}" ,
142154 "ucomisd {a}, {b}" ,
@@ -151,7 +163,7 @@ float_bench! {
151163 } ;
152164
153165 #[ cfg( target_arch = "aarch64" ) ] {
154- let ret: i32 ;
166+ let ret: CmpResult ;
155167 asm!(
156168 "fcmp {a:d}, {b:d}" ,
157169 "cset {ret:w}, vs" ,
@@ -168,7 +180,7 @@ float_bench! {
168180
169181float_bench ! {
170182 name: cmp_f128_gt,
171- sig: ( a: f128, b: f128) -> i32 ,
183+ sig: ( a: f128, b: f128) -> CmpResult ,
172184 crate_fn: cmp:: __gttf2,
173185 crate_fn_ppc: cmp:: __gtkf2,
174186 sys_fn: __gttf2,
@@ -180,7 +192,7 @@ float_bench! {
180192
181193float_bench ! {
182194 name: cmp_f128_unord,
183- sig: ( a: f128, b: f128) -> i32 ,
195+ sig: ( a: f128, b: f128) -> CmpResult ,
184196 crate_fn: cmp:: __unordtf2,
185197 crate_fn_ppc: cmp:: __unordkf2,
186198 sys_fn: __unordtf2,
0 commit comments