Mask out the exceptions that have no correspondance on
Alpha so that zero/non-zero tests work as expected.

Reported-by: Al Viro <v...@zeniv.linux.org.uk>
Signed-off-by: Richard Henderson <r...@twiddle.net>
---
 target-alpha/fpu_helper.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/target-alpha/fpu_helper.c b/target-alpha/fpu_helper.c
index 9b297de..f7fe31e 100644
--- a/target-alpha/fpu_helper.c
+++ b/target-alpha/fpu_helper.c
@@ -68,12 +68,17 @@ static inline void fp_exc_raise1(CPUAlphaState *env, 
uintptr_t retaddr,
     arith_excp(env, retaddr, hw_exc, 1ull << regno);
 }
 
+/* There are several flags that softfloat raises that are irrelevant.  */
+#define EXC_MASK (float_flag_invalid | float_flag_int_overflow \
+                  | float_flag_divbyzero | float_flag_overflow \
+                  | float_flag_underflow | float_flag_inexact)
+
 /* Raise exceptions for ieee fp insns without software completion.
    In that case there are no exceptions that don't trap; the mask
    doesn't apply.  */
 void helper_fp_exc_raise(CPUAlphaState *env, uint32_t ignore, uint32_t regno)
 {
-    uint32_t exc = (uint8_t)env->fp_status.float_exception_flags;
+    uint32_t exc = env->fp_status.float_exception_flags & EXC_MASK;
     if (exc) {
         env->fpcr_exc_status |= exc;
         exc &= ~ignore;
@@ -86,7 +91,7 @@ void helper_fp_exc_raise(CPUAlphaState *env, uint32_t ignore, 
uint32_t regno)
 /* Raise exceptions for ieee fp insns with software completion.  */
 void helper_fp_exc_raise_s(CPUAlphaState *env, uint32_t ignore, uint32_t regno)
 {
-    uint32_t exc = (uint8_t)env->fp_status.float_exception_flags;
+    uint32_t exc = env->fp_status.float_exception_flags & EXC_MASK;
     if (exc) {
         env->fpcr_exc_status |= exc;
         exc &= ~ignore;
-- 
1.9.3


Reply via email to