-
Notifications
You must be signed in to change notification settings - Fork 66
Improve documentation for VMLA/VMLS intrinsics for floats #419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The clang and GCC implementations for the VMLA/VMLS intrinsics for floats are the same except for the -ffp-contract=on case where GCC: uses VMUL+VADD/VSUM Clang: uses FMLA/FMLS (Fused MLA/MLS) Non-float VMLA/VMLS intrinsics reduce to MLA/MLS in both implementations. Previous ACLE releases (e.g. 2.1) made it clear that the VMLA/VMLS intrinsics for floats are implementation defined, but this information seem to have got lost in later releases. So redocument the implementation-defined behaviour.
|
I don't think this is correct, The
When Armv8-A was added, for backwards compatibility the however since Armv8-a doesn't have an rather than an instruction, to indicate that rounding shouldn't be done. So the clang behavior of fusing them is wrong (similar to GCC at some point). Clang was doing the right thing but changed at some point, and GCC was doing the wrong thing and we corrected it. That's why I don't think this intrinsics is implementation defined, because it has a defined behavior for allowing porting of code from Armv7. So |
|
Once you add |
That's not true at all, As I said before, this instruction is supposed to return the exact same value on |
|
Furthermore, LLVM's own documentation specifies that [1] https://clang.llvm.org/docs/UsersManual.html#cmdoption-ffp-contract |
|
The current documentation say's nothing about contraction. It says "This intrinsic compiles to the following instructions: RESULT[I] = a[i] + (b[i] * c[i])"? When I build this with -Ofast I get contraction. The specification has been poorly worded, with a difference in implementation being the result. We can either capture this, ideally in a way that suggests ways to avoid such issues (i.e. don't use flags whose behaviour is not guaranteed to be consistent across architectures), or we can continue to leave readers to work it out for themselves. |
Yes, this was a bad specification, and it happened because when Armv8-a was added, the decision was made to switch all the "instructions" in the standard to use Arvm8-a instructions. This of course doesn't work when Armv8-a didn't have a matching instruction. But note how the This compatibility with Armv7 however is the reason why many duplicate intrinsics exist, e.g. that's why we have both
I'm not saying that the documentation doesn't need updating. But I don't agree in updating it to be "implementation defined" because that was never the intention of it. But things got lost during the way. Note that GCC had this fused behavior before GCC 12. We explicitly took the decision to fix it due to complaints of people porting code. https://godbolt.org/z/WcfzTdf3E so this changed. We did so because of two clauses in the ACLE manual https://arm-software.github.io/acle/main/acle.html#undefined-behavior and https://arm-software.github.io/acle/main/acle.html#specification-of-advanced-simd-intrinsics where in this case the semantics comes from Armv7/Armv6 and prior. The confusion comes from instructions that don't exist in Armv8 but intrinsic were still added to aid porting of older code. |
Yep. I prefer we drop that part as well. For me the key bit is showing explicit calls to vaddq and vmulq. |
@TamarChristinaArm |
|
There are no plans to change the clang implementation. It is my understanding that if the |
I see. Thanks. I've removed that part. |
The clang and GCC implementations for the VMLA/VMLS intrinsics for floats are the same except for the -ffp-contract=on case where GCC: uses VMUL+VADD/VSUM
Clang: uses FMLA/FMLS (Fused MLA/MLS)
Non-float VMLA/VMLS intrinsics reduce to MLA/MLS in both implementations.
Previous ACLE releases (e.g. 2.1) made it clear that the VMLA/VMLS intrinsics for floats are implementation defined, but this information seem to have got lost in later releases.
So redocument the implementation-defined behaviour.
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.