rint/nearbyint for x86-64

John Reiser jreiser@BitWagon.com
Wed Mar 12 17:37:00 GMT 2008


__rint forgot to isolate the sign of the scalar:

> ENTRY(__rint)
> 	movmskpd %xmm0,%eax  // extract packed signs to low 2 bits of eax
> 	stmxcsr -4(%rsp); movl -4(%rsp),%ecx  // original mxcsr
> 	lea two52p(%rip),%rdx  // no double index with %rip as base
> 	andl $~(1<<P_PRECISION_MASK),-4(%rsp)

 	and $1,%eax  // sign of scalar in xmm0

> 	ldmxcsr -4(%rsp)  // enable Precision exception
> 	add %eax,%eax  // 2*
  ...
-- 



More information about the Libc-alpha mailing list