aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShan Hai <shan.hai@windriver.com>2010-11-16 21:28:53 -0500
committerKumar Gala <galak@kernel.crashing.org>2011-03-15 14:48:15 -0400
commitafc0a07d4a283599ac3a6a31d7454e9baaeccca0 (patch)
tree0cc07560a34c697f1f67841ee637170f4e38e416
parentcf773702b912544fdb8573c5f4299513d66bb0bf (diff)
powerpc/85xx: Fix SPE float to integer conversion failure
Conversion from float to integer should based on both the instruction encoding and the sign of the operand. A simple testcase to show the issue: static float fm; static signed int si_min = (-2147483647 - 1); static unsigned int ui; int main() { fm = (float) si_min; ; ui = (unsigned int)fm; printf("ui=%d, should be %d\n", ui, si_min); return 0; } Result: ui=-1, should be -2147483648 Signed-off-by: Shan Hai <shan.hai@windriver.com> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
-rw-r--r--arch/powerpc/math-emu/math_efp.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/arch/powerpc/math-emu/math_efp.c b/arch/powerpc/math-emu/math_efp.c
index 634830bdc0be..62279200d965 100644
--- a/arch/powerpc/math-emu/math_efp.c
+++ b/arch/powerpc/math-emu/math_efp.c
@@ -322,7 +322,8 @@ int do_spe_mathemu(struct pt_regs *regs)
322 } else { 322 } else {
323 _FP_ROUND_ZERO(1, SB); 323 _FP_ROUND_ZERO(1, SB);
324 } 324 }
325 FP_TO_INT_S(vc.wp[1], SB, 32, ((func & 0x3) != 0)); 325 FP_TO_INT_S(vc.wp[1], SB, 32,
326 (((func & 0x3) != 0) || SB_s));
326 goto update_regs; 327 goto update_regs;
327 328
328 default: 329 default:
@@ -460,7 +461,8 @@ cmp_s:
460 } else { 461 } else {
461 _FP_ROUND_ZERO(2, DB); 462 _FP_ROUND_ZERO(2, DB);
462 } 463 }
463 FP_TO_INT_D(vc.wp[1], DB, 32, ((func & 0x3) != 0)); 464 FP_TO_INT_D(vc.wp[1], DB, 32,
465 (((func & 0x3) != 0) || DB_s));
464 goto update_regs; 466 goto update_regs;
465 467
466 default: 468 default:
@@ -591,8 +593,10 @@ cmp_d:
591 _FP_ROUND_ZERO(1, SB0); 593 _FP_ROUND_ZERO(1, SB0);
592 _FP_ROUND_ZERO(1, SB1); 594 _FP_ROUND_ZERO(1, SB1);
593 } 595 }
594 FP_TO_INT_S(vc.wp[0], SB0, 32, ((func & 0x3) != 0)); 596 FP_TO_INT_S(vc.wp[0], SB0, 32,
595 FP_TO_INT_S(vc.wp[1], SB1, 32, ((func & 0x3) != 0)); 597 (((func & 0x3) != 0) || SB0_s));
598 FP_TO_INT_S(vc.wp[1], SB1, 32,
599 (((func & 0x3) != 0) || SB1_s));
596 goto update_regs; 600 goto update_regs;
597 601
598 default: 602 default: