[PATCH] D47807: Make uitofp and sitofp defined on overflow.

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 6 10:16:32 PDT 2018


spatel added reviewers: chandlerc, rsmith, qcolombet.
spatel added a comment.

This is reversing part of https://reviews.llvm.org/D5603 / https://reviews.llvm.org/rL219542 . I see there was some controversy in the post-commit thread, although it was for the FP -> int direction. Let me add those commenters as reviewers in any case.

For reference, IEEE754, section 7.4 says:
"The overflow exception shall be signaled if and only if the destination format’s largest finite number is exceeded in magnitude by what would have been the rounded floating-point result (see 4) were the exponent range unbounded. The default result shall be determined by the rounding-direction attribute and the sign of the intermediate result as follows:
a) roundTiesToEven and roundTiesToAway carry all overflows to ∞ with the sign of the intermediate result."

And the C standard, section 6.3.1.4 says:
"When a value of integer type is converted to a real floating type, if the value being converted can be represented exactly in the new type, it is unchanged. If the value being converted is in the range of values that can be represented but cannot be represented exactly, the result is either the nearest higher or nearest lower representable value, chosen in an implementation-defined manner. If the value being converted is outside the range of values that can be represented, the behavior is undefined."

That language (like the LangRef regardless of what we decide here) probably needs refinement because there is no "outside of the range" of infinity?

Note: I moved/corrected the tests at https://reviews.llvm.org/rL334107 (shouldn't have been under instcombine in the first place). Please rebase with full context for the record.


Repository:
  rL LLVM

https://reviews.llvm.org/D47807





More information about the llvm-commits mailing list