Skip to content

Commit 09ffb9e

Browse files
authored
[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]
1 parent 61924da commit 09ffb9e

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

clang/lib/Headers/arm_acle.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,21 @@ __smusdx(int16x2_t __a, int16x2_t __b) {
592592
}
593593
#endif
594594

595+
/* 8.6 Floating-point data-processing intrinsics */
596+
#if (defined(__ARM_FEATURE_DIRECTED_ROUNDING) && \
597+
(__ARM_FEATURE_DIRECTED_ROUNDING)) && \
598+
(defined(__ARM_64BIT_STATE) && __ARM_64BIT_STATE)
599+
static __inline__ double __attribute__((__always_inline__, __nodebug__))
600+
__rintn(double __a) {
601+
return __builtin_roundeven(__a);
602+
}
603+
604+
static __inline__ float __attribute__((__always_inline__, __nodebug__))
605+
__rintnf(float __a) {
606+
return __builtin_roundevenf(__a);
607+
}
608+
#endif
609+
595610
/* 9.7 CRC32 intrinsics */
596611
#if (defined(__ARM_FEATURE_CRC32) && __ARM_FEATURE_CRC32) || \
597612
(defined(__ARM_64BIT_STATE) && __ARM_64BIT_STATE)

clang/test/CodeGen/arm_acle.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,6 +1690,22 @@ int32_t test_jcvt(double v) {
16901690
}
16911691
#endif
16921692

1693+
#if defined(__ARM_FEATURE_DIRECTED_ROUNDING) && defined(__ARM_64BIT_STATE)
1694+
1695+
// AArch64-LABEL: @test_rintn(
1696+
// AArch64-NEXT: entry:
1697+
// AArch64-NEXT: call double @llvm.roundeven.f64(double [[TMP0:%.*]])
1698+
double test_rintn(double a) {
1699+
return __rintn(a);
1700+
}
1701+
1702+
// AArch64-LABEL: @test_rintnf(
1703+
// AArch64-NEXT: entry:
1704+
// AArch64-NEXT: call float @llvm.roundeven.f32(float [[TMP0:%.*]])
1705+
float test_rintnf(float b) {
1706+
return __rintnf(b);
1707+
}
1708+
#endif
16931709

16941710
#if defined(__ARM_64BIT_STATE) && defined(__ARM_FEATURE_RNG)
16951711

0 commit comments

Comments
 (0)