This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Setting and restoring rounding modes in sin/cos


Hi,

I'm trying to understand the code that sets and restores the floating
point state to try and eek out some performance from it.  I haven't
been able to figure out the need for SET_RESTORE_ROUND_53BIT vs
SET_RESTORE_ROUND_53 for x86_64 - I can see that it's needed for x87:

SET_RESTORE_ROUND (used in exp, log) only sets and restores the
rounding mode and does not touch the exception masks.  This was
holdexcept_setround, i.e. the same implementation as
SET_RESTORE_ROUND_53BIT before, but I assume the clearing of exception
mask, etc. was removed because it could result in delay in raising
floating point exceptions resulting from some operations within these
functions if exceptions are masked.

SET_RESTORE_ROUND_53BIT (used in sin/cos) sets the rounding mode,
exception mask and clears all exception flags.  Why can't we simply
get away with setting and restoring just the rounding mode like in
exp, log, etc?  That opens up a good opportunity for optimization
where I could avoid most of the set/restore code in the default case.
sin and cos run almost twice as fast in some cases.

Siddhesh


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]