<div dir="ltr">Hi Mehdi,<div><br></div><div>Thanks for the feedback. I think the comment is fine - the problem is just that the original conditional didn't exactly match it. With the addition of the underflow check I believe the condition now matches the comment: The sign is only tweaked if the result of the addition is exactly zero, rather than a small result that truncates to zero.</div><div><br></div><div>CC'ing llvm-commits, where this email should have gone in the first place. :)<div><br></div></div><div>Cheers,</div><div>Lang.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 1, 2015 at 10:56 PM, Mehdi Amini <span dir="ltr"><<a href="mailto:mehdi.amini@apple.com" target="_blank">mehdi.amini@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi Lang,<div><br><div><div><div class="h5"><blockquote type="cite"><div>On Jan 1, 2015, at 5:57 PM, Lang Hames <<a href="mailto:lhames@gmail.com" target="_blank">lhames@gmail.com</a>> wrote:</div><br><div><div dir="ltr">Hi All,<div><br></div><div>APFloat::fusedMultiplyAdd currently computes the wrong signed zero when small negative results are truncated back to zero in standard precision. The following snippet handles the signedness in fusedMultiplyAdd:</div><div><br></div><font face="monospace, monospace">/* If two numbers add (exactly) to zero, IEEE 754 decrees it is a<br>   positive zero unless rounding to minus infinity, except that                                                    <br>   adding two like-signed zeroes gives that zero.  */</font><div><font face="monospace, monospace">if (category == fcZero && sign != addend.sign)<br>  sign = (rounding_mode == rmTowardNegative);</font><div><br></div><div>The test "category == fcZero" tells us that the result was zero after rounding back down to standard precision, but since the addition is carried out in extended precision this doesn't guarantee that the result of the addition was exactly zero (so the comment text may not apply). The attached patch adds a check for underflow during truncation which ensures the correct signedness of the result.</div></div></div></div></blockquote><div><br></div><div><br></div></div></div><div>According to what you describe ("the comment text may not apply"), I feel that the comment might be updated as well.</div><div><br></div><div>Best,</div><div><br></div><div>Mehdi</div></div><br></div></div></blockquote></div><br></div>