<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><blockquote type="cite"><div>On Aug 8, 2014, at 2:59 PM, Sanjay Patel <<a href="mailto:spatel@rotateright.com">spatel@rotateright.com</a>> wrote:</div><br class="Apple-interchange-newline"><div><div dir="ltr"><div>FYI, I was looking at the SSE/AVX codegen here:<br><a href="http://llvm.org/bugs/show_bug.cgi?id=20578">http://llvm.org/bugs/show_bug.cgi?id=20578</a><br><br></div>If LLVM starts caring about FP exceptions, even this won't be possible. Is there a way of doing an IEEE-754 fneg in C/C++? Ie, there's no fneg() in libm, so any C method we choose could cause an exception, and that's not allowed by the IEEE definition of fneg.</div></div></blockquote><br></div><div>Huh? XOR[PS|PD] is an IEEE-754 negate( ) on x86; it does not raise any FP exceptions.</div><div><br></div><div>In C, it’s not specified at present whether –x corresponds to negate( ), but the general belief (among IEEE-754 committee members) seems to be that it should, and historically clang has mostly tried to behave that way.</div><div><br></div><div>On a platform where –x does not correspond to the IEEE-754 negate( ) operation, but the FP representation is known, you would type-pun to integer (via union or memcpy), xor the signbit, and type-pun back to FP to get the result.  The only platform I know of where even this isn’t possible is i386 under an ABI that returns on the x87 stack, where loading a single- or double- sNaN necessarily signals invalid.  Thankfully, the last such machine is now … what, 15 years old?</div><div><br></div><div>– Steve</div></body></html>