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>
This commit is contained in:
Richard Henderson 2014-07-03 12:36:34 -07:00
parent c24a8a0b6d
commit 7f2e40020c
1 changed files with 5 additions and 5 deletions

View File

@ -453,12 +453,12 @@ static uint64_t do_cvttq(CPUAlphaState *env, uint64_t a, int roundmode)
if (shift >= 0) { if (shift >= 0) {
/* In this case the number is so large that we must shift /* In this case the number is so large that we must shift
the fraction left. There is no rounding to do. */ the fraction left. There is no rounding to do. */
exc = FPCR_IOV | FPCR_INE; if (shift < 64) {
if (shift < 63) {
ret = frac << shift; 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 { } else {
uint64_t round; uint64_t round;