NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: lib/51530: ldexp(2.0,INT_MAX) still zero on mips64el



The following reply was made to PR lib/51530; it has been noted by GNATS.

From: coypu%SDF.ORG@localhost
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: lib/51530: ldexp(2.0,INT_MAX) still zero on mips64el
Date: Thu, 6 Oct 2016 01:27:46 +0000

 So:
 
 MIPS has its own implementation of ldexp: lib/libc/arch/mips/gen/ldexp.S
 
 
      71 	addu	t1, t1, a2		# scale exponent
      72 	sll	v0, a2, 20		# position N for addition
      73 	bge	t1, DEXP_INF, 8f	# overflow?
      74 	addu	v0, v0, v1		# multiply by (2**N)
      75 	ble	t1, zero, 4f		# underflow?
 
 
 The exponent will never underflow, because addu is 'add unsigned'.
 But even if changed to add, we run into a surprise:
 
 According to MIPS Architecture For Programmers Volume II-A: The MIPS64
 Instruction Set [1] page 51,
 
 If the addition results in 32-bit 2's complement arithmetic overflow, the
 destination register is not modified and an Integer Overflow exception occurs
 
 This behaviour is different from the expected integer overflow
 
 [1] - http://wiki.prplfoundation.org/w/images/6/6f/MD00087-2B-MIPS64BIS-AFP-05.04.pdf
 


Home | Main Index | Thread Index | Old Index