From de4eea7d7ea86e54843507c68d6672eca9d8c7bb Mon Sep 17 00:00:00 2001 From: Georg-Johann Lay Date: Wed, 8 May 2024 17:56:05 +0200 Subject: AVR: target/114981 - Support __builtin_powi[l] / __powidf2. This supports __powidf2 by means of a double wrapper for already existing f7_powi (renamed to __f7_powi by f7-renames.h). It tweaks the implementation so that it does not perform trivial multiplications with 1.0 any more, but instead uses a move. It also fixes the last statement of f7_powi, which was wrong. Notice that f7_powi was unused until now. PR target/114981 libgcc/config/avr/libf7/ * libf7-common.mk (F7_ASM_PARTS): Add D_powi * libf7-asm.sx (F7MOD_D_powi_, __powidf2): New module and function. * libf7.c (f7_powi): Fix last (wrong) statement. Tweak trivial multiplications with 1.0. gcc/testsuite/ * gcc.target/avr/pr114981-powil.c: New test. --- gcc/testsuite/gcc.target/avr/pr114981-powil.c | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 gcc/testsuite/gcc.target/avr/pr114981-powil.c (limited to 'gcc') diff --git a/gcc/testsuite/gcc.target/avr/pr114981-powil.c b/gcc/testsuite/gcc.target/avr/pr114981-powil.c new file mode 100644 index 0000000..70f8e79 --- /dev/null +++ b/gcc/testsuite/gcc.target/avr/pr114981-powil.c @@ -0,0 +1,33 @@ +/* { dg-do run { target { ! avr_tiny } } } */ +/* { dg-additional-options "-Os" } */ + +const long double vals[] = + { + 0.0625L, -0.125L, 0.25L, -0.5L, + 1.0L, + -2.0L, 4.0L, -8.0L, 16.0L + }; + +#define ARRAY_SIZE(X) ((int) (sizeof(X) / sizeof(*X))) + +__attribute__((noinline,noclone)) +void test1 (long double x) +{ + int i; + + for (i = 0; i < ARRAY_SIZE (vals); ++i) + { + long double val0 = vals[i]; + long double val1 = __builtin_powil (x, i - 4); + __asm ("" : "+r" (val0)); + + if (val0 != val1) + __builtin_exit (__LINE__); + } +} + +int main (void) +{ + test1 (-2.0L); + return 0; +} -- cgit v1.1