powerpc: use float64 for frsqrte
PATCH 1/1 powerpc: use float64 for frsqrte
Remove the code that reduce the result to float32 as the frsqrte instruction is defined to return a double-precision estimate of the reciprocal square root.
Although reducing the fractional part is harmless (as the estimation must have at least 12 bits of precision according to the old PEM), reducing the exponent range is not correct.
--- target-ppc/fpu_helper.c | 3 --- 1 file changed, 3 deletions(-)
target-ppc/fpu_helper.c +0 -3
@@ -977,7 +977,6 @@ uint64_t helper_fres(CPUPPCState *env, uint64_t arg)uint64_t helper_frsqrte (CPUPPCState *env,uint64_t arg) {CPU_DoubleU farg; -float32 f32; farg.ll = arg;
@@ -991,8 +990,6 @@ uint64_t helper_frsqrte(CPUPPCState *env, uint64_t arg) } farg.d =float64_sqrt (farg.d, &env->fp_status); farg.d =float64_div (float64_one, farg.d, &env->fp_status); - f32 =float64_to_float32 (farg.d, &env->fp_status); - farg.d =float32_to_float64 (f32, &env->fp_status); }return farg.ll; }
Signature · 1 line
1.7.10.4
Quoted 9 lines · Tristan Gingold
Remove the code that reduce the result to float32 as the frsqrte instruction is defined to return a double-precision estimate of the reciprocal square root.
Although reducing the fractional part is harmless (as the estimation must have at least 12 bits of precision according to the old PEM), reducing the exponent range is not correct.
Signed-off-by Tristan Gingold <[email protected]>
I couldn't find a reference to doubles in ISA 2.07. Is frsqrte supposed to return doubles on all cores? Or is this implementation specific? Also, is frsqrte the only instruction affected?
Alex
Quoted 25 lines
--- target-ppc/fpu_helper.c | 3 --- 1 file changed, 3 deletions(-)target-ppc/fpu_helper.c +0
-3@@ -977,7 +977,6 @@ uint64_t helper_fres(CPUPPCState *env, uint64_t arg)uint64_t helper_frsqrte (CPUPPCState *env,uint64_t arg) {CPU_DoubleU farg; -float32 f32; farg.ll = arg;@@ -991,8 +990,6 @@ uint64_t helper_frsqrte(CPUPPCState *env, uint64_t arg) } farg.d =float64_sqrt (farg.d, &env->fp_status); farg.d =float64_div (float64_one, farg.d, &env->fp_status); - f32 =float64_to_float32 (farg.d, &env->fp_status); - farg.d =float32_to_float64 (f32, &env->fp_status); }return farg.ll; }
Quoted 5 lines · Alexander Graf
Quoted 4 lines · Tristan Gingold
Remove the code that reduce the result to float32 as the frsqrte instruction is defined to return a double-precision estimate of the reciprocal square root.
Quoted 7 lines
Quoted 5 lines
Although reducing the fractional part is harmless (as the estimation must have at least 12 bits of precision according to the old PEM), reducing the exponent range is not correct.
Signed-off-by Tristan Gingold <[email protected]>I couldn't find a reference to doubles in ISA 2.07. Is frsqrte supposed to return doubles on all cores?
I have just checked ISA V 2.06 (will download 2.07 if necessary). There are now two
instructions: frsqrte and frsqrtes. The second one if for single - so the first one is for double.
[ If you look at IBM AIX assembly manual:
http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.aixassem/doc/alangref/frsqrte.htm
they clearly mention that frsqrte operates on double on 603, 604 but not implemented on 601]
Quoted 1 line
Or is this implementation specific?
This instruction is optional and the precision of the estimation is implementation dependant. I have looked at some implementation manuals (604, 603, e300) and they don't mention single.
Quoted 1 line
Also, is frsqrte the only instruction affected?
Yes. Operation fres operates on single.
Tristan.
Quoted 28 lines
Alex
Quoted 23 lines
--- target-ppc/fpu_helper.c | 3 --- 1 file changed, 3 deletions(-)target-ppc/fpu_helper.c +0
-1@@ -977,7 +977,6 @@ uint64_t helper_fres(CPUPPCState *env, uint64_t arg)uint64_t helper_frsqrte (CPUPPCState *env,uint64_t arg) {CPU_DoubleU farg; -float32 f32; farg.ll = arg; @@ -991,8 +990,6 @@ uint64_t helper_frsqrte(CPUPPCState *env, uint64_t arg) }farg.d = float64_sqrt(farg.d, &env->fp_status); farg.d = float64_div(float64_one, farg.d, &env->fp_status);target-ppc/fpu_helper.c +0
-2- f32 =float64_to_float32 (farg.d, &env->fp_status); - farg.d =float32_to_float64 (f32, &env->fp_status); }return farg.ll; }