* Fixed Powerpc SPE data type conversion failure
@ 2010-11-14 4:11 Hai Shan
2010-11-14 4:11 ` [PATCH] Fix float to unsigned conversion failure with SPE enabled Hai Shan
0 siblings, 1 reply; 6+ messages in thread
From: Hai Shan @ 2010-11-14 4:11 UTC (permalink / raw)
To: linux-kernel
The following test case failed on Powerpc e500 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 conversion instruction
in the SPE driver.
---
arch/powerpc/math-emu/math_efp.c | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH] Fix float to unsigned conversion failure with SPE enabled 2010-11-14 4:11 Fixed Powerpc SPE data type conversion failure Hai Shan @ 2010-11-14 4:11 ` Hai Shan 2010-11-16 11:29 ` Josh Boyer 0 siblings, 1 reply; 6+ messages in thread From: Hai Shan @ 2010-11-14 4:11 UTC (permalink / raw) To: linux-kernel; +Cc: Hai Shan Fixed the failure on converting minus float to unsigned int with SPE enabled Signed-off-by: Hai Shan <shan.hai@windriver.com> --- arch/powerpc/math-emu/math_efp.c | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/math-emu/math_efp.c b/arch/powerpc/math-emu/math_efp.c index 41f4ef3..338a128 100644 --- a/arch/powerpc/math-emu/math_efp.c +++ b/arch/powerpc/math-emu/math_efp.c @@ -320,7 +320,9 @@ 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)); + /* SB_s: convert from minus float to unsigned int */ + FP_TO_INT_S(vc.wp[1], SB, 32, + ((func & 0x3) != 0) || SB_s); goto update_regs; default: @@ -458,7 +460,11 @@ cmp_s: } else { _FP_ROUND_ZERO(2, DB); } - FP_TO_INT_D(vc.wp[1], DB, 32, ((func & 0x3) != 0)); + /* DB_s: convert from minus long double to + * unsigned long long + */ + FP_TO_INT_D(vc.wp[1], DB, 32, + ((func & 0x3) != 0) || DB_s); goto update_regs; default: @@ -589,8 +595,11 @@ 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)); + /* SB*_s: convert from minus float to unsigned int */ + 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.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix float to unsigned conversion failure with SPE enabled 2010-11-14 4:11 ` [PATCH] Fix float to unsigned conversion failure with SPE enabled Hai Shan @ 2010-11-16 11:29 ` Josh Boyer 0 siblings, 0 replies; 6+ messages in thread From: Josh Boyer @ 2010-11-16 11:29 UTC (permalink / raw) To: Hai Shan; +Cc: Hai Shan, linuxppc-dev, linux-kernel On Sat, Nov 13, 2010 at 11:11 PM, Hai Shan <haishan.bai@gmail.com> wrote: > Fixed the failure on converting minus float to unsigned int with SPE enab= led > > Signed-off-by: Hai Shan <shan.hai@windriver.com> You should make sure to send PowerPC patches to linuxppc-dev. josh > --- > =A0arch/powerpc/math-emu/math_efp.c | =A0 17 +++++++++++++---- > =A01 files changed, 13 insertions(+), 4 deletions(-) > > diff --git a/arch/powerpc/math-emu/math_efp.c b/arch/powerpc/math-emu/mat= h_efp.c > index 41f4ef3..338a128 100644 > --- a/arch/powerpc/math-emu/math_efp.c > +++ b/arch/powerpc/math-emu/math_efp.c > @@ -320,7 +320,9 @@ int do_spe_mathemu(struct pt_regs *regs) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} else { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0_FP_ROUND_= ZERO(1, SB); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 FP_TO_INT_S(vc.wp[1], SB, 3= 2, ((func & 0x3) !=3D 0)); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* SB_s: convert from minus= float to unsigned int */ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 FP_TO_INT_S(vc.wp[1], SB, 3= 2, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 ((func & 0x3) !=3D 0) || SB_s); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0goto update_regs; > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0default: > @@ -458,7 +460,11 @@ cmp_s: > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} else { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0_FP_ROUND_= ZERO(2, DB); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 FP_TO_INT_D(vc.wp[1], DB, 3= 2, ((func & 0x3) !=3D 0)); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* DB_s: convert from minus= long double to > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* unsigned long long > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*/ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 FP_TO_INT_D(vc.wp[1], DB, 3= 2, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 ((func & 0x3) !=3D 0) || DB_s); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0goto update_regs; > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0default: > @@ -589,8 +595,11 @@ cmp_d: > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0_FP_ROUND_= ZERO(1, SB0); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0_FP_ROUND_= ZERO(1, SB1); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 FP_TO_INT_S(vc.wp[0], SB0, = 32, ((func & 0x3) !=3D 0)); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 FP_TO_INT_S(vc.wp[1], SB1, = 32, ((func & 0x3) !=3D 0)); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* SB*_s: convert from minu= s float to unsigned int */ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 FP_TO_INT_S(vc.wp[0], SB0, = 32, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 ((func & 0x3) !=3D 0) || SB0_s); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 FP_TO_INT_S(vc.wp[1], SB1, = 32, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 ((func & 0x3) !=3D 0) || SB1_s); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0goto update_regs; > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0default: > -- > 1.7.0.4 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" i= n > the body of a message to majordomo@vger.kernel.org > More majordomo info at =A0http://vger.kernel.org/majordomo-info.html > Please read the FAQ at =A0http://www.tux.org/lkml/ > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix float to unsigned conversion failure with SPE enabled @ 2010-11-16 11:29 ` Josh Boyer 0 siblings, 0 replies; 6+ messages in thread From: Josh Boyer @ 2010-11-16 11:29 UTC (permalink / raw) To: Hai Shan; +Cc: linux-kernel, Hai Shan, linuxppc-dev On Sat, Nov 13, 2010 at 11:11 PM, Hai Shan <haishan.bai@gmail.com> wrote: > Fixed the failure on converting minus float to unsigned int with SPE enabled > > Signed-off-by: Hai Shan <shan.hai@windriver.com> You should make sure to send PowerPC patches to linuxppc-dev. josh > --- > arch/powerpc/math-emu/math_efp.c | 17 +++++++++++++---- > 1 files changed, 13 insertions(+), 4 deletions(-) > > diff --git a/arch/powerpc/math-emu/math_efp.c b/arch/powerpc/math-emu/math_efp.c > index 41f4ef3..338a128 100644 > --- a/arch/powerpc/math-emu/math_efp.c > +++ b/arch/powerpc/math-emu/math_efp.c > @@ -320,7 +320,9 @@ 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)); > + /* SB_s: convert from minus float to unsigned int */ > + FP_TO_INT_S(vc.wp[1], SB, 32, > + ((func & 0x3) != 0) || SB_s); > goto update_regs; > > default: > @@ -458,7 +460,11 @@ cmp_s: > } else { > _FP_ROUND_ZERO(2, DB); > } > - FP_TO_INT_D(vc.wp[1], DB, 32, ((func & 0x3) != 0)); > + /* DB_s: convert from minus long double to > + * unsigned long long > + */ > + FP_TO_INT_D(vc.wp[1], DB, 32, > + ((func & 0x3) != 0) || DB_s); > goto update_regs; > > default: > @@ -589,8 +595,11 @@ 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)); > + /* SB*_s: convert from minus float to unsigned int */ > + 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.4 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix float to unsigned conversion failure with SPE enabled 2010-11-16 11:29 ` Josh Boyer @ 2010-11-17 1:39 ` haishan -1 siblings, 0 replies; 6+ messages in thread From: haishan @ 2010-11-17 1:39 UTC (permalink / raw) To: Josh Boyer; +Cc: linuxppc-dev, linux-kernel, Hai Shan Josh Boyer wrote: > On Sat, Nov 13, 2010 at 11:11 PM, Hai Shan <haishan.bai@gmail.com> wrote: > >> Fixed the failure on converting minus float to unsigned int with SPE enabled >> >> Signed-off-by: Hai Shan <shan.hai@windriver.com> >> > > You should make sure to send PowerPC patches to linuxppc-dev. > > Thanks for your suggestion, I will send it to linuxppc-dev. Regards Shan Hai > josh > > >> --- >> arch/powerpc/math-emu/math_efp.c | 17 +++++++++++++---- >> 1 files changed, 13 insertions(+), 4 deletions(-) >> >> diff --git a/arch/powerpc/math-emu/math_efp.c b/arch/powerpc/math-emu/math_efp.c >> index 41f4ef3..338a128 100644 >> --- a/arch/powerpc/math-emu/math_efp.c >> +++ b/arch/powerpc/math-emu/math_efp.c >> @@ -320,7 +320,9 @@ 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)); >> + /* SB_s: convert from minus float to unsigned int */ >> + FP_TO_INT_S(vc.wp[1], SB, 32, >> + ((func & 0x3) != 0) || SB_s); >> goto update_regs; >> >> default: >> @@ -458,7 +460,11 @@ cmp_s: >> } else { >> _FP_ROUND_ZERO(2, DB); >> } >> - FP_TO_INT_D(vc.wp[1], DB, 32, ((func & 0x3) != 0)); >> + /* DB_s: convert from minus long double to >> + * unsigned long long >> + */ >> + FP_TO_INT_D(vc.wp[1], DB, 32, >> + ((func & 0x3) != 0) || DB_s); >> goto update_regs; >> >> default: >> @@ -589,8 +595,11 @@ 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)); >> + /* SB*_s: convert from minus float to unsigned int */ >> + 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.4 >> >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html >> Please read the FAQ at http://www.tux.org/lkml/ >> >> ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix float to unsigned conversion failure with SPE enabled @ 2010-11-17 1:39 ` haishan 0 siblings, 0 replies; 6+ messages in thread From: haishan @ 2010-11-17 1:39 UTC (permalink / raw) To: Josh Boyer; +Cc: Hai Shan, linux-kernel, linuxppc-dev Josh Boyer wrote: > On Sat, Nov 13, 2010 at 11:11 PM, Hai Shan <haishan.bai@gmail.com> wrote: > >> Fixed the failure on converting minus float to unsigned int with SPE enabled >> >> Signed-off-by: Hai Shan <shan.hai@windriver.com> >> > > You should make sure to send PowerPC patches to linuxppc-dev. > > Thanks for your suggestion, I will send it to linuxppc-dev. Regards Shan Hai > josh > > >> --- >> arch/powerpc/math-emu/math_efp.c | 17 +++++++++++++---- >> 1 files changed, 13 insertions(+), 4 deletions(-) >> >> diff --git a/arch/powerpc/math-emu/math_efp.c b/arch/powerpc/math-emu/math_efp.c >> index 41f4ef3..338a128 100644 >> --- a/arch/powerpc/math-emu/math_efp.c >> +++ b/arch/powerpc/math-emu/math_efp.c >> @@ -320,7 +320,9 @@ 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)); >> + /* SB_s: convert from minus float to unsigned int */ >> + FP_TO_INT_S(vc.wp[1], SB, 32, >> + ((func & 0x3) != 0) || SB_s); >> goto update_regs; >> >> default: >> @@ -458,7 +460,11 @@ cmp_s: >> } else { >> _FP_ROUND_ZERO(2, DB); >> } >> - FP_TO_INT_D(vc.wp[1], DB, 32, ((func & 0x3) != 0)); >> + /* DB_s: convert from minus long double to >> + * unsigned long long >> + */ >> + FP_TO_INT_D(vc.wp[1], DB, 32, >> + ((func & 0x3) != 0) || DB_s); >> goto update_regs; >> >> default: >> @@ -589,8 +595,11 @@ 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)); >> + /* SB*_s: convert from minus float to unsigned int */ >> + 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.4 >> >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html >> Please read the FAQ at http://www.tux.org/lkml/ >> >> ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-11-17 1:34 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-11-14 4:11 Fixed Powerpc SPE data type conversion failure Hai Shan 2010-11-14 4:11 ` [PATCH] Fix float to unsigned conversion failure with SPE enabled Hai Shan 2010-11-16 11:29 ` Josh Boyer 2010-11-16 11:29 ` Josh Boyer 2010-11-17 1:39 ` haishan 2010-11-17 1:39 ` haishan
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.