This is an archive of the discontinued LLVM Phabricator instance.

Make IEEEFloat::roundToIntegral more standard conformant
ClosedPublic

Authored by sepavloff on Feb 27 2020, 5:27 AM.

Details

Summary

Behavior of IEEEFloat::roundToIntegral is aligned with IEEE-754
operation roundToIntegralExact. In partucular this function now:

  • produces opInvalid for signaling NaNs,
  • returns opInexact if the result of rounding differs from argument.

Diff Detail

Event Timeline

sepavloff created this revision.Feb 27 2020, 5:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 27 2020, 5:27 AM
scanon added inline comments.Mar 9 2020, 10:38 AM
llvm/lib/Support/APFloat.cpp
2011

What is this check intended to do? AFAICT from a quick glance, this will never happen.

2020

fs will never be anything other than opOK here, right? By Sterbenz' lemma this subtraction is always exact.

scanon requested changes to this revision.Mar 9 2020, 10:38 AM
This revision now requires changes to proceed.Mar 9 2020, 10:38 AM
sepavloff updated this revision to Diff 249389.Mar 10 2020, 8:14 AM
sepavloff marked 2 inline comments as done.

Updated patch according to reviewer's feedback.

llvm/lib/Support/APFloat.cpp
2011

For signaling NaN fs may be opInvalid.
Reorganized code so that the respective check is made explicitly.

2020

Sterbenz' lemma! Exactly! Thank you very much!

sepavloff retitled this revision from Fix reporting inexact status in IEEEFloat::roundToIntegral to Make IEEEFloat::roundToIntegral more standard conformant.Mar 10 2020, 8:24 AM
sepavloff edited the summary of this revision. (Show Details)
scanon accepted this revision.Mar 10 2020, 8:50 AM
scanon added inline comments.
llvm/lib/Support/APFloat.cpp
1984

Correct as written, but can we get some brackets since we have the comment here?

This revision is now accepted and ready to land.Mar 10 2020, 8:50 AM
This revision was automatically updated to reflect the committed changes.