[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 08/17] target-alpha: Raise IOV from CVTTQ
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH v2 08/17] target-alpha: Raise IOV from CVTTQ |
Date: |
Tue, 12 May 2015 10:39:38 -0700 |
Floating-point overflow is a different bit from integer overflow.
Reported-by: Al Viro <address@hidden>
Signed-off-by: Richard Henderson <address@hidden>
---
target-alpha/fpu_helper.c | 25 +++++++++----------------
target-alpha/helper.h | 1 -
target-alpha/translate.c | 17 ++++-------------
3 files changed, 13 insertions(+), 30 deletions(-)
diff --git a/target-alpha/fpu_helper.c b/target-alpha/fpu_helper.c
index 914c1d5..132b5a2 100644
--- a/target-alpha/fpu_helper.c
+++ b/target-alpha/fpu_helper.c
@@ -427,12 +427,9 @@ uint64_t helper_cvtqs(CPUAlphaState *env, uint64_t a)
/* Implement float64 to uint64 conversion without saturation -- we must
supply the truncated result. This behaviour is used by the compiler
- to get unsigned conversion for free with the same instruction.
+ to get unsigned conversion for free with the same instruction. */
- The VI flag is set when overflow or inexact exceptions should be raised. */
-
-static inline uint64_t inline_cvttq(CPUAlphaState *env, uint64_t a,
- int roundmode, int VI)
+static uint64_t do_cvttq(CPUAlphaState *env, uint64_t a, int roundmode)
{
uint64_t frac, ret = 0;
uint32_t exp, sign, exc = 0;
@@ -447,7 +444,7 @@ static inline uint64_t inline_cvttq(CPUAlphaState *env,
uint64_t a,
goto do_underflow;
}
} else if (exp == 0x7ff) {
- exc = (frac ? FPCR_INV : VI ? FPCR_OVF : 0);
+ exc = (frac ? FPCR_INV : FPCR_IOV | FPCR_INE);
} else {
/* Restore implicit bit. */
frac |= 0x10000000000000ull;
@@ -456,10 +453,11 @@ static inline uint64_t inline_cvttq(CPUAlphaState *env,
uint64_t a,
if (shift >= 0) {
/* In this case the number is so large that we must shift
the fraction left. There is no rounding to do. */
+ exc = FPCR_IOV | FPCR_INE;
if (shift < 63) {
ret = frac << shift;
- if (VI && (ret >> shift) != frac) {
- exc = FPCR_OVF;
+ if ((ret >> shift) == frac) {
+ exc = 0;
}
}
} else {
@@ -482,7 +480,7 @@ static inline uint64_t inline_cvttq(CPUAlphaState *env,
uint64_t a,
}
if (round) {
- exc = (VI ? FPCR_INE : 0);
+ exc = FPCR_INE;
switch (roundmode) {
case float_round_nearest_even:
if (round == (1ull << 63)) {
@@ -514,17 +512,12 @@ static inline uint64_t inline_cvttq(CPUAlphaState *env,
uint64_t a,
uint64_t helper_cvttq(CPUAlphaState *env, uint64_t a)
{
- return inline_cvttq(env, a, FP_STATUS.float_rounding_mode, 1);
+ return do_cvttq(env, a, FP_STATUS.float_rounding_mode);
}
uint64_t helper_cvttq_c(CPUAlphaState *env, uint64_t a)
{
- return inline_cvttq(env, a, float_round_to_zero, 0);
-}
-
-uint64_t helper_cvttq_svic(CPUAlphaState *env, uint64_t a)
-{
- return inline_cvttq(env, a, float_round_to_zero, 1);
+ return do_cvttq(env, a, float_round_to_zero);
}
uint64_t helper_cvtqt(CPUAlphaState *env, uint64_t a)
diff --git a/target-alpha/helper.h b/target-alpha/helper.h
index 67a6e32..9e7b771 100644
--- a/target-alpha/helper.h
+++ b/target-alpha/helper.h
@@ -83,7 +83,6 @@ DEF_HELPER_FLAGS_2(cvtqg, TCG_CALL_NO_RWG, i64, env, i64)
DEF_HELPER_FLAGS_2(cvttq, TCG_CALL_NO_RWG, i64, env, i64)
DEF_HELPER_FLAGS_2(cvttq_c, TCG_CALL_NO_RWG, i64, env, i64)
-DEF_HELPER_FLAGS_2(cvttq_svic, TCG_CALL_NO_RWG, i64, env, i64)
DEF_HELPER_FLAGS_2(setroundmode, TCG_CALL_NO_RWG, void, env, i32)
DEF_HELPER_FLAGS_2(setflushzero, TCG_CALL_NO_RWG, void, env, i32)
diff --git a/target-alpha/translate.c b/target-alpha/translate.c
index f121320..7868cc4 100644
--- a/target-alpha/translate.c
+++ b/target-alpha/translate.c
@@ -760,23 +760,14 @@ static void gen_cvttq(DisasContext *ctx, int rb, int rc,
int fn11)
vb = gen_ieee_input(ctx, rb, fn11, 0);
vc = dest_fpr(ctx, rc);
- /* Almost all integer conversions use cropped rounding, and most
- also do not have integer overflow enabled. Special case that. */
- switch (fn11) {
- case QUAL_RM_C:
+ /* Almost all integer conversions use cropped rounding;
+ special case that. */
+ if ((fn11 & QUAL_RM_MASK) == QUAL_RM_C) {
gen_helper_cvttq_c(vc, cpu_env, vb);
- break;
- case QUAL_V | QUAL_RM_C:
- case QUAL_S | QUAL_V | QUAL_RM_C:
- case QUAL_S | QUAL_V | QUAL_I | QUAL_RM_C:
- gen_helper_cvttq_svic(vc, cpu_env, vb);
- break;
- default:
+ } else {
gen_qual_roundmode(ctx, fn11);
gen_helper_cvttq(vc, cpu_env, vb);
- break;
}
-
gen_fp_exc_raise(rc, fn11);
}
--
2.1.0
- [Qemu-devel] [PATCH v2 00/17] target-alpha fpu improvments, Richard Henderson, 2015/05/12
- [Qemu-devel] [PATCH v2 02/17] target-alpha: Rename floating-point subroutines, Richard Henderson, 2015/05/12
- [Qemu-devel] [PATCH v2 04/17] target-alpha: Set PC correctly for floating-point exceptions, Richard Henderson, 2015/05/12
- [Qemu-devel] [PATCH v2 01/17] target-alpha: Move VAX helpers to a new file, Richard Henderson, 2015/05/12
- [Qemu-devel] [PATCH v2 05/17] target-alpha: Tidy FPCR representation, Richard Henderson, 2015/05/12
- [Qemu-devel] [PATCH v2 06/17] target-alpha: Set fpcr_exc_status even for disabled exceptions, Richard Henderson, 2015/05/12
- [Qemu-devel] [PATCH v2 03/17] target-alpha: Forget installed round mode after MT_FPCR, Richard Henderson, 2015/05/12
- [Qemu-devel] [PATCH v2 07/17] target-alpha: Set EXC_M_SWC for exceptions from /S insns, Richard Henderson, 2015/05/12
- [Qemu-devel] [PATCH v2 09/17] target-alpha: Fix cvttq vs large integers, Richard Henderson, 2015/05/12
- [Qemu-devel] [PATCH v2 08/17] target-alpha: Raise IOV from CVTTQ,
Richard Henderson <=
- [Qemu-devel] [PATCH v2 11/17] target-alpha: Fix integer overflow checking insns, Richard Henderson, 2015/05/12
- [Qemu-devel] [PATCH v2 12/17] target-alpha: Implement WH64EN, Richard Henderson, 2015/05/12
- [Qemu-devel] [PATCH v2 10/17] target-alpha: Fix cvttq vs inf, Richard Henderson, 2015/05/12
- [Qemu-devel] [PATCH v2 13/17] target-alpha: Disallow literal operand to 1C.30 to 1C.37, Richard Henderson, 2015/05/12
- [Qemu-devel] [PATCH v2 14/17] target-alpha: Raise EXC_M_INV properly for fp inputs, Richard Henderson, 2015/05/12
- [Qemu-devel] [PATCH v2 17/17] target-alpha: Rewrite helper_zapnot, Richard Henderson, 2015/05/12
- [Qemu-devel] [PATCH v2 15/17] target-alpha: Suppress underflow from CVTTQ if DNZ, Richard Henderson, 2015/05/12
- [Qemu-devel] [PATCH v2 16/17] target-alpha: Raise IOV from CVTQL, Richard Henderson, 2015/05/12