1
1
// makes configuration easier
2
2
#![ allow( unused_macros) ]
3
+ #![ feature( f128) ]
3
4
4
5
use testcrate:: * ;
5
6
@@ -96,7 +97,7 @@ fn leading_zeros() {
96
97
// https://github.com/rust-lang/rust/issues/73920.
97
98
// TODO how do we resolve this indeterminacy?
98
99
macro_rules! pow {
99
- ( $( $f: ty, $tolerance: expr, $fn: ident) ;* ; ) => {
100
+ ( $( $f: ty, $tolerance: expr, $fn: ident) ;* ; ) => {
100
101
$(
101
102
fuzz_float_2( N , |x: $f, y: $f| {
102
103
if !( Float :: is_subnormal( x) || Float :: is_subnormal( y) || x. is_nan( ) ) {
@@ -118,12 +119,12 @@ macro_rules! pow {
118
119
b < $tolerance
119
120
} else {
120
121
let quo = b / a;
121
- ( quo < ( 1. + $tolerance) ) && ( quo > ( 1. - $tolerance) )
122
+ ( quo < ( 1. + black_box ( $tolerance) ) ) && ( quo > ( 1. - black_box ( $tolerance) ) )
122
123
}
123
124
} ;
124
125
if !good {
125
126
panic!(
126
- "{}({}, {}): std: {}, builtins: {}" ,
127
+ "{}({:? }, {:? }): std: {:? }, builtins: {:? }" ,
127
128
stringify!( $fn) , x, n, tmp0, tmp1
128
129
) ;
129
130
}
@@ -139,8 +140,27 @@ fn float_pow() {
139
140
use compiler_builtins:: float:: pow:: { __powidf2, __powisf2} ;
140
141
use compiler_builtins:: float:: Float ;
141
142
143
+ fn black_box < T > ( val : T ) -> T {
144
+ val
145
+ }
146
+
142
147
pow ! (
143
148
f32 , 1e-4 , __powisf2;
144
149
f64 , 1e-12 , __powidf2;
145
150
) ;
151
+
152
+ // There is no apfloat fallback for `powi` so we just skip these tests on these platforms
153
+ #[ cfg( not( any( feature = "no-f16-f128" , feature = "no-sys-f128" ) ) ) ]
154
+ {
155
+ #[ cfg( any( target_arch = "powerpc" , target_arch = "powerpc64" ) ) ]
156
+ use compiler_builtins:: float:: pow:: __powikf2 as __powitf2;
157
+ #[ cfg( not( any( target_arch = "powerpc" , target_arch = "powerpc64" ) ) ) ]
158
+ use compiler_builtins:: float:: pow:: __powitf2;
159
+
160
+ // FIXME(f16_f128): we do this to block const eval which currently ICEs. Change this
161
+ // once it works correctly.
162
+ use core:: hint:: black_box;
163
+
164
+ pow ! ( f128, 1e-24 , __powitf2; ) ;
165
+ }
146
166
}
0 commit comments