Fix specification of FP16 scalar conversion to/from fixed point#435
Fix specification of FP16 scalar conversion to/from fixed point#435momchil-velikov wants to merge 1 commit into
Conversation
CarolineConcatto
left a comment
There was a problem hiding this comment.
I understand that GCC and LLVM use different instructions, which is inconsistent, but changing this would also change the behaviour of the intrinsic.Do we want to do that after seven years?
Taking as an example The specification says:
Let's ignore for a moment that spec says "vector" and focus on the important part, which is the numerical behaviour of the intrinsic - it converts using rounding mode specified by FPCR. However, the mentioned instruction takes its source operand from a 16-bit register. There's no guarantee that the discarded bits (since the original argument is 32-bit) do not affect the final result for all rounding modes. In that sense, the specification either self-contradicting, unimplementable, or implicitly assumes the compiler does some non-trivial conversion of a 32-bit value to 16 bits, in which case it'd be incomplete. Therefore it's a bug in the specification that needs to be fixed, and here's my proposal how to fix it, which is consistent with the original intent of using FPCR rounding mode, improves precision, is at least as efficient as the previous approach, is consistent with GCC implementation, and is simple in the sense it just changes the instruction (as opposed to specifying an eleborate conversion sequence that ensures final result using the current instruction is rounded as specified by FPCR). Now the question is, does the change in behaviour negatively affects users? There are a few factors that reduce the exposure area:
That is to say, while there could be negatively affected users, it's unlikely. |
|
Another option would be to evolve the specification over a period of time:
|
Related to llvm/llvm-project#197083
name: Pull request
about: Technical issues, document format problems, bugs in scripts or feature proposal.
Thank you for submitting a pull request!
If this PR is about a bugfix:
Please use the bugfix label and make sure to go through the checklist below.
If this PR is about a proposal:
We are looking forward to evaluate your proposal, and if possible to
make it part of the Arm C Language Extension (ACLE) specifications.
We would like to encourage you reading through the contribution
guidelines, in particular the section on submitting
a proposal.
Please use the proposal label.
As for any pull request, please make sure to go through the below
checklist.
Checklist: (mark with
Xthose which apply)PR (do not bother creating the issue if all you want to do is
fixing the bug yourself).
SPDX-FileCopyrightTextlines on topof any file I have edited. Format is
SPDX-FileCopyrightText: Copyright {year} {entity or name} <{contact informations}>(Please update existing copyright lines if applicable. You can
specify year ranges with hyphen , as in
2017-2019, and usecommas to separate gaps, as in
2018-2020, 2022).Copyrightsection of the sources of thespecification I have edited (this will show up in the text
rendered in the PDF and other output format supported). The
format is the same described in the previous item.
tricky to set up on non-*nix machines). The sequence can be
found in the contribution
guidelines. Don't
worry if you cannot run these scripts on your machine, your
patch will be automatically checked in the Actions of the pull
request.
introduced in this PR in the section Changes for next
release of the section Change Control/Document history
of the document. Create Changes for next release if it does
not exist. Notice that changes that are not modifying the
content and rendering of the specifications (both HTML and PDF)
do not need to be listed.
correctness of the result in the PDF output (please refer to the
instructions on how to build the PDFs
locally).
draftversionis set totruein the YAML headerof the sources of the specifications I have modified.
in the README page of the project.