* math_efp.c: Fixed SPE data type conversion failure
@ 2010-11-17 2:28 Shan Hai
2010-11-17 2:28 ` [PATCH] Fix SPE float to integer " Shan Hai
0 siblings, 1 reply; 3+ messages in thread
From: Shan Hai @ 2010-11-17 2:28 UTC (permalink / raw)
To: linuxppc-dev
The following test case failed on Powerpc sbc8548 with CONFIG_SPE
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
The reason is failure to emulate the minus float to unsigned integer conversion
instruction in the SPE driver.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] Fix SPE float to integer conversion failure
2010-11-17 2:28 math_efp.c: Fixed SPE data type conversion failure Shan Hai
@ 2010-11-17 2:28 ` Shan Hai
2011-03-15 15:51 ` Kumar Gala
0 siblings, 1 reply; 3+ messages in thread
From: Shan Hai @ 2010-11-17 2:28 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Shan Hai
Conversion from float to integer should based on both the instruction
encoding and the sign of the operand.
Signed-off-by: Shan Hai <shan.hai@windriver.com>
---
arch/powerpc/math-emu/math_efp.c | 12 ++++++++----
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 41f4ef3..64faf10 100644
--- a/arch/powerpc/math-emu/math_efp.c
+++ b/arch/powerpc/math-emu/math_efp.c
@@ -320,7 +320,8 @@ int do_spe_mathemu(struct pt_regs *regs)
} else {
_FP_ROUND_ZERO(1, SB);
}
- FP_TO_INT_S(vc.wp[1], SB, 32, ((func & 0x3) != 0));
+ FP_TO_INT_S(vc.wp[1], SB, 32,
+ (((func & 0x3) != 0) || SB_s));
goto update_regs;
default:
@@ -458,7 +459,8 @@ cmp_s:
} else {
_FP_ROUND_ZERO(2, DB);
}
- FP_TO_INT_D(vc.wp[1], DB, 32, ((func & 0x3) != 0));
+ FP_TO_INT_D(vc.wp[1], DB, 32,
+ (((func & 0x3) != 0) || DB_s));
goto update_regs;
default:
@@ -589,8 +591,10 @@ cmp_d:
_FP_ROUND_ZERO(1, SB0);
_FP_ROUND_ZERO(1, SB1);
}
- FP_TO_INT_S(vc.wp[0], SB0, 32, ((func & 0x3) != 0));
- FP_TO_INT_S(vc.wp[1], SB1, 32, ((func & 0x3) != 0));
+ FP_TO_INT_S(vc.wp[0], SB0, 32,
+ (((func & 0x3) != 0) || SB0_s));
+ FP_TO_INT_S(vc.wp[1], SB1, 32,
+ (((func & 0x3) != 0) || SB1_s));
goto update_regs;
default:
--
1.7.0.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix SPE float to integer conversion failure
2010-11-17 2:28 ` [PATCH] Fix SPE float to integer " Shan Hai
@ 2011-03-15 15:51 ` Kumar Gala
0 siblings, 0 replies; 3+ messages in thread
From: Kumar Gala @ 2011-03-15 15:51 UTC (permalink / raw)
To: Shan Hai; +Cc: linuxppc-dev
On Nov 16, 2010, at 8:28 PM, Shan Hai wrote:
> Conversion from float to integer should based on both the instruction
> encoding and the sign of the operand.
>
> Signed-off-by: Shan Hai <shan.hai@windriver.com>
> ---
> arch/powerpc/math-emu/math_efp.c | 12 ++++++++----
> 1 files changed, 8 insertions(+), 4 deletions(-)
applied
- k
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-03-15 15:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-17 2:28 math_efp.c: Fixed SPE data type conversion failure Shan Hai
2010-11-17 2:28 ` [PATCH] Fix SPE float to integer " Shan Hai
2011-03-15 15:51 ` Kumar Gala
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).