This is an archive of the discontinued LLVM Phabricator instance.

[libc] Add nearest integer instructions to fputil.
ClosedPublic

Authored by lntue on Jul 14 2022, 7:45 AM.

Details

Summary

Add round to nearest integer instructions to fputil. This will be
used in sinf implementation https://reviews.llvm.org/D123154

Diff Detail

Event Timeline

lntue created this revision.Jul 14 2022, 7:45 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 14 2022, 7:45 AM
lntue requested review of this revision.Jul 14 2022, 7:45 AM
This revision is now accepted and ready to land.Jul 14 2022, 10:14 AM
This revision was automatically updated to reflect the committed changes.
tschuett added a comment.EditedJul 31 2022, 4:36 AM

I am probably wrong, but ...
The Arm® Architecture Reference Manual defines a feature called FEAT_FRINTTS. It was added with Armv8.5.
FEAT_FRINTTS, Floating-point to integer instructions.

frintn is probably only available on modern ARM cores ala iPhone 12 from 2020.

You include arm_acle.h in a few places. There are intrinsics for frint with a feature flag, see https://gcc.gnu.org/legacy-ml/gcc-patches/2019-09/msg00053.html.

lntue added a comment.EditedJul 31 2022, 12:01 PM

I am probably wrong, but ...
The Arm® Architecture Reference Manual defines a feature called FEAT_FRINTTS. It was added with Armv8.5.
FEAT_FRINTTS, Floating-point to integer instructions.

frintn is probably only available on modern ARM cores ala iPhone 12 from 2020.

You include arm_acle.h in a few places. There are intrinsics for frint with a feature flag, see https://gcc.gnu.org/legacy-ml/gcc-patches/2019-09/msg00053.html.

I do think frintn is available on aarch64. I got it from https://developer.arm.com/documentation/ddi0487/ga section C7.2.162 (page 1873). I also tested it on a Raspberry Pi 400,

Also thanks for the suggestion about the intrinsics. I would definitely replacing these arm assembly with compiler intrinsics if they are available.

I can confirm that I found frintn on page 1873. What worries me is A2.8.1. There is a feature FEAT_FRINTTS added by Armv8.5.

This uncertainty can be easily solved by using the intrinsics. Thanks.