Skip to content

Commit

Permalink
[AArch64][Clang] Implement ACLE rintn intrinsics (llvm#66112)
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
Blue-Dot authored and kstoimenov committed Sep 14, 2023
1 parent e6bf958 commit 235f91c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
15 changes: 15 additions & 0 deletions clang/lib/Headers/arm_acle.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions clang/test/CodeGen/arm_acle.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 235f91c

Please sign in to comment.