11// makes configuration easier
22#![ allow( unused_macros) ]
3+ #![ feature( f128) ]
34
45use testcrate:: * ;
56
@@ -96,7 +97,7 @@ fn leading_zeros() {
9697// https://github.com/rust-lang/rust/issues/73920.
9798// TODO how do we resolve this indeterminacy?
9899macro_rules! pow {
99- ( $( $f: ty, $tolerance: expr, $fn: ident) ;* ; ) => {
100+ ( $( $f: ty, $tolerance: expr, $fn: ident) ;* ; ) => {
100101 $(
101102 fuzz_float_2( N , |x: $f, y: $f| {
102103 if !( Float :: is_subnormal( x) || Float :: is_subnormal( y) || x. is_nan( ) ) {
@@ -118,12 +119,12 @@ macro_rules! pow {
118119 b < $tolerance
119120 } else {
120121 let quo = b / a;
121- ( quo < ( 1. + $tolerance) ) && ( quo > ( 1. - $tolerance) )
122+ ( quo < ( 1. + black_box ( $tolerance) ) ) && ( quo > ( 1. - black_box ( $tolerance) ) )
122123 }
123124 } ;
124125 if !good {
125126 panic!(
126- "{}({}, {}): std: {}, builtins: {}" ,
127+ "{}({:? }, {:? }): std: {:? }, builtins: {:? }" ,
127128 stringify!( $fn) , x, n, tmp0, tmp1
128129 ) ;
129130 }
@@ -139,8 +140,27 @@ fn float_pow() {
139140 use compiler_builtins:: float:: pow:: { __powidf2, __powisf2} ;
140141 use compiler_builtins:: float:: Float ;
141142
143+ fn black_box < T > ( val : T ) -> T {
144+ val
145+ }
146+
142147 pow ! (
143148 f32 , 1e-4 , __powisf2;
144149 f64 , 1e-12 , __powidf2;
145150 ) ;
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+ }
146166}
0 commit comments