aboutsummaryrefslogtreecommitdiff
path: root/target-alpha/fpu_helper.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@twiddle.net>2014-07-03 12:36:34 -0700
committerRichard Henderson <rth@twiddle.net>2015-05-18 13:03:46 -0700
commit7f2e40020cfc827f7e59670f8c400b0b9a704481 (patch)
tree330630de3a2f00f005b264828a5f7e2947f0f773 /target-alpha/fpu_helper.c
parentc24a8a0b6dad5a33d84f5fb846edb28c43312c71 (diff)
target-alpha: Fix cvttq vs large integers
The range +- 2**63 - 2**64 was returning the wrong truncated result. We also incorrectly signaled overflow for -2**63. Reported-by: Al Viro <viro@ZenIV.linux.org.uk> Signed-off-by: Richard Henderson <rth@twiddle.net>
Diffstat (limited to 'target-alpha/fpu_helper.c')
-rw-r--r--target-alpha/fpu_helper.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/target-alpha/fpu_helper.c b/target-alpha/fpu_helper.c
index 132b5a2a1a..9449c57243 100644
--- a/target-alpha/fpu_helper.c
+++ b/target-alpha/fpu_helper.c
@@ -453,12 +453,12 @@ static uint64_t do_cvttq(CPUAlphaState *env, uint64_t a, int roundmode)
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) {
+ if (shift < 64) {
ret = frac << shift;
- if ((ret >> shift) == frac) {
- exc = 0;
- }
+ }
+ /* Check for overflow. Note the special case of -0x1p63. */
+ if (shift >= 11 && a != 0xC3E0000000000000ull) {
+ exc = FPCR_IOV | FPCR_INE;
}
} else {
uint64_t round;