11use crate :: float:: Float ;
2- use crate :: int:: { CastInto , Int } ;
2+ use crate :: int:: { CastInto , Int , MinInt } ;
33
44/// Returns `a + b`
55fn add < F : Float > ( a : F , b : F ) -> F
@@ -57,17 +57,17 @@ where
5757 }
5858
5959 // zero + anything = anything
60- if a_abs == Int :: ZERO {
60+ if a_abs == MinInt :: ZERO {
6161 // but we need to get the sign right for zero + zero
62- if b_abs == Int :: ZERO {
62+ if b_abs == MinInt :: ZERO {
6363 return F :: from_repr ( a. repr ( ) & b. repr ( ) ) ;
6464 } else {
6565 return b;
6666 }
6767 }
6868
6969 // anything + zero = anything
70- if b_abs == Int :: ZERO {
70+ if b_abs == MinInt :: ZERO {
7171 return a;
7272 }
7373 }
@@ -113,10 +113,10 @@ where
113113 // Shift the significand of b by the difference in exponents, with a sticky
114114 // bottom bit to get rounding correct.
115115 let align = a_exponent. wrapping_sub ( b_exponent) . cast ( ) ;
116- if align != Int :: ZERO {
116+ if align != MinInt :: ZERO {
117117 if align < bits {
118118 let sticky =
119- F :: Int :: from_bool ( b_significand << bits. wrapping_sub ( align) . cast ( ) != Int :: ZERO ) ;
119+ F :: Int :: from_bool ( b_significand << bits. wrapping_sub ( align) . cast ( ) != MinInt :: ZERO ) ;
120120 b_significand = ( b_significand >> align. cast ( ) ) | sticky;
121121 } else {
122122 b_significand = one; // sticky; b is known to be non-zero.
@@ -125,8 +125,8 @@ where
125125 if subtraction {
126126 a_significand = a_significand. wrapping_sub ( b_significand) ;
127127 // If a == -b, return +zero.
128- if a_significand == Int :: ZERO {
129- return F :: from_repr ( Int :: ZERO ) ;
128+ if a_significand == MinInt :: ZERO {
129+ return F :: from_repr ( MinInt :: ZERO ) ;
130130 }
131131
132132 // If partial cancellation occured, we need to left-shift the result
@@ -143,8 +143,8 @@ where
143143
144144 // If the addition carried up, we need to right-shift the result and
145145 // adjust the exponent:
146- if a_significand & implicit_bit << 4 != Int :: ZERO {
147- let sticky = F :: Int :: from_bool ( a_significand & one != Int :: ZERO ) ;
146+ if a_significand & implicit_bit << 4 != MinInt :: ZERO {
147+ let sticky = F :: Int :: from_bool ( a_significand & one != MinInt :: ZERO ) ;
148148 a_significand = a_significand >> 1 | sticky;
149149 a_exponent += 1 ;
150150 }
@@ -160,7 +160,7 @@ where
160160 // need to shift the significand.
161161 let shift = ( 1 - a_exponent) . cast ( ) ;
162162 let sticky =
163- F :: Int :: from_bool ( ( a_significand << bits. wrapping_sub ( shift) . cast ( ) ) != Int :: ZERO ) ;
163+ F :: Int :: from_bool ( ( a_significand << bits. wrapping_sub ( shift) . cast ( ) ) != MinInt :: ZERO ) ;
164164 a_significand = a_significand >> shift. cast ( ) | sticky;
165165 a_exponent = 0 ;
166166 }
@@ -203,6 +203,16 @@ intrinsics! {
203203 add( a, b)
204204 }
205205
206+ #[ cfg( not( any( feature = "no-f16-f128" , target_arch = "powerpc" , target_arch = "powerpc64" ) ) ) ]
207+ pub extern "C" fn __addtf3( a: f128, b: f128) -> f128 {
208+ add( a, b)
209+ }
210+
211+ #[ cfg( all( not( feature = "no-f16-f128" ) , any( target_arch = "powerpc" , target_arch = "powerpc64" ) ) ) ]
212+ pub extern "C" fn __addkf3( a: f128, b: f128) -> f128 {
213+ add( a, b)
214+ }
215+
206216 #[ cfg( target_arch = "arm" ) ]
207217 pub extern "C" fn __addsf3vfp( a: f32 , b: f32 ) -> f32 {
208218 a + b
0 commit comments