Skip to contentSkip to conversation

Fixed Powerpc SPE data type conversion failure

PATCH In review Hai Shan 3 participants 4 messages Nov 14, 2010 – Nov 17, 2010 PowerPC

lore
Share & tools
lore

Hai Shan

author
#0 lore raw

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(-)
author
#1 lore raw

PATCH 1/1 Fix float to unsigned conversion failure with SPE enabled

Fixed the failure on converting minus float to unsigned int with SPE enabled

---
 arch/powerpc/math-emu/math_efp.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)
arch/powerpc/math-emu/math_efp.c +13 -4
index 41f4ef3..338a128 100644
@@ -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:
Signature · 1 line
1.7.0.4
#2 lore raw

Re: [PATCH] Fix float to unsigned conversion failure with SPE enabled

Quoted 3 lines · Hai Shan

Fixed the failure on converting minus float to unsigned int with SPE enabled

You should make sure to send PowerPC patches to linuxppc-dev.

josh

Quoted 55 lines

---
 arch/powerpc/math-emu/math_efp.c |   17 +++++++++++++----

 1 files changed, 13 insertions(+), 4 deletions(-)
arch/powerpc/math-emu/math_efp.c +3 -1
index 41f4ef3..338a128 100644
@@ -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:

arch/powerpc/math-emu/math_efp.c +5 -1
@@ -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:

arch/powerpc/math-emu/math_efp.c +5 -2
@@ -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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

#3 lore raw

Re: [PATCH] Fix float to unsigned conversion failure with SPE enabled

Quoted 10 lines · Josh Boyer
Quoted 4 lines · Hai Shan

Fixed the failure on converting minus float to unsigned int with SPE enabled

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

Quoted 59 lines

josh

Quoted 56 lines
---
 arch/powerpc/math-emu/math_efp.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)
arch/powerpc/math-emu/math_efp.c +13 -5
index 41f4ef3..338a128 100644
@@ -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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/