[clang] 09ffb9e - [AArch64][Clang] Implement ACLE rintn intrinsics (#66112)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 14 03:00:53 PDT 2023
Author: M Iyengar
Date: 2023-09-14T11:00:49+01:00
New Revision: 09ffb9ee19a73d8369ce11502e991c190fdafe5c
URL: https://github.com/llvm/llvm-project/commit/09ffb9ee19a73d8369ce11502e991c190fdafe5c
DIFF: https://github.com/llvm/llvm-project/commit/09ffb9ee19a73d8369ce11502e991c190fdafe5c.diff
LOG: [AArch64][Clang] Implement ACLE rintn intrinsics (#66112)
This patch adds support for two missing ACLE intrinsics for floating
point round with ties to even:
- rintn
- rintnf
These are specified in ACLE section 8.6:
[https://arm-software.github.io/acle/main/acle.html#floating-point-data-processing-intrinsics]
Added:
Modified:
clang/lib/Headers/arm_acle.h
clang/test/CodeGen/arm_acle.c
Removed:
################################################################################
diff --git a/clang/lib/Headers/arm_acle.h b/clang/lib/Headers/arm_acle.h
index c208512bab59829..61d80258d166a1d 100644
--- a/clang/lib/Headers/arm_acle.h
+++ b/clang/lib/Headers/arm_acle.h
@@ -592,6 +592,21 @@ __smusdx(int16x2_t __a, int16x2_t __b) {
}
#endif
+/* 8.6 Floating-point data-processing intrinsics */
+#if (defined(__ARM_FEATURE_DIRECTED_ROUNDING) && \
+ (__ARM_FEATURE_DIRECTED_ROUNDING)) && \
+ (defined(__ARM_64BIT_STATE) && __ARM_64BIT_STATE)
+static __inline__ double __attribute__((__always_inline__, __nodebug__))
+__rintn(double __a) {
+ return __builtin_roundeven(__a);
+}
+
+static __inline__ float __attribute__((__always_inline__, __nodebug__))
+__rintnf(float __a) {
+ return __builtin_roundevenf(__a);
+}
+#endif
+
/* 9.7 CRC32 intrinsics */
#if (defined(__ARM_FEATURE_CRC32) && __ARM_FEATURE_CRC32) || \
(defined(__ARM_64BIT_STATE) && __ARM_64BIT_STATE)
diff --git a/clang/test/CodeGen/arm_acle.c b/clang/test/CodeGen/arm_acle.c
index b1105a1d5aabb64..00afaf15fded392 100644
--- a/clang/test/CodeGen/arm_acle.c
+++ b/clang/test/CodeGen/arm_acle.c
@@ -1690,6 +1690,22 @@ int32_t test_jcvt(double v) {
}
#endif
+#if defined(__ARM_FEATURE_DIRECTED_ROUNDING) && defined(__ARM_64BIT_STATE)
+
+// AArch64-LABEL: @test_rintn(
+// AArch64-NEXT: entry:
+// AArch64-NEXT: call double @llvm.roundeven.f64(double [[TMP0:%.*]])
+double test_rintn(double a) {
+ return __rintn(a);
+}
+
+// AArch64-LABEL: @test_rintnf(
+// AArch64-NEXT: entry:
+// AArch64-NEXT: call float @llvm.roundeven.f32(float [[TMP0:%.*]])
+float test_rintnf(float b) {
+ return __rintnf(b);
+}
+#endif
#if defined(__ARM_64BIT_STATE) && defined(__ARM_FEATURE_RNG)
More information about the cfe-commits
mailing list