Skip to contentSkip to conversation

powerpc: correctly handle fpu exceptions.

PATCH Applied Fabien Chouteau 2 participants 4 messages Apr 9, 2013 – Apr 19, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: correctly handle fpu exceptions.

From: Tristan Gingold <[email protected]>

Raise the exception on the first occurence, do not wait for the next floating point operation.

---
 target-ppc/fpu_helper.c |   23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
target-ppc/fpu_helper.c +12 -11
index 9e779ea..1e141fb 100644
@@ -470,6 +470,18 @@ void store_fpscr(CPUPPCState *env, uint64_t arg, uint32_t mask)
 
 void helper_float_check_status(CPUPPCState *env)
 {
+    int status = get_float_exception_flags(&env->fp_status);
+
+    if (status & float_flag_divbyzero) {
+        float_zero_divide_excp(env);
+    } else if (status & float_flag_overflow) {
+        float_overflow_excp(env);
+    } else if (status & float_flag_underflow) {
+        float_underflow_excp(env);
+    } else if (status & float_flag_inexact) {
+        float_inexact_excp(env);
+    }
+
     if (env->exception_index == POWERPC_EXCP_PROGRAM &&
         (env->error_code & POWERPC_EXCP_FP)) {
         /* Differred floating-point exception after target FPR update */
@@ -477,17 +489,6 @@ void helper_float_check_status(CPUPPCState *env)
             helper_raise_exception_err(env, env->exception_index,
                                        env->error_code);
         }
-    } else {
-        int status = get_float_exception_flags(&env->fp_status);
-        if (status & float_flag_divbyzero) {
-            float_zero_divide_excp(env);
-        } else if (status & float_flag_overflow) {
-            float_overflow_excp(env);
-        } else if (status & float_flag_underflow) {
-            float_underflow_excp(env);
-        } else if (status & float_flag_inexact) {
-            float_inexact_excp(env);
-        }
     }
 }
 
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 4 lines · Fabien Chouteau

From: Tristan Gingold <[email protected]>

Raise the exception on the first occurence, do not wait for the next floating point operation.

Do you have a test case for this one that I could use to compare results with real hardware?

Alex

Quoted 50 lines

---
target-ppc/fpu_helper.c | 23 ++++++++++++-----------

1 file changed, 12 insertions(+), 11 deletions(-)
target-ppc/fpu_helper.c +12 -11
index 9e779ea..1e141fb 100644
@@ -470,6 +470,18 @@ void store_fpscr(CPUPPCState *env, uint64_t arg, uint32_t mask)
 
 void helper_float_check_status(CPUPPCState *env)
 {
+    int status = get_float_exception_flags(&env->fp_status);
+
+    if (status & float_flag_divbyzero) {
+        float_zero_divide_excp(env);
+    } else if (status & float_flag_overflow) {
+        float_overflow_excp(env);
+    } else if (status & float_flag_underflow) {
+        float_underflow_excp(env);
+    } else if (status & float_flag_inexact) {
+        float_inexact_excp(env);
+    }
+
    if (env->exception_index == POWERPC_EXCP_PROGRAM &&
        (env->error_code & POWERPC_EXCP_FP)) {
        /* Differred floating-point exception after target FPR update */
@@ -477,17 +489,6 @@ void helper_float_check_status(CPUPPCState *env)
            helper_raise_exception_err(env, env->exception_index,
                                       env->error_code);
        }
-    } else {
-        int status = get_float_exception_flags(&env->fp_status);
-        if (status & float_flag_divbyzero) {
-            float_zero_divide_excp(env);
-        } else if (status & float_flag_overflow) {
-            float_overflow_excp(env);
-        } else if (status & float_flag_underflow) {
-            float_underflow_excp(env);
-        } else if (status & float_flag_inexact) {
-            float_inexact_excp(env);
-        }
    }
 }
 
Signature · 1 line
1.7.9.5
#2 lore raw
Quoted 10 lines · Alexander Graf
Quoted 4 lines · Fabien Chouteau

From: Tristan Gingold <[email protected]>

Raise the exception on the first occurence, do not wait for the next floating point operation.

Do you have a test case for this one that I could use to compare results with real hardware?

Not for real hardware, maybe you can try to build a simple program with just do a division by zero.

Signature · 1 line
Fabien Chouteau
#3 lore raw
In reply to Fabien Chouteau
Quoted 6 lines · Fabien Chouteau

From: Tristan Gingold <[email protected]>

Raise the exception on the first occurence, do not wait for the next floating point operation.

Thanks, applied to ppc-next.

Alex

Quoted 48 lines

---
target-ppc/fpu_helper.c | 23 ++++++++++++-----------

1 file changed, 12 insertions(+), 11 deletions(-)
target-ppc/fpu_helper.c +12 -11
index 9e779ea..1e141fb 100644
@@ -470,6 +470,18 @@ void store_fpscr(CPUPPCState *env, uint64_t arg, uint32_t mask)
 
 void helper_float_check_status(CPUPPCState *env)
 {
+    int status = get_float_exception_flags(&env->fp_status);
+
+    if (status & float_flag_divbyzero) {
+        float_zero_divide_excp(env);
+    } else if (status & float_flag_overflow) {
+        float_overflow_excp(env);
+    } else if (status & float_flag_underflow) {
+        float_underflow_excp(env);
+    } else if (status & float_flag_inexact) {
+        float_inexact_excp(env);
+    }
+
    if (env->exception_index == POWERPC_EXCP_PROGRAM &&
        (env->error_code & POWERPC_EXCP_FP)) {
        /* Differred floating-point exception after target FPR update */
@@ -477,17 +489,6 @@ void helper_float_check_status(CPUPPCState *env)
            helper_raise_exception_err(env, env->exception_index,
                                       env->error_code);
        }
-    } else {
-        int status = get_float_exception_flags(&env->fp_status);
-        if (status & float_flag_divbyzero) {
-            float_zero_divide_excp(env);
-        } else if (status & float_flag_overflow) {
-            float_overflow_excp(env);
-        } else if (status & float_flag_underflow) {
-            float_underflow_excp(env);
-        } else if (status & float_flag_inexact) {
-            float_inexact_excp(env);
-        }
    }
 }
 
Signature · 1 line
1.7.9.5